Package com.prineside.luaj.lib.jse
Class CoerceJavaToLua
java.lang.Object
com.prineside.luaj.lib.jse.CoerceJavaToLua
Helper class to coerce values from Java to lua within the luajava library.
This class is primarily used by the org.luaj.vm2.lib.jse.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:
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.- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
CoerceJavaToLua
public CoerceJavaToLua()
-
-
Method Details
-
coerce
Coerse a Java object to a corresponding lua value.Integral types
boolean,byte,char, andintwill becomeLuaInteger;long,float, anddoublewill becomeLuaDouble;Stringandbyte[]will becomeLuaString; types inheriting fromLuaValuewill be returned without coercion; other types will becomeLuaUserdata.- Parameters:
o- Java object needing conversion- Returns:
LuaValuecorresponding to the supplied Java value.- See Also:
-