Class LuaNil
- Direct Known Subclasses:
LuaValue.None
nil
There will be one instance of this class, LuaValue.NIL
,
per Java virtual machine.
However, the Varargs
instance LuaValue.NONE
which is the empty list,
is also considered treated as a nil value by default.
Although it is possible to test for nil using Java == operator,
the recommended approach is to use the method LuaValue.isnil()
instead. By using that any ambiguities between
LuaValue.NIL
and LuaValue.NONE
are avoided.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.prineside.luaj.LuaValue
LuaValue.NillableSerializer, LuaValue.None
Nested classes/interfaces inherited from class com.prineside.luaj.Varargs
Varargs.ArrayVarargs
-
Field Summary
FieldsFields inherited from class com.prineside.luaj.LuaValue
ADD, CALL, CONCAT, DIV, EMPTYSTRING, ENV, EQ, FALSE, INDEX, LE, LEN, LT, METATABLE, MINUSONE, MOD, MODE, MUL, NEWINDEX, NIL, NILLABLE_SERIALIZER, NILS, NONE, NOVALS, ONE, POW, SUB, TBOOLEAN, TFUNCTION, TINT, TLIGHTUSERDATA, TNIL, TNONE, TNUMBER, TOSTRING, TRUE, TSTRING, TTABLE, TTHREAD, TUSERDATA, TVALUE, TYPE_NAMES, UNM, ZERO
-
Method Summary
Modifier and TypeMethodDescriptionCheck that this is not the valueLuaValue.NIL
, or throwLuaError
if it isboolean
Get the metatable for thisLuaValue
boolean
isnil()
Check ifthis
is#NIL
boolean
Return true if this is a valid key in a table index operation.not()
Unary not: return inverse boolean value(~this)
as defined by lua not operatorboolean
optboolean
(boolean defval) Check that optional argument is a boolean and return its boolean valueoptclosure
(LuaClosure defval) Check that optional argument is a closure and return asLuaClosure
double
optdouble
(double defval) Check that optional argument is a number or string convertible to number and return as doubleoptfunction
(LuaFunction defval) Check that optional argument is a function and return asLuaFunction
int
optint
(int defval) Check that optional argument is a number or string convertible to number and return as intoptjstring
(String defval) Check that optional argument is a string or number and return as Java Stringlong
optlong
(long defval) Check that optional argument is a number or string convertible to number and return as longCheck that optional argument is a number or string convertible to number and return asLuaNumber
Check that optional argument is a string or number and return asLuaString
Check that optional argument is a table and return asLuaTable
Check that optional argument is a thread and return asLuaThread
optuserdata
(Class c, Object defval) Check that optional argument is a userdata whose instance is of a type and return the Object instanceoptuserdata
(Object defval) Check that optional argument is a userdata and return the Object instancePerform argument check that this is not nil or none.boolean
Convert to boolean false ifLuaValue.NIL
orLuaValue.FALSE
, true if anything elseConvert to human readable String for any type.toString()
Convert the value to a human readable string usingLuaValue.tojstring()
int
type()
Get the enumeration value for the type of this value.typename()
Get the String name of the type of this value.Methods inherited from class com.prineside.luaj.LuaValue
add, add, add, and, arg, arg1, argerror, assert_, buffer, call, call, call, call, call, cBool, cDouble, cFloat, checkboolean, checkclosure, checkdouble, checkfunction, checkglobals, checkint, checkjstring, checklong, checknumber, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, cInt, cNcDouble, cNcFloat, cNcInt, cObject, comparemt, concat, concat, concatmt, concatTo, concatTo, concatTo, cRegObject, cVarargs, cVarargs, cVarargs, cVarargs, cVarargs, cVarargs, cVarargs, cVarargs, div, div, div, divInto, eq, eq_b, eqmtcall, error, get, get, get, gt, gt, gt, gt_b, gt_b, gt_b, gteq, gteq, gteq, gteq_b, gteq_b, gteq_b, inext, initupvalue1, invoke, invoke, invoke, invoke, invokemethod, invokemethod, invokemethod, invokemethod, isboolean, isclosure, isfunction, isint, isinttype, islong, isnumber, isRegObject, isstring, istable, isthread, isuserdata, isuserdata, len, length, listOf, listOf, load, lt, lt, lt, lt_b, lt_b, lt_b, lteq, lteq, lteq, lteq_b, lteq_b, lteq_b, markAsConst, metatag, method, method, method, method, method, method, mod, mod, mod, modFrom, mul, mul, mul, narg, neg, neq, neq_b, next, onInvoke, or, pow, pow, pow, powWith, powWith, presize, raweq, raweq, raweq, raweq, raweq, rawget, rawget, rawget, rawlen, rawset, rawset, rawset, rawset, rawset, rawset, rawset, rawsetlist, set, set, set, set, set, set, set, setmetatable, strcmp, strcmp, strongvalue, strvalue, sub, sub, sub, subargs, subFrom, subFrom, tableOf, tableOf, tableOf, tableOf, tableOf, tableOf, tailcallOf, testfor_b, tobyte, tochar, todouble, tofloat, toint, tolong, tonumber, toshort, tostring, touserdata, touserdata, userdataOf, userdataOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf
Methods inherited from class com.prineside.luaj.Varargs
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, dealias, eval, isfunction, isnil, isnoneornil, isnumber, isstring, istable, isTailcall, isthread, isuserdata, isvalue, optboolean, optclosure, optdouble, optfunction, optint, optjstring, optlong, optnumber, optstring, opttable, optthread, optuserdata, optuserdata, optvalue, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, toshort, touserdata, touserdata, type
-
Field Details
-
s_metatable
-
-
Method Details
-
type
public int type()Description copied from class:LuaValue
Get the enumeration value for the type of this value.- Specified by:
type
in classLuaValue
- Returns:
- value for this type, one of
LuaValue.TNIL
,LuaValue.TBOOLEAN
,LuaValue.TNUMBER
,LuaValue.TSTRING
,LuaValue.TTABLE
,LuaValue.TFUNCTION
,LuaValue.TUSERDATA
,LuaValue.TTHREAD
- See Also:
-
toString
Description copied from class:LuaValue
Convert the value to a human readable string usingLuaValue.tojstring()
-
typename
Description copied from class:LuaValue
Get the String name of the type of this value.- Specified by:
typename
in classLuaValue
- Returns:
- name from type name list
LuaValue.TYPE_NAMES
corresponding to the type of this value: "nil", "boolean", "number", "string", "table", "function", "userdata", "thread" - See Also:
-
tojstring
Description copied from class:LuaValue
Convert to human readable String for any type. -
not
Description copied from class:LuaValue
Unary not: return inverse boolean value(~this)
as defined by lua not operator- Overrides:
not
in classLuaValue
- Returns:
LuaValue.TRUE
ifLuaValue.NIL
orLuaValue.FALSE
, otherwiseLuaValue.FALSE
-
toboolean
public boolean toboolean()Description copied from class:LuaValue
Convert to boolean false ifLuaValue.NIL
orLuaValue.FALSE
, true if anything else -
isnil
public boolean isnil()Description copied from class:LuaValue
Check ifthis
is#NIL
-
getmetatable
Description copied from class:LuaValue
Get the metatable for thisLuaValue
For
LuaTable
andLuaUserdata
instances, the metatable returned is this instance metatable. For all other types, the class metatable value will be returned.- Overrides:
getmetatable
in classLuaValue
- Returns:
- metatable, or null if it there is none
-
equals
-
checknotnil
Description copied from class:LuaValue
Check that this is not the valueLuaValue.NIL
, or throwLuaError
if it is- Overrides:
checknotnil
in classLuaValue
- Returns:
this
if it is notLuaValue.NIL
- See Also:
-
isvalidkey
public boolean isvalidkey()Description copied from class:LuaValue
Return true if this is a valid key in a table index operation.- Overrides:
isvalidkey
in classLuaValue
- Returns:
- true if valid as a table key, otherwise false
- See Also:
-
optboolean
public boolean optboolean(boolean defval) Description copied from class:LuaValue
Check that optional argument is a boolean and return its boolean value- Overrides:
optboolean
in classLuaValue
- Parameters:
defval
- boolean value to return ifthis
is nil or none- Returns:
this
cast to boolean if aLuaBoolean
,defval
if nil or none, throwsLuaError
otherwise- See Also:
-
optclosure
Description copied from class:LuaValue
Check that optional argument is a closure and return asLuaClosure
A
LuaClosure
is aLuaFunction
that executes lua byteccode.- Overrides:
optclosure
in classLuaValue
- Parameters:
defval
-LuaClosure
to return ifthis
is nil or none- Returns:
this
cast toLuaClosure
if a function,defval
if nil or none, throwsLuaError
otherwise- See Also:
-
optdouble
public double optdouble(double defval) Description copied from class:LuaValue
Check that optional argument is a number or string convertible to number and return as double -
optfunction
Description copied from class:LuaValue
Check that optional argument is a function and return asLuaFunction
A
LuaFunction
may either be a Java function that implements functionality directly in Java, or aLuaClosure
which is aLuaFunction
that executes lua bytecode.- Overrides:
optfunction
in classLuaValue
- Parameters:
defval
-LuaFunction
to return ifthis
is nil or none- Returns:
this
cast toLuaFunction
if a function,defval
if nil or none, throwsLuaError
otherwise- See Also:
-
optint
public int optint(int defval) Description copied from class:LuaValue
Check that optional argument is a number or string convertible to number and return as int -
optlong
public long optlong(long defval) Description copied from class:LuaValue
Check that optional argument is a number or string convertible to number and return as long -
optnumber
Description copied from class:LuaValue
Check that optional argument is a number or string convertible to number and return asLuaNumber
-
opttable
Description copied from class:LuaValue
Check that optional argument is a table and return asLuaTable
-
optthread
Description copied from class:LuaValue
Check that optional argument is a thread and return asLuaThread
-
optjstring
Description copied from class:LuaValue
Check that optional argument is a string or number and return as Java String- Overrides:
optjstring
in classLuaValue
- Parameters:
defval
-LuaString
to return ifthis
is nil or none- Returns:
this
converted to String if a string or number,defval
if nil or none, throwsLuaError
if some other type- See Also:
-
optstring
Description copied from class:LuaValue
Check that optional argument is a string or number and return asLuaString
-
optuserdata
Description copied from class:LuaValue
Check that optional argument is a userdata and return the Object instance- Overrides:
optuserdata
in classLuaValue
- Parameters:
defval
- Object to return ifthis
is nil or none- Returns:
- Object instance of the userdata if a
LuaUserdata
,defval
if nil or none, throwsLuaError
if some other type - See Also:
-
optuserdata
Description copied from class:LuaValue
Check that optional argument is a userdata whose instance is of a type and return the Object instance- Overrides:
optuserdata
in classLuaValue
- Parameters:
c
- Class to test userdata instance againstdefval
- Object to return ifthis
is nil or none- Returns:
- Object instance of the userdata if a
LuaUserdata
and instance is assignable toc
,defval
if nil or none, throwsLuaError
if some other type - See Also:
-
optvalue
Description copied from class:LuaValue
Perform argument check that this is not nil or none.
-