context.arch.interpreter
Class Interpreter

java.lang.Object
  |
  +--context.arch.BaseObject
        |
        +--context.arch.interpreter.Interpreter
Direct Known Subclasses:
IDemoRecommender, IGroup2URL, IIButton2Group, IIButton2GroupURL, IIButton2Name, IIButton2NameExt

public abstract class Interpreter
extends BaseObject

This class is the basic interpreter.

See Also:
BaseObject

Field Summary
static int DEFAULT_PORT
          Default port to use for interpreters
protected  Attributes inAttributes
           
protected  java.util.Hashtable inAttributeTypes
           
static java.lang.String INTERPRET
          Tag for interpreter
static java.lang.String INTERPRET_REPLY
          Tag for interpreterReply
protected  Attributes outAttributes
           
protected  java.util.Hashtable outAttributeTypes
           
 
Fields inherited from class context.arch.BaseObject
communications, EXIT_OK, handlers, ID, parser, PING, PING_REPLY, serviceHandlers
 
Constructor Summary
Interpreter(int port)
          Constructor that creates a BaseObject with the given port and sets the incoming and outgoing attributes.
 
Method Summary
protected  java.lang.String getInAttributeType(java.lang.String name)
          Returns the attribute type with the given name for incoming attributes
protected  java.lang.String getOutAttributeType(java.lang.String name)
          Returns the attribute type with the given name for outgoing attributes
protected abstract  AttributeNameValues interpretData(AttributeNameValues data)
          This abstract method interprets the given data and returns it.
protected  boolean isInAttribute(java.lang.String name)
          Checks if the given incoming attribute is an attribute of this interpreter
protected  boolean isOutAttribute(java.lang.String name)
          Checks if the given outgoing attribute is an attribute of this interpreter
protected  DataObject runInterpreterMethod(DataObject data, java.lang.String error)
          This is an empty method that should be overridden by objects that subclass from this class.
 DataObject runUserMethod(DataObject data)
          This method is meant to handle any internal methods that the baseObject doesn't handle.
protected  void setInAttribute(java.lang.String name, java.lang.String type)
          Adds an incoming attribute
protected abstract  Attributes setInAttributes()
          Sets the incoming attributes for the interpreter
protected  void setOutAttribute(java.lang.String name, java.lang.String type)
          Adds an outgoing attribute
protected abstract  Attributes setOutAttributes()
          Sets the outgoing attributes for the interpreter
 
Methods inherited from class context.arch.BaseObject
askInterpreter, decodeData, encodeData, executeAsynchronousWidgetService, executeSynchronousWidgetService, getHostAddress, getId, getVersion, getVersion, getWidgetAttributes, getWidgetCallbacks, getWidgetServices, main, pingComponent, pollWidget, putDataInWidget, queryVersion, quit, retrieveDataFrom, retrieveDataFrom, retrieveDataFrom, retrieveDataFrom, retrieveDataFrom, retrieveDataFrom, retrieveDataFrom, returnPing, runComponentMethod, runMethod, serviceResult, setId, setVersion, subscribeTo, subscribeTo, subscribeTo, subscribeTo, unsubscribeFrom, updateAndPollWidget, userCallback, userRequest, userRequest, userRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTERPRET

public static final java.lang.String INTERPRET
Tag for interpreter

INTERPRET_REPLY

public static final java.lang.String INTERPRET_REPLY
Tag for interpreterReply

DEFAULT_PORT

public static final int DEFAULT_PORT
Default port to use for interpreters

inAttributes

protected Attributes inAttributes

outAttributes

protected Attributes outAttributes

inAttributeTypes

protected java.util.Hashtable inAttributeTypes

outAttributeTypes

protected java.util.Hashtable outAttributeTypes
Constructor Detail

Interpreter

public Interpreter(int port)
Constructor that creates a BaseObject with the given port and sets the incoming and outgoing attributes.
Parameters:
port - Port number to create the BaseObject on
See Also:
BaseObject
Method Detail

runUserMethod

public DataObject runUserMethod(DataObject data)
This method is meant to handle any internal methods that the baseObject doesn't handle. In particular, this method handles interpret requests. It ensures that the ID of the incoming request matches this interpreter. If the method is an INTERPRET method, it sends it to the interpreter. Otherwise runInterpreterMethod() is called.
Overrides:
runUserMethod in class BaseObject
Parameters:
data - DataObject containing the method to run and parameters
Returns:
DataObject containing the results of running the method
See Also:
runInterpreterMethod(DataObject,String)

interpretData

protected abstract AttributeNameValues interpretData(AttributeNameValues data)
This abstract method interprets the given data and returns it.
Parameters:
data - AttributeNameValues containing data to be interpreted
Returns:
AttributeNameValues object containing the interpreted data

runInterpreterMethod

protected DataObject runInterpreterMethod(DataObject data,
                                          java.lang.String error)
This is an empty method that should be overridden by objects that subclass from this class. It is called when another component tries to run a method on the interpreter, but it's not an interpret request.
Parameters:
data - DataObject containing the data for the method
error - String containing the incoming error value
Returns:
DataObject containing the method results

getInAttributeType

protected java.lang.String getInAttributeType(java.lang.String name)
Returns the attribute type with the given name for incoming attributes
Parameters:
name - Name of the attribute to get

setInAttribute

protected void setInAttribute(java.lang.String name,
                              java.lang.String type)
Adds an incoming attribute
Parameters:
name - Name of the attribute to set
type - Type of the attribute

isInAttribute

protected boolean isInAttribute(java.lang.String name)
Checks if the given incoming attribute is an attribute of this interpreter
Parameters:
name - Name of the attribute to check

getOutAttributeType

protected java.lang.String getOutAttributeType(java.lang.String name)
Returns the attribute type with the given name for outgoing attributes
Parameters:
name - Name of the attribute to get

setOutAttribute

protected void setOutAttribute(java.lang.String name,
                               java.lang.String type)
Adds an outgoing attribute
Parameters:
name - Name of the attribute to set
type - Type of the attribute

isOutAttribute

protected boolean isOutAttribute(java.lang.String name)
Checks if the given outgoing attribute is an attribute of this interpreter
Parameters:
name - Name of the attribute to check

setInAttributes

protected abstract Attributes setInAttributes()
Sets the incoming attributes for the interpreter

setOutAttributes

protected abstract Attributes setOutAttributes()
Sets the outgoing attributes for the interpreter