context.arch.interpreter
Class IIButton2NameExt

java.lang.Object
  |
  +--context.arch.BaseObject
        |
        +--context.arch.interpreter.Interpreter
              |
              +--context.arch.interpreter.IIButton2NameExt

public class IIButton2NameExt
extends Interpreter

This class is an interpreter that converts iButton ids to names. It looks up correspondences between ids and names from an XML web page given as an argument. It expects the XML page to comply with the context-users DTD. Another component (app/widget/interpreter) sends an interpret command to it with an ibutton id, and this class returns the corresponding name.

See Also:
Interpreter

Field Summary
static java.lang.String CLASSNAME
          Name of interpreter
static int DEFAULT_PORT
          Default port to use to receive communications
static java.lang.String DEFAULT_USERSLIST
          Default port to use to receive communications
static java.lang.String DUMMBO
          String for Dummbo
static java.lang.String IBUTTONID
          Tag for iButton id
static java.lang.String LISTUSERSNAMES
          Tag for requesting the list of all users names
static java.lang.String LISTUSERSNAMES_REPLY
          Tag for reply to request for the list of all users names
static java.lang.String USERNAME
          Tag for username
 
Fields inherited from class context.arch.interpreter.Interpreter
DEFAULT_PORT, inAttributes, inAttributeTypes, INTERPRET, INTERPRET_REPLY, outAttributes, outAttributeTypes
 
Fields inherited from class context.arch.BaseObject
communications, EXIT_OK, handlers, ID, parser, PING, PING_REPLY, serviceHandlers
 
Constructor Summary
IIButton2NameExt()
          Constructor that creates the interpreter at the default port and using the default users list.
IIButton2NameExt(int port)
          Constructor that creates the interpreter at the given port and using the default users list.
IIButton2NameExt(int port, java.lang.String url)
          Constructor that creates the interpreter at the given port and with the given url for the users list.
IIButton2NameExt(java.lang.String url)
          Constructor that creates the interpreter at the default port and using the given url for the users list.
 
Method Summary
protected  AttributeNameValues interpretData(AttributeNameValues data)
          This method performs the actual interpretation of this component.
static void main(java.lang.String[] argv)
          Main method to create this interpreter with port specified by command line arguments
protected  DataObject runInterpreterMethod(DataObject data, java.lang.String error)
          This is method that handles methods for this Interpreter that are no interpreter requests.
protected  Attributes setInAttributes()
          Sets the incoming attributes for the interpreter.
protected  Attributes setOutAttributes()
          Sets the outgoing attributes for the interpreter.
 
Methods inherited from class context.arch.interpreter.Interpreter
getInAttributeType, getOutAttributeType, isInAttribute, isOutAttribute, runUserMethod, setInAttribute, setOutAttribute
 
Methods inherited from class context.arch.BaseObject
askInterpreter, decodeData, encodeData, executeAsynchronousWidgetService, executeSynchronousWidgetService, getHostAddress, getId, getVersion, getVersion, getWidgetAttributes, getWidgetCallbacks, getWidgetServices, 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

CLASSNAME

public static final java.lang.String CLASSNAME
Name of interpreter

LISTUSERSNAMES

public static final java.lang.String LISTUSERSNAMES
Tag for requesting the list of all users names

LISTUSERSNAMES_REPLY

public static final java.lang.String LISTUSERSNAMES_REPLY
Tag for reply to request for the list of all users names

IBUTTONID

public static final java.lang.String IBUTTONID
Tag for iButton id

USERNAME

public static final java.lang.String USERNAME
Tag for username

DEFAULT_PORT

public static final int DEFAULT_PORT
Default port to use to receive communications

DEFAULT_USERSLIST

public static final java.lang.String DEFAULT_USERSLIST
Default port to use to receive communications

DUMMBO

public static final java.lang.String DUMMBO
String for Dummbo
Constructor Detail

IIButton2NameExt

public IIButton2NameExt()
Constructor that creates the interpreter at the default port and using the default users list.

IIButton2NameExt

public IIButton2NameExt(int port)
Constructor that creates the interpreter at the given port and using the default users list.

IIButton2NameExt

public IIButton2NameExt(java.lang.String url)
Constructor that creates the interpreter at the default port and using the given url for the users list.

IIButton2NameExt

public IIButton2NameExt(int port,
                        java.lang.String url)
Constructor that creates the interpreter at the given port and with the given url for the users list. It sets the id of the this interpreter to CLASSNAME.
Method Detail

interpretData

protected AttributeNameValues interpretData(AttributeNameValues data)
This method performs the actual interpretation of this component. It takes an iButton id and returns a user name.
Overrides:
interpretData in class Interpreter
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 method that handles methods for this Interpreter that are no interpreter requests.
Overrides:
runInterpreterMethod in class Interpreter
Parameters:
data - DataObject containing the data for the method
error - String containing the incoming error value
Returns:
DataObject containing the method results

setInAttributes

protected Attributes setInAttributes()
Sets the incoming attributes for the interpreter. It has only one: IBUTTONID.
Overrides:
setInAttributes in class Interpreter
Returns:
the incoming attributes for this interpreter

setOutAttributes

protected Attributes setOutAttributes()
Sets the outgoing attributes for the interpreter. It has only one: USERNAME.
Overrides:
setOutAttributes in class Interpreter
Returns:
the outgoing attributes for this interpreter

main

public static void main(java.lang.String[] argv)
Main method to create this interpreter with port specified by command line arguments