org.keplerproject.luajava
Class LuaObject

java.lang.Object
  extended by org.keplerproject.luajava.LuaObject

public class LuaObject
extends java.lang.Object

This class represents a Lua object of any type. A LuaObject is constructed by a LuaState object using one of the four methods:

The LuaObject will represent only the object itself, not a variable or a stack index, so when you change a string, remember that strings are immutable objects in Lua, and the LuaObject you have will represent the old one.

Proxies

LuaJava allows you to implement a class in Lua, like said before. If you want to create this proxy from Java, you should have a LuaObject representing the table that has the functions that implement the interface. From this LuaObject you can call the createProxy(String implements). This method receives the string with the name of the interfaces implemented by the object separated by comma.


Method Summary
 java.lang.Object call(java.lang.Object[] args)
          Calls the object represented by this using Lua function pcall.
 java.lang.Object[] call(java.lang.Object[] args, int nres)
          Calls the object represented by this using Lua function pcall.
 java.lang.Object createProxy(java.lang.String implem)
          Function that creates a java proxy to the object represented by this
 boolean getBoolean()
           
 LuaObject getField(java.lang.String field)
          If this is a table or userdata tries to set a field value.
 LuaState getLuaState()
          Gets the Object's State
 double getNumber()
           
 java.lang.Object getObject()
           
 java.lang.String getString()
           
 boolean isBoolean()
           
 boolean isFunction()
           
 boolean isJavaFunction()
           
 boolean isJavaObject()
           
 boolean isNil()
           
 boolean isNumber()
           
 boolean isString()
           
 boolean isTable()
           
 boolean isUserdata()
           
 void push()
          Pushes the object represented by this into L's stack
 java.lang.String toString()
           
 int type()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getLuaState

public LuaState getLuaState()
Gets the Object's State


push

public void push()
Pushes the object represented by this into L's stack


isNil

public boolean isNil()

isBoolean

public boolean isBoolean()

isNumber

public boolean isNumber()

isString

public boolean isString()

isFunction

public boolean isFunction()

isJavaObject

public boolean isJavaObject()

isJavaFunction

public boolean isJavaFunction()

isTable

public boolean isTable()

isUserdata

public boolean isUserdata()

type

public int type()

getBoolean

public boolean getBoolean()

getNumber

public double getNumber()

getString

public java.lang.String getString()

getObject

public java.lang.Object getObject()
                           throws LuaException
Throws:
LuaException

getField

public LuaObject getField(java.lang.String field)
                   throws LuaException
If this is a table or userdata tries to set a field value.

Throws:
LuaException

call

public java.lang.Object[] call(java.lang.Object[] args,
                               int nres)
                        throws LuaException
Calls the object represented by this using Lua function pcall.

Parameters:
args - - Call arguments
nres - - Number of objects returned
Returns:
Object[] - Returned Objects
Throws:
LuaException

call

public java.lang.Object call(java.lang.Object[] args)
                      throws LuaException
Calls the object represented by this using Lua function pcall. Returns 1 object

Parameters:
args - - Call arguments
Returns:
Object - Returned Object
Throws:
LuaException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

createProxy

public java.lang.Object createProxy(java.lang.String implem)
                             throws java.lang.ClassNotFoundException,
                                    LuaException
Function that creates a java proxy to the object represented by this

Parameters:
implem - Interfaces that are implemented, separated by ,
Throws:
java.lang.ClassNotFoundException
LuaException