com.sri.oaa2.mapper
Class OAAMapper

java.lang.Object
  |
  +--com.sri.oaa2.mapper.OAAMapper
All Implemented Interfaces:
java.util.EventListener, OAAEventListener

public class OAAMapper
extends java.lang.Object
implements OAAEventListener

OAAMapper maps OAA solvable calls to Java function calls, and maps the results back. It takes an XML OAAMapper mapping file and a set of Java objects that the solvables are executed over. It then can act as an OAAEventListener and respond to OAA solvables directly, or it can be passed pieces of ICL to act upon.

Function calls made through the callFunction() or doOAAEvent() methods are not synchronized, so Java objects to which these calls are mapped must be thread-safe.


Constructor Summary
OAAMapper(IclMapping iclMapping)
           
OAAMapper(java.io.InputStream mappingFile)
           
OAAMapper(java.io.Reader mappingFile)
           
 
Method Summary
 void addSolvableObject(java.lang.Object o)
          Adds an object upon which callFunction() and doOAAEvent function calls are invoked.
 java.lang.Object callFunction(IclTerm goal)
          Calls the function indicated by the solvable.
 java.lang.Object createOAAProxy(java.lang.Class[] proxyInterfaces, LibOaa oaaFacilitator)
          Creates a proxy object that implements the specified interfaces, translates calls on those interfaces into OAA solvable calls, and translates the results into Java objects.
 IclTerm createSolvable(java.lang.Class functionClass, java.lang.reflect.Method functionSignature, java.lang.Object[] parameters)
           
 boolean doOAAEvent(IclTerm goal, IclList params, IclList answers)
          Maps an OAA solvable to a function call, and parses and returns the result.
 IclMapping getIclMapping()
           
 java.util.List getSolvableObjects()
           
 java.lang.Object iclToJava(java.lang.Class type, IclTerm icl)
          Maps ICL to a Java object of the specified type as indicated by the mapping file.
 IclTerm javaToIcl(java.lang.Object value)
          Maps a Java object to ICL as indicated by the mapping file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OAAMapper

public OAAMapper(IclMapping iclMapping)
Parameters:
iclMapping -

OAAMapper

public OAAMapper(java.io.InputStream mappingFile)
          throws MappingException
Parameters:
mappingFile -
Throws:
MappingException

OAAMapper

public OAAMapper(java.io.Reader mappingFile)
          throws MappingException
Parameters:
mappingFile -
Throws:
MappingException
Method Detail

addSolvableObject

public void addSolvableObject(java.lang.Object o)
Adds an object upon which callFunction() and doOAAEvent function calls are invoked.

Parameters:
o -

createOAAProxy

public java.lang.Object createOAAProxy(java.lang.Class[] proxyInterfaces,
                                       LibOaa oaaFacilitator)
Creates a proxy object that implements the specified interfaces, translates calls on those interfaces into OAA solvable calls, and translates the results into Java objects. The returned object can be cast to any of the specified interfaces, and functions on thos interfaces are callable if the functions have a mapping in the XML OAAMapper file and if the specified LibOaa object is connected to an OAA facilitator.

Parameters:
proxyInterfaces -
oaaFacilitator -
Returns:

doOAAEvent

public boolean doOAAEvent(IclTerm goal,
                          IclList params,
                          IclList answers)
Maps an OAA solvable to a function call, and parses and returns the result.

Specified by:
doOAAEvent in interface OAAEventListener
Parameters:
goal - ???
params - ???
answers - ???

callFunction

public java.lang.Object callFunction(IclTerm goal)
                              throws MappingException
Calls the function indicated by the solvable.

Parameters:
goal -
Returns:
Throws:
MappingException

createSolvable

public IclTerm createSolvable(java.lang.Class functionClass,
                              java.lang.reflect.Method functionSignature,
                              java.lang.Object[] parameters)
                       throws MappingException
MappingException

javaToIcl

public IclTerm javaToIcl(java.lang.Object value)
                  throws MappingException
Maps a Java object to ICL as indicated by the mapping file.

Parameters:
value -
Returns:
Throws:
MappingException

iclToJava

public java.lang.Object iclToJava(java.lang.Class type,
                                  IclTerm icl)
                           throws MappingException
Maps ICL to a Java object of the specified type as indicated by the mapping file.

Parameters:
type -
icl -
Returns:
Throws:
MappingException

getIclMapping

public IclMapping getIclMapping()

getSolvableObjects

public java.util.List getSolvableObjects()