|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.luaj.vm2.lib.jse.CoerceJavaToLua
public class CoerceJavaToLua
Helper class to coerce values from Java to lua within the luajava library.
This class is primarily used by the LuajavaLib
,
but can also be used directly when working with Java/lua bindings.
To coerce scalar types, the various, generally the valueOf(type)
methods
on LuaValue
may be used:
LuaValue.valueOf(boolean)
LuaValue.valueOf(byte[])
LuaValue.valueOf(double)
LuaValue.valueOf(int)
LuaValue.valueOf(String)
To coerce arrays of objects and lists, the listOf(..)
and tableOf(...)
methods
on LuaValue
may be used:
LuaValue.listOf(LuaValue[])
LuaValue.listOf(LuaValue[], org.luaj.vm2.Varargs)
LuaValue.tableOf(LuaValue[])
LuaValue.tableOf(LuaValue[], LuaValue[], org.luaj.vm2.Varargs)
coerce(Object)
looks as the type and dimesioning
of the argument and tries to guess the best fit for corrsponding lua scalar,
table, or table of tables.
coerce(Object)
,
LuajavaLib
Constructor Summary | |
---|---|
CoerceJavaToLua()
|
Method Summary | |
---|---|
static LuaValue |
coerce(java.lang.Object o)
Coerse a Java object to a corresponding lua value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CoerceJavaToLua()
Method Detail |
---|
public static LuaValue coerce(java.lang.Object o)
Integral types boolean
, byte
, char
, and int
will become LuaInteger
;
long
, float
, and double
will become LuaDouble
;
String
and byte[]
will become LuaString
;
other types will become LuaUserdata
.
o
- Java object needing conversion
LuaValue
corresponding to the supplied Java value.LuaValue
,
LuaInteger
,
LuaDouble
,
LuaString
,
LuaUserdata
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |