public enum LuaType extends Enum<LuaType>
There are eight types in Lua (nil
, boolean
, number
, string
,
function
, userdata
, thread
and table
). In Rembulan,
all Java object references are mapped to a Lua type according to the following list:
NIL
... no explicit nil
type; any (Java) null
value is
considered nilBOOLEAN
... instances of java.lang.Boolean
NUMBER
... instances of java.lang.Number
:
java.lang.Double
(canonical)
or java.lang.Float
java.lang.Number
,
with java.lang.Long
being the canonical
representationSTRING
... instances of java.lang.String
FUNCTION
... LuaFunction
USERDATA
:
Userdata
THREAD
... Coroutine
TABLE
... Table
For numeric values, the canonical representation is the default, full-precision
representation of the number as either a float or integer. To convert a number to its
canonical value, use Conversions.toCanonicalNumber(Number)
.
To retrieve the name of the type of a Lua value, use the ValueTypeNamer
interface (for names based on the type only, without taking into account the __name
metamethod, use PlainValueTypeNamer
).
Enum Constant and Description |
---|
BOOLEAN
The Lua
boolean type, corresponding to instances
of java.lang.Boolean . |
FUNCTION
The Lua
function type, corresponding to instances of LuaFunction . |
NIL
The Lua
nil type, corresponding to null references. |
NUMBER
The Lua
number type, corresponding to instances of java.lang.Number . |
STRING
|
TABLE
The Lua
table type, corresponding to instances of Table . |
THREAD
The Lua
thread type, corresponding to instances of the Coroutine class. |
USERDATA
|
Modifier and Type | Method and Description |
---|---|
static boolean |
isBoolean(Object o)
Returns
true iff o is a Lua boolean. |
static boolean |
isFloat(Object o)
Returns
true iff o is a Lua float. |
static boolean |
isFullUserdata(Object o)
Returns
true iff o is full userdata. |
static boolean |
isFunction(Object o)
Returns
true iff o is a Lua function. |
static boolean |
isInteger(Object o)
Returns
true iff o is a Lua integer. |
static boolean |
isLightUserdata(Object o)
Returns
true iff the object o is light userdata. |
static boolean |
isNil(Object o)
Returns
true iff o is nil. |
static boolean |
isNumber(Object o)
Returns
true iff o is a Lua number. |
static boolean |
isString(Object o)
Returns
true iff o is a Lua string. |
static boolean |
isTable(Object o)
Returns
true iff the object o is a Lua table. |
static boolean |
isThread(Object o)
Returns
true iff the object o is a Lua thread. |
static boolean |
isUserdata(Object o)
Returns
true iff o is a Lua userdata. |
static LuaType |
typeOf(Object o)
Returns the Lua type of the object
o . |
static LuaType |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static LuaType[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final LuaType NIL
nil
type, corresponding to null
references.public static final LuaType BOOLEAN
boolean
type, corresponding to instances
of java.lang.Boolean
.public static final LuaType NUMBER
number
type, corresponding to instances of java.lang.Number
.
Instances of java.lang.Double
and java.lang.Float
are mapped to Lua floats (Double
s being the canonical representation). All other
subclasses of Number
are mapped to Lua integers, with java.lang.Long
being the canonical representation.
public static final LuaType STRING
public static final LuaType FUNCTION
function
type, corresponding to instances of LuaFunction
.public static final LuaType USERDATA
public static final LuaType THREAD
thread
type, corresponding to instances of the Coroutine
class.public static LuaType[] values()
for (LuaType c : LuaType.values()) System.out.println(c);
public static LuaType valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static LuaType typeOf(Object o)
o
.o
- the object to determine the type of, may be null
o
public static boolean isNil(Object o)
true
iff o
is nil.
o
is nil if and only if o
is null
.
o
- the object to test for being nil, may be null
true
iff o
is nilpublic static boolean isBoolean(Object o)
true
iff o
is a Lua boolean.
o
is a Lua boolean if and only if o
is an instance of
java.lang.Boolean
.
o
- the object to test for being a boolean, may be null
true
iff o
is a Lua booleanpublic static boolean isNumber(Object o)
true
iff o
is a Lua number.
o
is a Lua number if and only if o
is an instance of
java.lang.Number
.
o
- the object to test for being a number, may be null
true
iff o
is a Lua numberpublic static boolean isFloat(Object o)
true
iff o
is a Lua float.
o
is a Lua float if and only if o
is an instance of
java.lang.Double
or java.lang.Float
.
o
- the object to test for being a float, may be null
true
iff o
is a Lua floatpublic static boolean isInteger(Object o)
true
iff o
is a Lua integer.
o
is a Lua number if and only if o
is a Lua number and is not
a Lua float.
o
- the object to test for being an integer, may be null
true
iff o
is a Lua integerpublic static boolean isString(Object o)
true
iff o
is a Lua string.
o
is a Lua string if and only if o
is an instance of
ByteString
or java.lang.String
.
o
- the object to test for being a string, may be null
true
iff o
is a Lua stringpublic static boolean isFunction(Object o)
true
iff o
is a Lua function.
o
is a Lua function if and only if o
is an instance of
LuaFunction
.
o
- the object to test for being a function, may be null
true
iff o
is a Lua functionpublic static boolean isUserdata(Object o)
true
iff o
is a Lua userdata.
o
is a Lua userdata if it is not nil
, boolean
, number
,
string
, function
, thread
or table
.
o
- the object to test for being a userdata, may be null
true
iff o
is a Lua userdatapublic static boolean isFullUserdata(Object o)
true
iff o
is full userdata.
o
is full userdata if and only if o
is an instance of
Userdata
.
o
- the object to test for being full userdata, may be null
true
iff o
is full userdatapublic static boolean isLightUserdata(Object o)
true
iff the object o
is light userdata.
An object is light userdata when its Lua type is USERDATA
and it
is not an instance of the Userdata
class. In other words, it is not an
instance of any class mapped to a Lua type.
o
- the object to test for being light userdata, may be null
true
iff o
is light userdatapublic static boolean isThread(Object o)
true
iff the object o
is a Lua thread.
o
is a Lua thread if and only if o
is an instance of Coroutine
.
o
- the object to test for being a Lua thread, may be null
true
iff o
is a Lua threadCopyright © 2016. All rights reserved.