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 -
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 throwLuaErrorif it isbooleanGet the metatable for thisLuaValuebooleanisnil()Check ifthisis#NILbooleanReturn 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 operatorbooleanoptboolean(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 asLuaClosuredoubleoptdouble(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 asLuaFunctionintoptint(int defval) Check that optional argument is a number or string convertible to number and return as intoptinteger(LuaInteger defval) Check that optional argument is a number or string convertible to number and return asLuaIntegeroptjstring(String defval) Check that optional argument is a string or number and return as Java Stringlongoptlong(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 asLuaNumberCheck that optional argument is a string or number and return asLuaStringCheck that optional argument is a table and return asLuaTableCheck that optional argument is a thread and return asLuaThreadoptuserdata(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.booleanConvert to boolean false ifLuaValue.NILorLuaValue.FALSE, true if anything elseConvert to human readable String for any type.toString()Convert the value to a human readable string usingLuaValue.tojstring()inttype()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, cachedDouble, cachedInt, cachedVarargsOf, cachedVarargsOf, cachedVarargsOf, cachedVarargsOf, cachedVarargsOf, cachedVarargsOf, call, call, call, call, call, checkboolean, checkclosure, checkdouble, checkfunction, checkglobals, checkint, checkinteger, checkjstring, checklong, checknumber, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, comparemt, concat, concat, concatmt, concatTo, concatTo, concatTo, 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, invoke, invoke, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, isboolean, isclosure, isfunction, isint, isinttype, islong, isnumber, 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, 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, varargsOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOfMethods inherited from class com.prineside.luaj.Varargs
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, 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, optinteger, 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:LuaValueGet the enumeration value for the type of this value.- Specified by:
typein 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:LuaValueConvert the value to a human readable string usingLuaValue.tojstring() -
typename
Description copied from class:LuaValueGet the String name of the type of this value.- Specified by:
typenamein classLuaValue- Returns:
- name from type name list
LuaValue.TYPE_NAMEScorresponding to the type of this value: "nil", "boolean", "number", "string", "table", "function", "userdata", "thread" - See Also:
-
tojstring
Description copied from class:LuaValueConvert to human readable String for any type. -
not
Description copied from class:LuaValueUnary not: return inverse boolean value(~this)as defined by lua not operator- Overrides:
notin classLuaValue- Returns:
LuaValue.TRUEifLuaValue.NILorLuaValue.FALSE, otherwiseLuaValue.FALSE
-
toboolean
public boolean toboolean()Description copied from class:LuaValueConvert to boolean false ifLuaValue.NILorLuaValue.FALSE, true if anything else -
isnil
public boolean isnil()Description copied from class:LuaValueCheck ifthisis#NIL -
getmetatable
Description copied from class:LuaValueGet the metatable for thisLuaValueFor
LuaTableandLuaUserdatainstances, the metatable returned is this instance metatable. For all other types, the class metatable value will be returned.- Overrides:
getmetatablein classLuaValue- Returns:
- metatable, or null if it there is none
- See Also:
-
equals
-
checknotnil
Description copied from class:LuaValueCheck that this is not the valueLuaValue.NIL, or throwLuaErrorif it is- Overrides:
checknotnilin classLuaValue- Returns:
thisif it is notLuaValue.NIL- See Also:
-
isvalidkey
public boolean isvalidkey()Description copied from class:LuaValueReturn true if this is a valid key in a table index operation.- Overrides:
isvalidkeyin classLuaValue- Returns:
- true if valid as a table key, otherwise false
- See Also:
-
optboolean
public boolean optboolean(boolean defval) Description copied from class:LuaValueCheck that optional argument is a boolean and return its boolean value- Overrides:
optbooleanin classLuaValue- Parameters:
defval- boolean value to return ifthisis nil or none- Returns:
thiscast to boolean if aLuaBoolean,defvalif nil or none, throwsLuaErrorotherwise- See Also:
-
optclosure
Description copied from class:LuaValueCheck that optional argument is a closure and return asLuaClosureA
LuaClosureis aLuaFunctionthat executes lua byteccode.- Overrides:
optclosurein classLuaValue- Parameters:
defval-LuaClosureto return ifthisis nil or none- Returns:
thiscast toLuaClosureif a function,defvalif nil or none, throwsLuaErrorotherwise- See Also:
-
optdouble
public double optdouble(double defval) Description copied from class:LuaValueCheck that optional argument is a number or string convertible to number and return as double -
optfunction
Description copied from class:LuaValueCheck that optional argument is a function and return asLuaFunctionA
LuaFunctionmay either be a Java function that implements functionality directly in Java, or aLuaClosurewhich is aLuaFunctionthat executes lua bytecode.- Overrides:
optfunctionin classLuaValue- Parameters:
defval-LuaFunctionto return ifthisis nil or none- Returns:
thiscast toLuaFunctionif a function,defvalif nil or none, throwsLuaErrorotherwise- See Also:
-
optint
public int optint(int defval) Description copied from class:LuaValueCheck that optional argument is a number or string convertible to number and return as int -
optinteger
Description copied from class:LuaValueCheck that optional argument is a number or string convertible to number and return asLuaInteger- Overrides:
optintegerin classLuaValue- Parameters:
defval-LuaIntegerto return ifthisis nil or none- Returns:
thisconverted and wrapped inLuaIntegerif numeric,defvalif nil or none, throwsLuaErrorotherwise- See Also:
-
optlong
public long optlong(long defval) Description copied from class:LuaValueCheck that optional argument is a number or string convertible to number and return as long -
optnumber
Description copied from class:LuaValueCheck that optional argument is a number or string convertible to number and return asLuaNumber -
opttable
Description copied from class:LuaValueCheck that optional argument is a table and return asLuaTable -
optthread
Description copied from class:LuaValueCheck that optional argument is a thread and return asLuaThread -
optjstring
Description copied from class:LuaValueCheck that optional argument is a string or number and return as Java String- Overrides:
optjstringin classLuaValue- Parameters:
defval-LuaStringto return ifthisis nil or none- Returns:
thisconverted to String if a string or number,defvalif nil or none, throwsLuaErrorif some other type- See Also:
-
optstring
Description copied from class:LuaValueCheck that optional argument is a string or number and return asLuaString -
optuserdata
Description copied from class:LuaValueCheck that optional argument is a userdata and return the Object instance- Overrides:
optuserdatain classLuaValue- Parameters:
defval- Object to return ifthisis nil or none- Returns:
- Object instance of the userdata if a
LuaUserdata,defvalif nil or none, throwsLuaErrorif some other type - See Also:
-
optuserdata
Description copied from class:LuaValueCheck that optional argument is a userdata whose instance is of a type and return the Object instance- Overrides:
optuserdatain classLuaValue- Parameters:
c- Class to test userdata instance againstdefval- Object to return ifthisis nil or none- Returns:
- Object instance of the userdata if a
LuaUserdataand instance is assignable toc,defvalif nil or none, throwsLuaErrorif some other type - See Also:
-
optvalue
Description copied from class:LuaValuePerform argument check that this is not nil or none.
-