net.sf.xbus.protocol.records
Class RecordTypeMessage

java.lang.Object
  extended by net.sf.xbus.protocol.Message
      extended by net.sf.xbus.protocol.xml.XMLMessageAbstract
          extended by net.sf.xbus.protocol.records.RecordTypeMessage
All Implemented Interfaces:
ObjectMessage, TextMessage, XMLMessage

public class RecordTypeMessage
extends XMLMessageAbstract
implements TextMessage, ObjectMessage, XMLMessage

RecordTypeMessage is used in the xBus to transport and convert file contents structured by record types.

The structure is described by a xml file - in particular the contained record types, their order within the string and how to identify them during parsing. Such describing files are of document type InterfaceSpec declared in "InterfaceSpec.dtd".

The records are internally stored in a DOM tree. Thus RecordTypeMessage extends XMLMessageAbstractto use some of xml its features.

Author:
Stephan Dwel

Constructor Summary
RecordTypeMessage(java.lang.String function, XBUSSystem source, java.lang.String id)
          This constructor initializes the new RecordTypeMessage with the given parameters.
RecordTypeMessage(XBUSSystem source)
          This constructor stores the source, creates an unique identifier for the message and initializes the requestTimestamp.
 
Method Summary
 java.lang.Object getRequestObject(XBUSSystem system)
          Gets the text of the incoming message as a ByteArrayList.
 java.lang.String getRequestText(XBUSSystem system)
          Gets the text of the incoming message.
 java.lang.String getRequestTextAsXML(XBUSSystem system)
          Gets the text of the message as xml document.
 java.lang.Object getResponseObject()
          Gets the text of the response message as a ByteArrayList.
 java.lang.String getResponseText()
          Gets the text of the response message.
 void setRequestObject(java.lang.Object obj, XBUSSystem source)
          setRequestObject sets the text of the incoming message.
 void setRequestText(java.lang.String text, XBUSSystem source)
          setRequestText sets the text of the incoming message.
 void setResponseDocument(org.w3c.dom.Document doc, XBUSSystem destination)
          Sets the response XML data as a org.w3c.dom.Document.
 void setResponseObject(java.lang.Object obj, XBUSSystem destination)
          setResponseObject sets the text of the incoming message.
 void setResponseText(java.lang.String text, XBUSSystem destination)
          setResponseText sets the text of the incoming message.
protected  void synchronizeRequestFields(XBUSSystem system)
          Empty method.
protected  void synchronizeResponseFields(XBUSSystem system)
          Empty method.
 
Methods inherited from class net.sf.xbus.protocol.xml.XMLMessageAbstract
getDocumentBuilder, getRequestDocument, getResponseDocument, parseXML, serializeXML, setRequestDocument
 
Methods inherited from class net.sf.xbus.protocol.Message
getErrorcode, getErrortext, getFunction, getId, getRequestTimestamp, getResponseTimestamp, getReturncode, getShortname, getSource, setErrorcode, setErrortext, setFunction, setId, setResponseTimestamp, setReturncode, setShortname
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.xbus.protocol.XMLMessage
getRequestDocument, getResponseDocument, setRequestDocument
 

Constructor Detail

RecordTypeMessage

public RecordTypeMessage(XBUSSystem source)
This constructor stores the source, creates an unique identifier for the message and initializes the requestTimestamp. It is used when constructing a new RecordTypeMessage from the data of a receiver.

Parameters:
source - the source of the data

RecordTypeMessage

public RecordTypeMessage(java.lang.String function,
                         XBUSSystem source,
                         java.lang.String id)
This constructor initializes the new RecordTypeMessage with the given parameters. It is used when constructing a new RecordTypeMessage by converting it from another Message.

Parameters:
function - the function to be executed by the destination system
source - the source of the data
id - the message id
Method Detail

setRequestText

public void setRequestText(java.lang.String text,
                           XBUSSystem source)
                    throws XException
setRequestText sets the text of the incoming message. After parsing due to the interface file and record type specification, the information is stored in a org.w3c.dom.Document. This operation is used to work with strings.

Specified by:
setRequestText in interface TextMessage
Overrides:
setRequestText in class XMLMessageAbstract
Parameters:
text - the data string
source - system where the request is coming from
Throws:
XException - in case that the specifed string cannot be parsed
See Also:
setRequestObject(Object, net.sf.xbus.base.xbussystem.XBUSSystem)

getRequestText

public java.lang.String getRequestText(XBUSSystem system)
                                throws XException
Gets the text of the incoming message. It is the result of the serialization of a org.w3c.dom.Documentdue to the interface file and record type specification. This operation is used to work with strings.

