Class CoerceJavaToLua

java.lang.Object
com.prineside.luaj.lib.jse.CoerceJavaToLua

public class CoerceJavaToLua extends Object
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:

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:
  • Field Details

  • Constructor Details

    • CoerceJavaToLua

      public CoerceJavaToLua()
  • Method Details

    • coerce

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

      Integral types boolean, byte, char, and int will become ; long, float, and double will become ; 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: