edu.uci.isr.yancees
Class GenericMessage

java.lang.Object
  extended by edu.uci.isr.yancees.GenericMessage
All Implemented Interfaces:
MessageInterface, java.io.Serializable
Direct Known Subclasses:
GenericEvent, GenericSubscription

public class GenericMessage
extends java.lang.Object
implements MessageInterface

See Also:
Serialized Form

Field Summary
protected  java.util.Date dateCreated
          In order to have the proper comparison between dates, timezone differences must be considered here.
protected  java.util.Date dateReceivedInServer
           
protected  org.w3c.dom.Node messageDOM
           
protected  long myId
           
protected  java.lang.String textContent
           
 
Constructor Summary
GenericMessage()
           
GenericMessage(java.io.File file)
          Initializes the message with a file.
GenericMessage(org.w3c.dom.Node n)
           
GenericMessage(java.lang.String content)
          Initializes the file with the content provided in a String We assume that the String has a XML message able to be parsed
 
Method Summary
protected  org.w3c.dom.Document convertTextToMessageDOM(java.lang.String text)
          Writes the contents of the file in memory to the disk, in a temporary directory, then parses it with a DOM parser, generating a data sturcture in memory.
 java.util.Date getDateCreated()
           
 java.util.Date getDateReceivedInServer()
           
 org.w3c.dom.Node getDOM()
           
 long getId()
          Messages have unique ids inside an address space.
 java.lang.String getXMLTextContent()
           
 void setDateReceivedInServer(java.util.Date date)
          This method is not shown in the MessageInterface and is used internally, by the Yancees APIs to stamp the date received
 void setDOM(org.w3c.dom.Node n)
          Changes the content of this Message object to the message tree provided.
 void setXMLTextContent(java.lang.String content)
          Changes the content of this message.
 java.lang.String toString()
           
protected  java.lang.String writeTextToTempFile(java.lang.String text)
          Writes the text to a temp file, with a special name and in the global temporary directory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

messageDOM

protected transient org.w3c.dom.Node messageDOM

textContent

protected java.lang.String textContent

dateCreated

protected java.util.Date dateCreated
In order to have the proper comparison between dates, timezone differences must be considered here.


dateReceivedInServer

protected java.util.Date dateReceivedInServer

myId

protected long myId
Constructor Detail

GenericMessage

public GenericMessage(org.w3c.dom.Node n)
               throws MessageParsingException
Throws:
MessageParsingException

GenericMessage

public GenericMessage()

GenericMessage

public GenericMessage(java.io.File file)
               throws java.io.IOException
Initializes the message with a file. Do not parse it so it can be exchanged remotely.

Parameters:
file - is the XML file having the message text content.
Throws:
java.io.IOException

GenericMessage

public GenericMessage(java.lang.String content)
Initializes the file with the content provided in a String We assume that the String has a XML message able to be parsed

Parameters:
content -
Method Detail

setDOM

public void setDOM(org.w3c.dom.Node n)
            throws MessageParsingException
Changes the content of this Message object to the message tree provided.

Specified by:
setDOM in interface MessageInterface
Throws:
MessageParsingException

getDOM

public org.w3c.dom.Node getDOM()
Specified by:
getDOM in interface MessageInterface
Returns:
a data structure in memory having the Document Object Model of this message.

writeTextToTempFile

protected java.lang.String writeTextToTempFile(java.lang.String text)
Writes the text to a temp file, with a special name and in the global temporary directory

Parameters:
text - the text to be written
Returns:
the path of the file created so it can be opened and used elsewhere

convertTextToMessageDOM

protected org.w3c.dom.Document convertTextToMessageDOM(java.lang.String text)
Writes the contents of the file in memory to the disk, in a temporary directory, then parses it with a DOM parser, generating a data sturcture in memory.

Parameters:
return - the document generated

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
Parameters:
content - is the new XML format contnet in the form of a String
Throws:
MessageParsingException - is thrown if the content is not syntatically correct

getXMLTextContent

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

toString

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

getId

public long getId()
Messages have unique ids inside an address space.

Specified by:
getId in interface MessageInterface
Returns:
the unique id for this message

getDateCreated

public java.util.Date getDateCreated()
Specified by:
getDateCreated in interface MessageInterface
Returns:
the local date when this object was created

getDateReceivedInServer

public java.util.Date getDateReceivedInServer()
Specified by:
getDateReceivedInServer in interface MessageInterface
Returns:
the data this message reached the server

setDateReceivedInServer

public void setDateReceivedInServer(java.util.Date date)
This method is not shown in the MessageInterface and is used internally, by the Yancees APIs to stamp the date received

Parameters:
date - is the current time and date