|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.luaj.vm2.Varargs
org.luaj.vm2.LuaValue
org.luaj.vm2.LuaNil
public class LuaNil
Class to encapsulate behavior of the singleton instance 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.
LuaValue,
LuaValue.NIL| Field Summary | |
|---|---|
static LuaValue |
s_metatable
|
| Fields inherited from class org.luaj.vm2.LuaValue |
|---|
ADD, CALL, CONCAT, DIV, EMPTYSTRING, ENV, EQ, FALSE, INDEX, LE, LEN, LT, METATABLE, MINUSONE, MOD, MODE, MUL, NEWINDEX, NIL, 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 | |
|---|---|
LuaValue |
checknotnil()
Check that this is not the value LuaValue.NIL, or throw LuaError if it is |
boolean |
equals(java.lang.Object o)
|
LuaValue |
getmetatable()
Get the metatable for this LuaValue |
boolean |
isnil()
Check if this is #NIL |
boolean |
isvalidkey()
Return true if this is a valid key in a table index operation. |
LuaValue |
not()
Unary not: return inverse boolean value (~this) as defined by lua not operator |
boolean |
optboolean(boolean defval)
Check that optional argument is a boolean and return its boolean value |
LuaClosure |
optclosure(LuaClosure defval)
Check that optional argument is a closure and return as LuaClosure |
double |
optdouble(double defval)
Check that optional argument is a number or string convertible to number and return as double |
LuaFunction |
optfunction(LuaFunction defval)
Check that optional argument is a function and return as LuaFunction |
int |
optint(int defval)
Check that optional argument is a number or string convertible to number and return as int |
LuaInteger |
optinteger(LuaInteger defval)
Check that optional argument is a number or string convertible to number and return as LuaInteger |
java.lang.String |
optjstring(java.lang.String defval)
Check that optional argument is a string or number and return as Java String |
long |
optlong(long defval)
Check that optional argument is a number or string convertible to number and return as long |
LuaNumber |
optnumber(LuaNumber defval)
Check that optional argument is a number or string convertible to number and return as LuaNumber |
LuaString |
optstring(LuaString defval)
Check that optional argument is a string or number and return as LuaString |
LuaTable |
opttable(LuaTable defval)
Check that optional argument is a table and return as LuaTable |
LuaThread |
optthread(LuaThread defval)
Check that optional argument is a thread and return as LuaThread |
java.lang.Object |
optuserdata(java.lang.Class c,
java.lang.Object defval)
Check that optional argument is a userdata whose instance is of a type and return the Object instance |
java.lang.Object |
optuserdata(java.lang.Object defval)
Check that optional argument is a userdata and return the Object instance |
LuaValue |
optvalue(LuaValue defval)
Perform argument check that this is not nil or none. |
boolean |
toboolean()
Convert to boolean false if LuaValue.NIL or LuaValue.FALSE, true if anything else |
java.lang.String |
tojstring()
Convert to human readable String for any type. |
java.lang.String |
toString()
Convert the value to a human readable string using LuaValue.tojstring() |
int |
type()
Get the enumeration value for the type of this value. |
java.lang.String |
typename()
Get the String name of the type of this value. |
| Methods inherited from class org.luaj.vm2.Varargs |
|---|
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, 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 |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static LuaValue s_metatable
| Method Detail |
|---|
public int type()
LuaValue
type in class LuaValueLuaValue.TNIL,
LuaValue.TBOOLEAN,
LuaValue.TNUMBER,
LuaValue.TSTRING,
LuaValue.TTABLE,
LuaValue.TFUNCTION,
LuaValue.TUSERDATA,
LuaValue.TTHREADLuaValue.typename()public java.lang.String toString()
LuaValueLuaValue.tojstring()
toString in class LuaValueLuaValue.tostring(),
LuaValue.tojstring(),
LuaValue.optstring(LuaString),
LuaValue.checkstring(),
LuaValue.toString()public java.lang.String typename()
LuaValue
typename in class LuaValueLuaValue.TYPE_NAMES
corresponding to the type of this value:
"nil", "boolean", "number", "string",
"table", "function", "userdata", "thread"LuaValue.type()public java.lang.String tojstring()
LuaValue
tojstring in class LuaValueLuaValue.tostring(),
LuaValue.optjstring(String),
LuaValue.checkjstring(),
LuaValue.isstring(),
LuaValue.TSTRINGpublic LuaValue not()
LuaValue(~this) as defined by lua not operator
not in class LuaValueLuaValue.TRUE if LuaValue.NIL or LuaValue.FALSE, otherwise LuaValue.FALSEpublic boolean toboolean()
LuaValueLuaValue.NIL or LuaValue.FALSE, true if anything else
toboolean in class LuaValueLuaValue.optboolean(boolean),
LuaValue.checkboolean(),
LuaValue.isboolean(),
LuaValue.TBOOLEANpublic boolean isnil()
LuaValuethis is #NIL
isnil in class LuaValue#NIL, otherwise falseLuaValue.NIL,
LuaValue.NONE,
LuaValue.checknotnil(),
LuaValue.optvalue(LuaValue),
Varargs.isnoneornil(int),
LuaValue.TNIL,
LuaValue.TNONEpublic LuaValue getmetatable()
LuaValueLuaValue
For LuaTable and LuaUserdata instances,
the metatable returned is this instance metatable.
For all other types, the class metatable value will be returned.
getmetatable in class LuaValueLuaBoolean.s_metatable,
LuaNumber.s_metatable,
s_metatable,
LuaFunction.s_metatable,
LuaThread.s_metatablepublic boolean equals(java.lang.Object o)
equals in class LuaValuepublic LuaValue checknotnil()
LuaValueLuaValue.NIL, or throw LuaError if it is
checknotnil in class LuaValuethis if it is not LuaValue.NILLuaValue.optvalue(LuaValue)public boolean isvalidkey()
LuaValue
isvalidkey in class LuaValueLuaValue.isnil(),
LuaValue.isinttype()public boolean optboolean(boolean defval)
LuaValue
optboolean in class LuaValuedefval - boolean value to return if this is nil or none
this cast to boolean if a LuaBoolean,
defval if nil or none,
throws LuaError otherwiseLuaValue.checkboolean(),
LuaValue.isboolean(),
LuaValue.TBOOLEANpublic LuaClosure optclosure(LuaClosure defval)
LuaValueLuaClosure
A LuaClosure is a LuaFunction that executes lua byteccode.
optclosure in class LuaValuedefval - LuaClosure to return if this is nil or none
this cast to LuaClosure if a function,
defval if nil or none,
throws LuaError otherwiseLuaValue.checkclosure(),
LuaValue.isclosure(),
LuaValue.TFUNCTIONpublic double optdouble(double defval)
LuaValue
optdouble in class LuaValuedefval - double to return if this is nil or none
this cast to double if numeric,
defval if nil or none,
throws LuaError otherwiseLuaValue.optint(int),
LuaValue.optinteger(LuaInteger),
LuaValue.checkdouble(),
LuaValue.todouble(),
LuaValue.tonumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic LuaFunction optfunction(LuaFunction defval)
LuaValueLuaFunction
A LuaFunction may either be a Java function that implements
functionality directly in Java, or a LuaClosure
which is a LuaFunction that executes lua bytecode.
optfunction in class LuaValuedefval - LuaFunction to return if this is nil or none
this cast to LuaFunction if a function,
defval if nil or none,
throws LuaError otherwiseLuaValue.checkfunction(),
LuaValue.isfunction(),
LuaValue.TFUNCTIONpublic int optint(int defval)
LuaValue
optint in class LuaValuedefval - int to return if this is nil or none
this cast to int if numeric,
defval if nil or none,
throws LuaError otherwiseLuaValue.optdouble(double),
LuaValue.optlong(long),
LuaValue.optinteger(LuaInteger),
LuaValue.checkint(),
LuaValue.toint(),
LuaValue.tonumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic LuaInteger optinteger(LuaInteger defval)
LuaValueLuaInteger
optinteger in class LuaValuedefval - LuaInteger to return if this is nil or none
this converted and wrapped in LuaInteger if numeric,
defval if nil or none,
throws LuaError otherwiseLuaValue.optdouble(double),
LuaValue.optint(int),
LuaValue.checkint(),
LuaValue.toint(),
LuaValue.tonumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic long optlong(long defval)
LuaValue
optlong in class LuaValuedefval - long to return if this is nil or none
this cast to long if numeric,
defval if nil or none,
throws LuaError otherwiseLuaValue.optdouble(double),
LuaValue.optint(int),
LuaValue.checkint(),
LuaValue.toint(),
LuaValue.tonumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic LuaNumber optnumber(LuaNumber defval)
LuaValueLuaNumber
optnumber in class LuaValuedefval - LuaNumber to return if this is nil or none
this cast to LuaNumber if numeric,
defval if nil or none,
throws LuaError otherwiseLuaValue.optdouble(double),
LuaValue.optlong(long),
LuaValue.optint(int),
LuaValue.checkint(),
LuaValue.toint(),
LuaValue.tonumber(),
LuaValue.isnumber(),
LuaValue.TNUMBERpublic LuaTable opttable(LuaTable defval)
LuaValueLuaTable
opttable in class LuaValuedefval - LuaTable to return if this is nil or none
this cast to LuaTable if a table,
defval if nil or none,
throws LuaError if some other typeLuaValue.checktable(),
LuaValue.istable(),
LuaValue.TTABLEpublic LuaThread optthread(LuaThread defval)
LuaValueLuaThread
optthread in class LuaValuedefval - LuaThread to return if this is nil or none
this cast to LuaTable if a thread,
defval if nil or none,
throws LuaError if some other typeLuaValue.checkthread(),
LuaValue.isthread(),
LuaValue.TTHREADpublic java.lang.String optjstring(java.lang.String defval)
LuaValue
optjstring in class LuaValuedefval - LuaString to return if this is nil or none
this converted to String if a string or number,
defval if nil or none,
throws LuaError if some other typeLuaValue.tojstring(),
LuaValue.optstring(LuaString),
LuaValue.checkjstring(),
LuaValue.toString(),
LuaValue.TSTRINGpublic LuaString optstring(LuaString defval)
LuaValueLuaString
optstring in class LuaValuedefval - LuaString to return if this is nil or none
this converted to LuaString if a string or number,
defval if nil or none,
throws LuaError if some other typeLuaValue.tojstring(),
LuaValue.optjstring(String),
LuaValue.checkstring(),
LuaValue.toString(),
LuaValue.TSTRINGpublic java.lang.Object optuserdata(java.lang.Object defval)
LuaValue
optuserdata in class LuaValuedefval - Object to return if this is nil or none
LuaUserdata,
defval if nil or none,
throws LuaError if some other typeLuaValue.checkuserdata(),
LuaValue.isuserdata(),
LuaValue.optuserdata(Class, Object),
LuaValue.TUSERDATA
public java.lang.Object optuserdata(java.lang.Class c,
java.lang.Object defval)
LuaValue
optuserdata in class LuaValuec - Class to test userdata instance againstdefval - Object to return if this is nil or none
LuaUserdata and instance is assignable to c,
defval if nil or none,
throws LuaError if some other typeLuaValue.checkuserdata(Class),
LuaValue.isuserdata(Class),
LuaValue.optuserdata(Object),
LuaValue.TUSERDATApublic LuaValue optvalue(LuaValue defval)
LuaValue
optvalue in class LuaValuedefval - LuaValue to return if this is nil or none
this if not nil or none, else defvalLuaValue.NIL,
LuaValue.NONE,
LuaValue.isnil(),
Varargs.isnoneornil(int),
LuaValue.TNIL,
LuaValue.TNONE
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||