starlink.AbstractMessage
Class XMLFactoring

java.lang.Object
  extended by starlink.AbstractMessage.XMLFactoring

public class XMLFactoring
extends java.lang.Object

XMLFactoring provides a library of operations for processing the XML descriptions of protocol packets. Java code can be generated from an xml schema. Data values can be inserted into XML generated objects; and xpath expressions can be used to query the value of a field in and XML generated object.

Since:
28th September 2010
Version:
0.1
Author:
Paul Grace

Method Summary
 AbstractMessage constructPacket(Message m)
          Construct the data representation as required by the generic composer
 ProtocolMessage createMessages(java.io.File XMLDocument)
          Generate the java objects that correspond to the protocol's abstract representation.
static XMLFactoring getInstance()
           
 java.lang.Object getXPathField(AbstractMessage msg, java.lang.String xpathExpr)
           
 java.lang.String getXPathFieldLabel(java.lang.String xpathExpr)
           
 AbstractMessage getXPathStructuredField(AbstractMessage msg, java.lang.String xpathExpr)
           
 java.lang.Object getXPathValue(AbstractMessage msg, java.lang.String xpathExpr)
          Get the value of a message field by using an XPATH expression.
 void setXPathValue(AbstractMessage msg, java.lang.String xpathExpr, java.lang.Object value)
          Set the value of a message field by using an XPATH expression.
 void writePrimitiveField(AbstractMessage mp, java.lang.String label, java.lang.String type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static XMLFactoring getInstance()

createMessages

public ProtocolMessage createMessages(java.io.File XMLDocument)
Generate the java objects that correspond to the protocol's abstract representation. That is the objects that match each of the protocol's messages in terms of fields and types.

Parameters:
XMLDocument - The XML file containing the description of the network protocol.
Returns:
The "generated" java object representing a network protocol.

getXPathValue

public java.lang.Object getXPathValue(AbstractMessage msg,
                                      java.lang.String xpathExpr)
Get the value of a message field by using an XPATH expression.

Parameters:
msg - The message content to search the value in.
xpathExpr - The XPATH expression describing the location of the field we want the value of.
Returns:
the value of the field

getXPathFieldLabel

public java.lang.String getXPathFieldLabel(java.lang.String xpathExpr)

getXPathField

public java.lang.Object getXPathField(AbstractMessage msg,
                                      java.lang.String xpathExpr)

getXPathStructuredField

public AbstractMessage getXPathStructuredField(AbstractMessage msg,
                                               java.lang.String xpathExpr)

setXPathValue

public void setXPathValue(AbstractMessage msg,
                          java.lang.String xpathExpr,
                          java.lang.Object value)
Set the value of a message field by using an XPATH expression.

Parameters:
msg - The message content to put the value in.
xpathExpr - The XPATH expression describing the location of the field we want to change/set the value of.

constructPacket

public AbstractMessage constructPacket(Message m)
Construct the data representation as required by the generic composer

Parameters:
m - The message to convert to the meta packet structure
Returns:
The metapacket object built from the message values

writePrimitiveField

public void writePrimitiveField(AbstractMessage mp,
                                java.lang.String label,
                                java.lang.String type)