org.luaj.vm2.lib.jse
Class CoerceJavaToLua

java.lang.Object
  extended by org.luaj.vm2.lib.jse.CoerceJavaToLua

public class CoerceJavaToLua
extends java.lang.Object

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:

To coerce arrays of objects and lists, the listOf(..) and tableOf(...) methods on LuaValue may be used:

The method 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:
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

CoerceJavaToLua

public CoerceJavaToLua()
Method Detail

coerce

public static LuaValue coerce(java.lang.Object o)
Coerse a Java object to a corresponding lua value.

Integral types boolean, byte, char, and int will become LuaInteger; long, float, and double will become LuaDouble; String and byte[] will become LuaString; types inheriting from LuaValue will be returned without coercion; other types will become LuaUserdata.

Parameters:
o - Java object needing conversion
Returns:
LuaValue corresponding to the supplied Java value.
See Also:
LuaValue, LuaInteger, LuaDouble, LuaString, LuaUserdata


Copyright © 2007-2015 Luaj.org. All Rights Reserved.