edu.uci.isr.yancees
Class YanceesEvent

java.lang.Object
  extended byedu.uci.isr.yancees.GenericMessage
      extended byedu.uci.isr.yancees.GenericEvent
          extended byedu.uci.isr.yancees.YanceesEvent
All Implemented Interfaces:
EventInterface, MessageInterface, java.io.Serializable

public class YanceesEvent
extends GenericEvent

Author:
Roberto Silveira Silva Filho [rsilvafi@ics.uci.edu] This class implements an event using the xml schema defined in yanceesEvent.xsd. It extends the GenericEvent to include methods that allow the programmer to add and remove attributes in a programmatic way, not having to provide an XML file as an input. This class builds an XML document based on the event description at yanceesEvent.xsd
See Also:
Serialized Form

Field Summary
static java.lang.String ATTRIBUTE
           
static java.lang.String BINARY_TYPE
           
static java.lang.String BOOLEAN_TYPE
           
static java.lang.String DOUBLE_TYPE
           
static java.lang.String EVENT
          Tags used from the event to express siena constraints.
static java.lang.String FLOAT_TYPE
           
static java.lang.String INT_TYPE
           
static java.lang.String LONG_TYPE
           
static java.lang.String NAME
           
static java.lang.String STRING_TYPE
           
static java.lang.String TYPE_ATTRIBUTE
           
static java.lang.String VALUE
           
static java.lang.String YANCEES_DATE_CREATED
           
static java.lang.String YANCEES_DATE_RECEIVED
           
static java.lang.String YANCEES_ID
           
static java.lang.String YANCEES_VERSION
           
static java.lang.String YANCEES_VERSION_TAG
           
 
Fields inherited from class edu.uci.isr.yancees.GenericMessage
dateCreated, dateReceivedInServer, messageDOM, myId, textContent
 
Constructor Summary
YanceesEvent()
          This is the preferential constructor for this object.
YanceesEvent(java.io.File file)
           
YanceesEvent(org.w3c.dom.Node n)
           
YanceesEvent(java.lang.String content)
           
 
Method Summary
 void clearAll()
          Removes every attribute from this YanceesEvent.
 boolean containsAttribute(java.lang.String name)
           
protected  void extractAttributesFromText(java.lang.String text)
          Parses the text content using SAX and replaces the current attributes by the attributes in the text.
protected  void finalize()
           
 java.lang.Object get(java.lang.String attName)
           
 java.util.Iterator getAttributeNamesIterator()
          Returns an iterator for the set of attribute names of this SienaEvent body.
 boolean getBoolean(java.lang.String attName)
          Gets a boolean attribute
 byte[] getByteArray(java.lang.String attName)
          Gets a byte[] attribute
 org.w3c.dom.Node getDOM()
           
 double getDouble(java.lang.String attName)
          Gets a double attribute
 float getFloat(java.lang.String attName)
          Gets a float attribute
 int getInt(java.lang.String attName)
          Gets a int attribute
 long getLong(java.lang.String attName)
          Gets a long attribute
 java.lang.String getString(java.lang.String attName)
          Gets a string attribute
 java.lang.String getXMLTextContent()
           
 int numberOfAttributes()
           
 void put(java.lang.String attName, boolean value)
           
 void put(java.lang.String attName, byte[] value)
           
 void put(java.lang.String attName, double value)
           
 void put(java.lang.String attName, float value)
           
 void put(java.lang.String attName, int value)
           
 void put(java.lang.String attName, long value)
           
 void put(java.lang.String attName, java.lang.String value)
           
 void remove(java.lang.String attName)
           
 void setDateCreated(java.util.Date newDate)
          used to reconstruct the id when an event is re-created in the ohter side of the network
 void setDOM(org.w3c.dom.Node n)
          Changes the content of the event by providing a new XML representation for it.
 void setID(long originalId)
          used to reconstruct the id when an event is re-created in the ohter side of the network
 void setXMLTextContent(java.lang.String content)
          Changes the content of this message.
 java.lang.String toString()
          Prints the structure of the evetn using a free notation.
 
