hypercast.MonitorAndControl
Class MonMessage

java.lang.Object
  |
  +--hypercast.MonitorAndControl.MCRawMessage
        |
        +--hypercast.MonitorAndControl.MonMessage
All Implemented Interfaces:
java.lang.Cloneable

public class MonMessage
extends hypercast.MonitorAndControl.MCRawMessage

This class implements a Monitor/Control Query message exchanged between Monitor and Portal to carry the query and reply for statitics and schemas. The XML document represeting a MonMessage looks like: <...> //the value of the stats <...> //the value of the stats ... ... The type of message can be one of the following: 1. GetQuery 2. GetReply 3. ReadSchemaQuery 4. ReadSchemaReply 5. SetQuery 6. SetReply 7. WriteSchemaQuery 8. WriteSchemaReply A MonMessage contains a list of statistics ("Stats"), each of which has a XPath expression in String format, and an index specifying the location of the "Stats" in the message. If and only if the type is 2.,4.,5.,6.,or 8., the value Element contained in each "Stats" element is not empty. A "Stats" element inside an MonMessage can be indexed either by specifying the XPath string, or using the index field.


Field Summary
static java.lang.String MULTICAST_DESTINATION_STRING
           
 
Method Summary
 void addStat(org.apache.xpath.XPath xpath)
          Adds OR updates a new stats item with value Add a new stats item with null value.
 void addStat(org.apache.xpath.XPath Xpath, org.w3c.dom.Element value)
          Adds OR updates a new stats item with value If xpath exists, update the stat with new value
 void clearMessageID()
           
 java.lang.Object clone()
           
 boolean equals(java.lang.Object object)
           
 hypercast.I_LogicalAddress getDestination()
          Get the logical address string of the destination of this message.
 org.w3c.dom.Document getDocument()
          Return the XML document representation of this M&C message.
 long getMessageID()
          Returns the message ID.
 hypercast.I_LogicalAddress getSender()
          Get the logical address of the sender of this message.
 int getStatsCount()
          Get number of statistics contained in this message.
 org.w3c.dom.Element[] getStatValue(int index)
          Return the XML stats value at the specified index
 org.w3c.dom.Element[] getStatValue(org.apache.xpath.XPath xpath)
          Return the XML stats value which is referred by the xpath string.
 org.apache.xpath.XPath getStatXPath(int index)
          Return XPath string at the specified index.
 long getTimeStamp()
          Get the timestamp of the message
 java.lang.String getType()
          Get the String representation of the type of the message.
 int getTypeNum()
           
 int hashCode()
           
 boolean isStatError(int index)
          Returns true if an error message exists for a statistics item at the specified index.
 boolean isStatError(org.apache.xpath.XPath xpath)
          Returns true if an error message exists for a stat with the specified XPath.
 void removeStat(int index)
          remove a statistics item at the specified index
 void removeStat(org.apache.xpath.XPath Xpath)
          remove a statistics item with the specified xpath
 void setStat(int index, org.w3c.dom.Element value)
          set the XML value of a stat at the specified index
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MULTICAST_DESTINATION_STRING

public static final java.lang.String MULTICAST_DESTINATION_STRING
See Also:
Constant Field Values
Method Detail

getStatsCount

public int getStatsCount()
Get number of statistics contained in this message.

Returns:
number of stats contained

getStatXPath

public org.apache.xpath.XPath getStatXPath(int index)
                                    throws HyperCastStatsException
Return XPath string at the specified index.

Parameters:
index - the index of the stats
Returns:
the XPath string
HyperCastStatsException

getStatValue

public org.w3c.dom.Element[] getStatValue(int index)
                                   throws HyperCastStatsException
Return the XML stats value at the specified index

Parameters:
index - the index of the stats
Returns:
the XML stats value
HyperCastStatsException

getStatValue

public org.w3c.dom.Element[] getStatValue(org.apache.xpath.XPath xpath)
                                   throws HyperCastStatsException
Return the XML stats value which is referred by the xpath string.

Parameters:
xpath - the XPath string
Returns:
the XML stats value
HyperCastStatsException

addStat

public void addStat(org.apache.xpath.XPath xpath)
Adds OR updates a new stats item with value Add a new stats item with null value. NB: clobbers any existing stat with null

Parameters:
xpath -

addStat

public void addStat(org.apache.xpath.XPath Xpath,
                    org.w3c.dom.Element value)
Adds OR updates a new stats item with value If xpath exists, update the stat with new value

Parameters:
Xpath - the xpath string
value - the XML stats value

setStat

public void setStat(int index,
                    org.w3c.dom.Element value)
             throws HyperCastStatsException
set the XML value of a stat at the specified index

Parameters:
index - the index of the stats
value - the XML value of the stats
HyperCastStatsException

isStatError

public boolean isStatError(org.apache.xpath.XPath xpath)
                    throws HyperCastStatsException
Returns true if an error message exists for a stat with the specified XPath.

Parameters:
xpath - the xpath string
Returns:
true if it is an error for this statistics item
HyperCastStatsException

isStatError

public boolean isStatError(int index)
                    throws HyperCastStatsException
Returns true if an error message exists for a statistics item at the specified index.

Parameters:
index - the index for this stats
Returns:
true if it is an error for this statistics item
HyperCastStatsException

removeStat

public void removeStat(org.apache.xpath.XPath Xpath)
                throws HyperCastStatsException
remove a statistics item with the specified xpath

Parameters:
Xpath - the xpath string
HyperCastStatsException

removeStat

public void removeStat(int index)
                throws HyperCastStatsException
remove a statistics item at the specified index

Parameters:
index - the index of the statistics item
HyperCastStatsException

clone

public java.lang.Object clone()
Overrides:
clone in class hypercast.MonitorAndControl.MCRawMessage

getDocument

public org.w3c.dom.Document getDocument()
Return the XML document representation of this M&C message. An M&C message is transmitted on the network in XML format. So every M&C can be converted to a XML document. Note that this method returns a reference to an internal data structure - use with care!

Returns:
the XML document representing this M&C message

getDestination

public hypercast.I_LogicalAddress getDestination()
Get the logical address string of the destination of this message. If the message is supposed to be sent to all portals in the network, this field is set to "".

Returns:
Returns the destination.

getMessageID

public long getMessageID()
Returns the message ID.

Returns:
the message ID

clearMessageID

public void clearMessageID()

getSender

public hypercast.I_LogicalAddress getSender()
Get the logical address of the sender of this message.

Returns:
The logical address of the sender.

getTimeStamp

public long getTimeStamp()
Get the timestamp of the message

Returns:
Returns the timeStamp.

getType

public java.lang.String getType()
Get the String representation of the type of the message. This String will be put in to the XML document representing this message as the root element name.

Returns:
the String representation of the type of the message

getTypeNum

public int getTypeNum()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object