Specified by:
getRequestText in interface TextMessage
Overrides:
getRequestText in class XMLMessageAbstract
Parameters:
system - reference to the system for which the message is meant - used in finding specifications for serialising the message content
Returns:
the message text as string
Throws:
XException - in case that the content cannot be serialised
See Also:
getRequestObject(XBUSSystem)

setResponseText

public void setResponseText(java.lang.String text,
                            XBUSSystem destination)
                     throws XException
setResponseText sets the text of the incoming message. After parsing due to the interface file and record type specification, the information is stored in a org.w3c.dom.Document. This operation is used to work with strings.

Specified by:
setResponseText in interface TextMessage
Overrides:
setResponseText in class XMLMessageAbstract
Parameters:
text - the data string
destination - system where the response is coming from
Throws:
XException - in case that the specifed string cannot be parsed
See Also:
setResponseText(String, XBUSSystem)

getResponseText

public java.lang.String getResponseText()
                                 throws XException
Gets the text of the response message. It is the result of the serialization of a org.w3c.dom.Documentdue to the interface file and record type specification. This operation is used to work with strings.

Specified by:
getResponseText in interface TextMessage
Overrides:
getResponseText in class XMLMessageAbstract
Returns:
the message text as string
Throws:
XException - in case that the content cannot be serialised
See Also:
getResponseText()

setRequestObject

public void setRequestObject(java.lang.Object obj,
                             XBUSSystem source)
                      throws XException
setRequestObject sets the text of the incoming message. After parsing due to the interface file and record type specification, the information is stored in a org.w3c.dom.Document. This operation is used to work with byte array lists.

Specified by:
setRequestObject in interface ObjectMessage
Overrides:
setRequestObject in class XMLMessageAbstract
Parameters:
obj - the data in form of a ByteArrayList
source - system where the request is coming from
Throws:
XException - in case that the specifed string cannot be parsed
See Also:
setRequestObject(Object, net.sf.xbus.base.xbussystem.XBUSSystem)

getRequestObject

public java.lang.Object getRequestObject(XBUSSystem system)
                                  throws XException
Gets the text of the incoming message as a ByteArrayList. It is the result of the serialization of a org.w3c.dom.Documentdue to the interface file and record type specification. This operation is used to work with byte array lists.

Specified by:
getRequestObject in interface ObjectMessage
Overrides:
getRequestObject in class XMLMessageAbstract
Parameters:
system - reference to the system for which the message is meant - used in finding specifications for serialising the message content
Returns:
the message text as ByteArrayList
Throws:
XException - in case that the content cannot be serialised
See Also:
getRequestText(XBUSSystem)

setResponseObject

public void setResponseObject(java.lang.Object obj,
                              XBUSSystem destination)
                       throws XException
setResponseObject sets the text of the incoming message. After parsing due to the interface file and record type specification, the information is stored in a org.w3c.dom.Document. This operation is used to work with byte array lists.

Specified by:
setResponseObject in interface ObjectMessage
Overrides:
setResponseObject in class XMLMessageAbstract
Parameters:
obj - the data in form of a ByteArrayList
destination - system where the response is coming from
Throws:
XException - in case that the specifed string cannot be parsed
See Also:
setResponseText(String, XBUSSystem)

getResponseObject

public java.lang.Object getResponseObject()
                                   throws XException
Gets the text of the response message as a ByteArrayList. It is the result of the serialization of a org.w3c.dom.Documentdue to the interface file and record type specification. This operation is used to work with byte array lists.

Specified by:
getResponseObject in interface ObjectMessage
Overrides:
getResponseObject in class XMLMessageAbstract
Returns:
the message text as ByteArrayList
Throws:
XException - in case that the content cannot be serialised
See Also:
getResponseText()

setResponseDocument

public void setResponseDocument(org.w3c.dom.Document doc,
                                XBUSSystem destination)
                         throws XException
Description copied from class: XMLMessageAbstract
Sets the response XML data as a org.w3c.dom.Document.

Specified by:
setResponseDocument in interface XMLMessage
Overrides:
setResponseDocument in class XMLMessageAbstract
Parameters:
doc - the content of the response
destination - system where the response is coming from
Throws:
XException

getRequestTextAsXML

public java.lang.String getRequestTextAsXML(XBUSSystem system)
                                     throws XException
Gets the text of the message as xml document. It is the result of the standard serialization of a org.w3c.dom.Document.

Parameters:
system - reference to the system for which the message is meant - used in finding specifications for serialising the message content
Returns:
the serialised document in XML format
Throws:
XException - in case that the content cannot be serialised

synchronizeRequestFields

protected void synchronizeRequestFields(XBUSSystem system)
Empty method.

Specified by:
synchronizeRequestFields in class XMLMessageAbstract

synchronizeResponseFields

protected void synchronizeResponseFields(XBUSSystem system)
Empty method.

Specified by:
synchronizeResponseFields in class XMLMessageAbstract