Methods inherited from class edu.uci.isr.yancees.GenericMessage
convertTextToMessageDOM, getDateCreated, getDateReceivedInServer, getId, setDateReceivedInServer, writeTextToTempFile
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.uci.isr.yancees.MessageInterface
getDateCreated, getDateReceivedInServer, getId
 

Field Detail

YANCEES_DATE_RECEIVED

public static final java.lang.String YANCEES_DATE_RECEIVED
See Also:
Constant Field Values

YANCEES_DATE_CREATED

public static final java.lang.String YANCEES_DATE_CREATED
See Also:
Constant Field Values

YANCEES_ID

public static final java.lang.String YANCEES_ID
See Also:
Constant Field Values

YANCEES_VERSION_TAG

public static final java.lang.String YANCEES_VERSION_TAG
See Also:
Constant Field Values

YANCEES_VERSION

public static final java.lang.String YANCEES_VERSION
See Also:
Constant Field Values

EVENT

public static final java.lang.String EVENT
Tags used from the event to express siena constraints. these tags are imported from the sienaEvent.xsd schema and used in the sienaSubscriptin.xsd

See Also:
Constant Field Values

NAME

public static final java.lang.String NAME
See Also:
Constant Field Values

VALUE

public static final java.lang.String VALUE
See Also:
Constant Field Values

ATTRIBUTE

public static final java.lang.String ATTRIBUTE
See Also:
Constant Field Values

TYPE_ATTRIBUTE

public static final java.lang.String TYPE_ATTRIBUTE
See Also:
Constant Field Values

BINARY_TYPE

public static final java.lang.String BINARY_TYPE
See Also:
Constant Field Values

BOOLEAN_TYPE

public static final java.lang.String BOOLEAN_TYPE
See Also:
Constant Field Values

DOUBLE_TYPE

public static final java.lang.String DOUBLE_TYPE
See Also:
Constant Field Values

FLOAT_TYPE

public static final java.lang.String FLOAT_TYPE
See Also:
Constant Field Values

LONG_TYPE

public static final java.lang.String LONG_TYPE
See Also:
Constant Field Values

INT_TYPE

public static final java.lang.String INT_TYPE
See Also:
Constant Field Values

STRING_TYPE

public static final java.lang.String STRING_TYPE
See Also:
Constant Field Values
Constructor Detail

YanceesEvent

public YanceesEvent(org.w3c.dom.Node n)
             throws ParsingException
Parameters:
n - is the representation of the event as a DOM tree in memory
Throws:
ParsingException - is thrown in case the event is not according to the expected format.

YanceesEvent

public YanceesEvent(java.io.File file)
             throws java.io.IOException
Parameters:
file - is the File object with the XML representation of an event according to the standard format, supported by the adapter and the plug-ins. The event here can be desribed in many formats, as well as the adapters and plug-ins in the server know how to handle it.
Throws:
java.io.IOException

YanceesEvent

public YanceesEvent(java.lang.String content)
Parameters:
content - is the XML representation of the event in textual, string in memory.

YanceesEvent

public YanceesEvent()
This is the preferential constructor for this object. It creates an empty event that will be stuffed with attribute/value pairs with the setAttribute() methods.

Method Detail

setDOM

public void setDOM(org.w3c.dom.Node n)
            throws ParsingException
Changes the content of the event by providing a new XML representation for it. The representation is provided in the form of a DOM tree in the parameter n

Specified by:
setDOM in interface MessageInterface
Overrides:
setDOM in class GenericMessage
Throws:
ParsingException

getDOM

public org.w3c.dom.Node getDOM()
Specified by:
getDOM in interface MessageInterface
Overrides:
getDOM in class GenericMessage
Returns:
the DOM tree representing the current event. In other words, builds a DOM tree with the attributes in this event, in an DOM model format.

getString

public java.lang.String getString(java.lang.String attName)
                           throws WrongAttributeTypeException
Gets a string attribute

Parameters:
attName - is the name of the atribute to be retrieved
Returns:
the String type attribute or null if the attribute does not exist or it cannot be converted to a string.
Throws:
WrongAttributeTypeException - if the attribute exists but the type is wrong

getDouble

public double getDouble(java.lang.String attName)
                 throws WrongAttributeTypeException
Gets a double attribute

