|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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, 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 NIL , or throw LuaError if it is |
LuaValue |
checkvalidkey()
Check that this is a valid key in a table index operation, or throw LuaError if not |
boolean |
equals(java.lang.Object o)
|
LuaValue |
getmetatable()
Get the metatable for this LuaValue |
boolean |
isnil()
Check if this is nil |
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 FALSE , true if anything else |
java.lang.String |
tojstring()
Convert to human readable String for any type. |
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, subargs, 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 LuaValue
TNIL
,
TBOOLEAN
,
TNUMBER
,
TSTRING
,
TTABLE
,
TFUNCTION
,
TUSERDATA
,
TTHREAD
LuaValue.typename()
public java.lang.String typename()
LuaValue
typename
in class LuaValue
LuaValue.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 LuaValue
LuaValue.tostring()
,
LuaValue.optjstring(String)
,
LuaValue.checkjstring()
,
LuaValue.isstring()
,
TSTRING
public LuaValue not()
LuaValue
(~this)
as defined by lua not operator
not
in class LuaValue
TRUE
if NIL
or FALSE
, otherwise FALSE
public boolean toboolean()
LuaValue
LuaValue.NIL
or FALSE
, true if anything else
toboolean
in class LuaValue
LuaValue.optboolean(boolean)
,
LuaValue.checkboolean()
,
LuaValue.isboolean()
,
TBOOLEAN
public boolean isnil()
LuaValue
this
is nil
isnil
in class LuaValue
nil
, otherwise falseLuaValue.NIL
,
LuaValue.NONE
,
LuaValue.checknotnil()
,
LuaValue.optvalue(LuaValue)
,
Varargs.isnoneornil(int)
,
LuaValue.TNIL
,
LuaValue.TNONE
public LuaValue getmetatable()
LuaValue
LuaValue
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 LuaValue
LuaBoolean.s_metatable
,
LuaNumber.s_metatable
,
s_metatable
,
LuaFunction.s_metatable
,
LuaThread.s_metatable
public boolean equals(java.lang.Object o)
equals
in class LuaValue
public LuaValue checknotnil()
LuaValue
NIL
, or throw LuaError
if it is
checknotnil
in class LuaValue
this
if it is not NIL
LuaValue.optvalue(LuaValue)
public LuaValue checkvalidkey()
LuaValue
LuaError
if not
checkvalidkey
in class LuaValue
this
if valid as a table keyLuaValue.isnil()
,
LuaValue.isinttype()
public boolean optboolean(boolean defval)
LuaValue
optboolean
in class LuaValue
defval
- boolean value to return if this
is nil or none
this
cast to boolean if a ,
defval
if nil or none,
throws LuaError
otherwiseLuaValue.checkboolean()
,
LuaValue.isboolean()
,
LuaValue.TBOOLEAN
public LuaClosure optclosure(LuaClosure defval)
LuaValue
LuaClosure
A LuaClosure
is a that executes lua byteccode.
optclosure
in class LuaValue
defval
- 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.TFUNCTION
public double optdouble(double defval)
LuaValue
optdouble
in class LuaValue
defval
- 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.TNUMBER
public LuaFunction optfunction(LuaFunction defval)
LuaValue
LuaFunction
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 LuaValue
defval
- 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.TFUNCTION
public int optint(int defval)
LuaValue
optint
in class LuaValue
defval
- 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.TNUMBER
public LuaInteger optinteger(LuaInteger defval)
LuaValue
LuaInteger
optinteger
in class LuaValue
defval
- 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.TNUMBER
public long optlong(long defval)
LuaValue
optlong
in class LuaValue
defval
- 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.TNUMBER
public LuaNumber optnumber(LuaNumber defval)
LuaValue
LuaNumber
optnumber
in class LuaValue
defval
- 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.TNUMBER
public LuaTable opttable(LuaTable defval)
LuaValue
LuaTable
opttable
in class LuaValue
defval
- 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.TTABLE
public LuaThread optthread(LuaThread defval)
LuaValue
LuaThread
optthread
in class LuaValue
defval
- 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.TTHREAD
public java.lang.String optjstring(java.lang.String defval)
LuaValue
optjstring
in class LuaValue
defval
- 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.TSTRING
public LuaString optstring(LuaString defval)
LuaValue
LuaString
optstring
in class LuaValue
defval
- 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.TSTRING
public java.lang.Object optuserdata(java.lang.Object defval)
LuaValue
optuserdata
in class LuaValue
defval
- 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 LuaValue
c
- 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.TUSERDATA
public LuaValue optvalue(LuaValue defval)
LuaValue
optvalue
in class LuaValue
defval
- LuaValue
to return if this
is nil or none
this
if not nil or none, else defval
LuaValue.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 |