Parameters:
attName - is the name of the atribute to be retrieved
Returns:
the String type attribute or null if the attribute does not exist or it cannot be converted to a string.
Throws:
WrongAttributeTypeException - if the attribute exists but the type is wrong

getFloat

public float getFloat(java.lang.String attName)
               throws WrongAttributeTypeException
Gets a float attribute

Parameters:
attName - is the name of the atribute to be retrieved
Returns:
the String type attribute or null if the attribute does not exist or it cannot be converted to a string.
Throws:
WrongAttributeTypeException - if the attribute exists but the type is wrong

getInt

public int getInt(java.lang.String attName)
           throws WrongAttributeTypeException
Gets a int attribute

Parameters:
attName - is the name of the atribute to be retrieved
Returns:
the String type attribute or null if the attribute does not exist or it cannot be converted to a string.
Throws:
WrongAttributeTypeException - if the attribute exists but the type is wrong

getLong

public long getLong(java.lang.String attName)
             throws WrongAttributeTypeException
Gets a long attribute

Parameters:
attName - is the name of the atribute to be retrieved
Returns:
the String type attribute or null if the attribute does not exist or it cannot be converted to a string.
Throws:
WrongAttributeTypeException - if the attribute exists but the type is wrong

getByteArray

public byte[] getByteArray(java.lang.String attName)
                    throws WrongAttributeTypeException
Gets a byte[] attribute

Parameters:
attName - is the name of the atribute to be retrieved
Returns:
the String type attribute or null if the attribute does not exist or it cannot be converted to a string.
Throws:
WrongAttributeTypeException - if the attribute exists but the type is wrong

getBoolean

public boolean getBoolean(java.lang.String attName)
                   throws WrongAttributeTypeException
Gets a boolean attribute

Parameters:
attName - is the name of the atribute to be retrieved
Returns:
the String type attribute or null if the attribute does not exist or it cannot be converted to a string.
Throws:
WrongAttributeTypeException - if the attribute exists but the type is wrong

clearAll

public void clearAll()
Removes every attribute from this YanceesEvent.


numberOfAttributes

public int numberOfAttributes()

get

public java.lang.Object get(java.lang.String attName)

remove

public void remove(java.lang.String attName)

put

public void put(java.lang.String attName,
                java.lang.String value)

put

public void put(java.lang.String attName,
                double value)

put

public void put(java.lang.String attName,
                float value)

put

public void put(java.lang.String attName,
                boolean value)

put

public void put(java.lang.String attName,
                byte[] value)

put

public void put(java.lang.String attName,
                int value)

put

public void put(java.lang.String attName,
                long value)

getAttributeNamesIterator

public java.util.Iterator getAttributeNamesIterator()
Returns an iterator for the set of attribute names of this SienaEvent body.


containsAttribute

public boolean containsAttribute(java.lang.String name)

toString

public java.lang.String toString()
Prints the structure of the evetn using a free notation.

Overrides:
toString in class GenericMessage

setXMLTextContent

public void setXMLTextContent(java.lang.String content)
Changes the content of this message. Replaces it with the XML content provided in the String provided

Specified by:
setXMLTextContent in interface MessageInterface
Overrides:
setXMLTextContent in class GenericMessage
Parameters:
content - is the new XML format contnet in the form of a String

getXMLTextContent

public java.lang.String getXMLTextContent()
Specified by:
getXMLTextContent in interface MessageInterface
Overrides:
getXMLTextContent in class GenericMessage
Returns:
the content of this message in the text form, as a string.

extractAttributesFromText

protected void extractAttributesFromText(java.lang.String text)
Parses the text content using SAX and replaces the current attributes by the attributes in the text. If the text is null, nothing is done.

Parameters:
text - is the XML text in memory to be parsed.

setDateCreated

public void setDateCreated(java.util.Date newDate)
used to reconstruct the id when an event is re-created in the ohter side of the network

Parameters:
newDate - is the original creation date of the object.

setID

public void setID(long originalId)
used to reconstruct the id when an event is re-created in the ohter side of the network

Parameters:
originalId - is the original id of this event

finalize

protected void finalize()
                 throws java.lang.Throwable
Throws:
java.lang.Throwable