hypercast
Class HyperCastConfig

java.lang.Object
  |
  +--hypercast.HyperCastConfig
All Implemented Interfaces:
I_Stats

public class HyperCastConfig
extends java.lang.Object
implements I_Stats

This class defines the overlay socket configuration object which stores the attributes of the overlay. It contains a static method for creating an instance of overlay socket configuration object, and a set of methods for operating on the attributes. It is also used to create an overlay socket or java.net.MulticastSocket interface with a socket matching its stored attributs.


Field Summary
static java.lang.String CONFIG_ATTRIBUTE_OVERLAY_ID
          Xpath string that identified the overlay ID attribute in the configuration file
static java.lang.String CONFIGOBJ_ATTRIBUTE_NAME
          The root attribute name in the configuration document.
 java.io.PrintWriter err
          The opened error file.
static java.lang.String ERRFILE_ATTRIBUTE_NAME
          Xpath string that identifies error log file name attribute.
static java.lang.String LOCALATTRIBUTE_ATTRIBUTE_NAME
          Xpath string that identifies the attribute which specifies the local attributes in the configuration file
 java.io.PrintWriter log
          The opened log file.
static java.lang.String LOGFILE_ATTRIBUTE_NAME
          Xpath string that identifies the log file name attribute.
static java.lang.String NO_FILE
          Name used in properties file to indicate no logFileName or errFileName.
static java.lang.String OVERLAY_SERVER_ATTRIBUTE_NAME
          Xpath string that identifies overlay server attribute in configuration file.
static java.lang.String OVERLAY_SERVER_URL_ATTRIBUTE_NAME
          Xpath string that identifies overlay server address in configuration file.
static java.lang.String OVERLAYHASH_ATTRIBUTE_NAME
          Xpath string that identifies the attribute which specifies the attributes for calculating overlay hash.
static java.lang.String ROOT_ATTRIBUTE_NAME
          The root attribute name in the configuration document.
 java.io.PrintWriter seriousErr
          A PrintWriter guaranteed not to go to a NullWriter (/dev/null).
 
Constructor Summary
HyperCastConfig(org.w3c.dom.Document doc)
          Construct an HyperCastConfig object from given configuration DOM object
HyperCastConfig(java.lang.String configurationFilename)
          Construct an HyperCastConfig object from given configuration file.
HyperCastConfig(java.net.URL serverURL, java.lang.String OverlayId)
          Construct an HyperCastConfig object by downloading the configuration file from overlay server.
 
Method Summary
 boolean booleanFromYesNoString(java.lang.String yesNoString)
           
 void createandsetOverlayId()
          Creates a random overlay ID and sets it into the property Document.
static hypercast.HyperCastConfig createConfig(java.lang.String configurationFilename)
          Creates an overlay configuration object based on the given filename.
 java.net.MulticastSocket createJavaMulticastSocket()
          Creates a new object implementing Java.net.MulticastSocket that sends the messages over a new OL_Socket created using the createSocket function.
 hypercast.MonitorAndControl.I_Monitor createMonitor()
          creates a I_Monitor instance
 hypercast.I_OverlaySocket createOverlaySocket(hypercast.I_ReceiveCallback callback)
          Returns a new OL_Socket object.
 hypercast.I_OverlaySocket createOverlaySocket(hypercast.I_ReceiveCallback callback, hypercast.NotificationHandler nh)
          Returns a new OL_Socket object.
 hypercast.I_OverlaySocket createOverlaySocket(hypercast.I_ReceiveCallback callback, hypercast.NotificationHandler nh, hypercast.I_InterceptionCallback Icb)
          Returns a new OL_Socket object.
 hypercast.MonitorAndControl.I_Portal createPortal(hypercast.I_Stats stats)
          Creates a I_Portal instance
 hypercast.MonitorAndControl.I_Portal createPortal(hypercast.I_Stats stats, java.lang.String statsRoot)
          Creates a I_Portal instance
 boolean doesOverlayExist(java.net.URL serverURL, java.lang.String overlayID)
          Check if the overlay with given overlay ID exists at the server.
 org.w3c.dom.Document DownloadConfig(java.net.URL serverLocation, java.lang.String overlayID)
          This method downloads the property XML file specified by the given overlay ID from the overlay server.
 boolean getBooleanAttribute(org.apache.xpath.XPath attrXpath)
          Gets the value of a boolean attribute.
 boolean getBooleanProperty(java.lang.String attribute)
          Deprecated. use getBooleanAttribute (final XPath attrXpath)
 org.w3c.dom.Document getDocument()
          Return the XML document of this configuration object
 int getIntAttribute(org.apache.xpath.XPath attrXpath)
          Gets the value of an integer attribute.
 int getIntProperty(java.lang.String attribute)
          Deprecated. use getIntAttribute (final XPath attrXpath)
 int getIntProperty(java.lang.String attribute, int defaultValue)
          Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getIntProperty that does not accept a caller provided default value.
 long getLongAttribute(org.apache.xpath.XPath attrXpath)
          Gets the value of an long attribute.
 long getLongProperty(java.lang.String attribute)
          Deprecated. use getLongAttribute (final XPath attrXpath)
 long getLongProperty(java.lang.String attribute, long defaultValue)
          Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getLongProperty that does not accept a caller provided default value.
 int getNonNegativeIntAttribute(org.apache.xpath.XPath attrXpath)
          Gets the value of a non-negative integer attribute.
 int getNonNegativeIntProperty(java.lang.String attribute)
          Deprecated. use getNonNegativeIntAttribute (final XPath attrXpath)
 int getNonNegativeIntProperty(java.lang.String attribute, int defaultValue)
          Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getNonNegativeIntProperty that does not accept a caller provided default value.
 long getNonNegativeLongAttribute(org.apache.xpath.XPath attrXpath)
          Gets the value of a non-negative long attribute.
 long getNonNegativeLongProperty(java.lang.String attribute)
          Deprecated. use getNonNegativeLongAttribute (final XPath attrXpath)
 long getNonNegativeLongProperty(java.lang.String attribute, long defaultValue)
          Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getNonNegativeLongProperty that does not accept a caller provided default value.
 short getNonNegativeShortAttribute(org.apache.xpath.XPath attrXpath)
          Gets the value of a non-negative short attribute.
 short getNonNegativeShortProperty(java.lang.String attribute)
          Deprecated. use getNonNegativeShortAttribute (final XPath attrXpath)
 short getNonNegativeShortProperty(java.lang.String attribute, short defaultValue)
          Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getNonNegativeShortProperty that does not accept a caller provided default value.
 int getOverlayHash()
          Returns the hash calculated from overlay hash attributes.
 int getPositiveIntAttribute(org.apache.xpath.XPath attrXpath)
          Gets the value of a positive integer attribute.
 int getPositiveIntProperty(java.lang.String attribute)
          Deprecated. use getPositiveIntAttribute (final XPath attrXpath)
 int getPositiveIntProperty(java.lang.String attribute, int defaultValue)
          Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getPositiveIntProperty that does not accept a caller provided default value.
 long getPositiveLongAttribute(org.apache.xpath.XPath attrXpath)
          Gets the value of a positive long attribute.
 long getPositiveLongProperty(java.lang.String attribute)
          Deprecated. use getPositiveLongAttribute (final XPath attrXpath)
 long getPositiveLongProperty(java.lang.String attribute, long defaultValue)
          Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getPositiveLongProperty that does not accept a caller provided default value.
 short getPositiveShortAttribute(org.apache.xpath.XPath attrXpath)
          Gets the value of a positive short attribute.
 short getPositiveShortProperty(java.lang.String attribute)
          Deprecated. use getPositiveShortAttribute (final XPath attrXpath)
 short getPositiveShortProperty(java.lang.String attribute, short defaultValue)
          Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getPositiveShortProperty that does not accept a caller provided default value.
 org.w3c.dom.Document getPrivateConfiguration()
          Return the private configuration property document contained in this HyperCastConfig instance.
 java.lang.String getPrivateTextAttribute(org.apache.xpath.XPath attrXpath)
           
 java.lang.String getProperty(java.lang.String name)
          Deprecated. use getTextAttribute(final XPath attrXpath).
 org.w3c.dom.Document getPublicConfiguration()
          Return the public configuration property document contained in this HyperCastConfig instance.
 org.w3c.dom.Element[] getReadSchema(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath)
          Return the schema element which represents the root of the sub-tree, specified by the given xpath, in read schema tree.
 short getShortAttribute(org.apache.xpath.XPath attrXpath)
          Gets the value of an short attribute.
 short getShortProperty(java.lang.String attribute)
          Deprecated. use getShortAttribute (final XPath attrXpath)
 short getShortProperty(java.lang.String attribute, short defaultValue)
          Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getShortProperty that does not accept a caller provided default value.
 org.w3c.dom.Element[] getStats(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath)
          Return the result of query for the statistics specified by the given xpath.
 java.lang.String getStatsName()
          Gets the element name of this I_Stats instance.
 java.lang.String getStringProperty(java.lang.String attribute)
          Deprecated. use getTextAttribute (final XPath attrXpath)
 java.lang.String getStringProperty(java.lang.String attribute, java.lang.String defaultValue)
          Deprecated. Default values are stored in the HyperCast XML It is possible that this method should be deprecated, but the jury is still out. Ideally the default value should be extracted from the HyperCast XML Schema file. However, there is some debate (Nov 2004) about what to do when an attribute value is not defined in a configuration file and that attribute has no "natural" default.
 java.lang.String getTextAttribute(org.apache.xpath.XPath attrXpath)
           
 java.net.URL getURLAttribute(org.apache.xpath.XPath xpath)
           
 org.w3c.dom.Element[] getWriteSchema(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath)
          Return the schema element which represents the root of the sub-tree, specified by the given xpath, in write schema tree.
static int hash(byte[] array)
          Generates a hash of a byte array for the generateOverlayHash function.
 void MergeConfig(org.w3c.dom.Document fromDOM)
          Merges the downloaded configuration file with local property file.
 int setOverlayHash()
          Creates hash from overlay hash attributes.
 void setOverlayID(java.lang.String overlayid)
          Set the overlay ID of this HyperCastConfig instance to given value.
 void setPrivateTextAttribute(org.apache.xpath.XPath xpath, java.lang.String value)
          Sets the value of private scalar string attribute.
 org.w3c.dom.Element[] setStats(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath, org.w3c.dom.Element newValue)
          Set the statistics specified by the given xpath.
 void setStatsName(java.lang.String name)
          Assigns a name to this I_Stats instance.
 void setTextAttribute(org.apache.xpath.XPath xpath, java.lang.String value)
          Sets the value of scalar string attribute.
 boolean testIfAttributeIsDefined(org.apache.xpath.XPath attrXpath)
          Returns true if the given attribute is defined in the configuration Document.
 java.lang.String UploadConfig(java.net.URL serverLocation)
          This method uploads the property XML file to the overlay server.
 boolean validatePublicConfig(java.lang.String XSDfilename)
          Returns true if the given attribute is defined in the configuration Document.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT_ATTRIBUTE_NAME

public static final java.lang.String ROOT_ATTRIBUTE_NAME
The root attribute name in the configuration document.

See Also:
Constant Field Values

CONFIG_ATTRIBUTE_OVERLAY_ID

public static final java.lang.String CONFIG_ATTRIBUTE_OVERLAY_ID
Xpath string that identified the overlay ID attribute in the configuration file

See Also:
Constant Field Values

LOCALATTRIBUTE_ATTRIBUTE_NAME

public static final java.lang.String LOCALATTRIBUTE_ATTRIBUTE_NAME
Xpath string that identifies the attribute which specifies the local attributes in the configuration file

See Also:
Constant Field Values

OVERLAY_SERVER_ATTRIBUTE_NAME

public static final java.lang.String OVERLAY_SERVER_ATTRIBUTE_NAME
Xpath string that identifies overlay server attribute in configuration file.

See Also:
Constant Field Values

OVERLAY_SERVER_URL_ATTRIBUTE_NAME

public static final java.lang.String OVERLAY_SERVER_URL_ATTRIBUTE_NAME
Xpath string that identifies overlay server address in configuration file.

See Also:
Constant Field Values

OVERLAYHASH_ATTRIBUTE_NAME

public static final java.lang.String OVERLAYHASH_ATTRIBUTE_NAME
Xpath string that identifies the attribute which specifies the attributes for calculating overlay hash.

See Also:
Constant Field Values

LOGFILE_ATTRIBUTE_NAME

public static final java.lang.String LOGFILE_ATTRIBUTE_NAME
Xpath string that identifies the log file name attribute.

See Also:
Constant Field Values

ERRFILE_ATTRIBUTE_NAME

public static final java.lang.String ERRFILE_ATTRIBUTE_NAME
Xpath string that identifies error log file name attribute.

See Also:
Constant Field Values

CONFIGOBJ_ATTRIBUTE_NAME

public static final java.lang.String CONFIGOBJ_ATTRIBUTE_NAME
The root attribute name in the configuration document.

See Also:
Constant Field Values

NO_FILE

public static final java.lang.String NO_FILE
Name used in properties file to indicate no logFileName or errFileName.

See Also:
Constant Field Values

log

public java.io.PrintWriter log
The opened log file.


err

public java.io.PrintWriter err
The opened error file.


seriousErr

public java.io.PrintWriter seriousErr
A PrintWriter guaranteed not to go to a NullWriter (/dev/null).

Constructor Detail

HyperCastConfig

public HyperCastConfig(org.w3c.dom.Document doc)
Construct an HyperCastConfig object from given configuration DOM object

Parameters:
doc -

HyperCastConfig

public HyperCastConfig(java.lang.String configurationFilename)
Construct an HyperCastConfig object from given configuration file.

Parameters:
configurationFilename - configuration file name.

HyperCastConfig

public HyperCastConfig(java.net.URL serverURL,
                       java.lang.String OverlayId)
Construct an HyperCastConfig object by downloading the configuration file from overlay server.

Parameters:
serverURL - URL instance representing the address of the overlay server.
OverlayId - string representing the overlay ID.
Method Detail

getDocument

public org.w3c.dom.Document getDocument()
Return the XML document of this configuration object


createOverlaySocket

public hypercast.I_OverlaySocket createOverlaySocket(hypercast.I_ReceiveCallback callback)
Returns a new OL_Socket object.


createOverlaySocket

public hypercast.I_OverlaySocket createOverlaySocket(hypercast.I_ReceiveCallback callback,
                                                     hypercast.NotificationHandler nh)
Returns a new OL_Socket object.


createOverlaySocket

public hypercast.I_OverlaySocket createOverlaySocket(hypercast.I_ReceiveCallback callback,
                                                     hypercast.NotificationHandler nh,
                                                     hypercast.I_InterceptionCallback Icb)
Returns a new OL_Socket object.


createMonitor

public hypercast.MonitorAndControl.I_Monitor createMonitor()
creates a I_Monitor instance


createPortal

public hypercast.MonitorAndControl.I_Portal createPortal(hypercast.I_Stats stats,
                                                         java.lang.String statsRoot)
Creates a I_Portal instance


createPortal

public hypercast.MonitorAndControl.I_Portal createPortal(hypercast.I_Stats stats)
Creates a I_Portal instance


createJavaMulticastSocket

public java.net.MulticastSocket createJavaMulticastSocket()
Creates a new object implementing Java.net.MulticastSocket that sends the messages over a new OL_Socket created using the createSocket function.

See Also:
createOverlaySocket(hypercast.I_ReceiveCallback), MulticastSocketMasquerade

createConfig

public static hypercast.HyperCastConfig createConfig(java.lang.String configurationFilename)
Creates an overlay configuration object based on the given filename. It is called from application code.

Parameters:
configurationFilename - The name of the configuration file used to construct the property database, cannot be null or empty.
Returns:
A configuration object that contains the contents of the given configuration file.
Throws:
HyperCastConfigException - when configuration filename is not valid or construction of HyperCastConfig instance fails;

doesOverlayExist

public boolean doesOverlayExist(java.net.URL serverURL,
                                java.lang.String overlayID)
Check if the overlay with given overlay ID exists at the server.

Parameters:
serverURL - URL instance representing the address of overlay server.
overlayID - String representing the identifier of an overlay.
Throws:
java.lang.IllegalStateException - if overlay server property was not set or was set incorrectly.

UploadConfig

public java.lang.String UploadConfig(java.net.URL serverLocation)
This method uploads the property XML file to the overlay server. If the uploaded property XMl document cintains overlay ID, the overlay ID is returned by the overlay server; if , the uploaded property XMl document doesn't contain an overlay ID, the overlay server will create one and return it.

Parameters:
serverLocation - URL instance representing the address of the overlay server.
Throws:
java.lang.IllegalStateException - if overlay server property was not set or was set incorrectly.
HyperCastFatalRuntimeException - if overlay server cannot be connected or ERROR reply is returned by the overlay server.

DownloadConfig

public org.w3c.dom.Document DownloadConfig(java.net.URL serverLocation,
                                           java.lang.String overlayID)
This method downloads the property XML file specified by the given overlay ID from the overlay server.

Parameters:
serverLocation - URL instance representing the address of the overlay server.
overlayID - the overlay ID which specifies the XML configuration file to download.
Throws:
java.lang.IllegalStateException - if overlay server property was not set or was set incorrectly.
HyperCastFatalRuntimeException - if overlay server cannot be connected or ERROR reply is returned by the overlay server.

MergeConfig

public void MergeConfig(org.w3c.dom.Document fromDOM)
Merges the downloaded configuration file with local property file. If overlay server is not used, this method does nothing.


getPublicConfiguration

public org.w3c.dom.Document getPublicConfiguration()
Return the public configuration property document contained in this HyperCastConfig instance.


getPrivateConfiguration

public org.w3c.dom.Document getPrivateConfiguration()
Return the private configuration property document contained in this HyperCastConfig instance.


setOverlayID

public void setOverlayID(java.lang.String overlayid)
Set the overlay ID of this HyperCastConfig instance to given value.


validatePublicConfig

public boolean validatePublicConfig(java.lang.String XSDfilename)
Returns true if the given attribute is defined in the configuration Document. Returns false otherwise.


testIfAttributeIsDefined

public boolean testIfAttributeIsDefined(org.apache.xpath.XPath attrXpath)
Returns true if the given attribute is defined in the configuration Document. Returns false otherwise.


getProperty

public java.lang.String getProperty(java.lang.String name)
Deprecated. use getTextAttribute(final XPath attrXpath).

Returns:
the value of attribute in string format.

getStringProperty

public java.lang.String getStringProperty(java.lang.String attribute,
                                          java.lang.String defaultValue)
Deprecated. Default values are stored in the HyperCast XML It is possible that this method should be deprecated, but the jury is still out. Ideally the default value should be extracted from the HyperCast XML Schema file. However, there is some debate (Nov 2004) about what to do when an attribute value is not defined in a configuration file and that attribute has no "natural" default.

Returns:
a string property; a default value is returned if this property was not specified in the configuration file.

getStringProperty

public java.lang.String getStringProperty(java.lang.String attribute)
Deprecated. use getTextAttribute (final XPath attrXpath)

Returns:
a string property; a default value is returned if this property was not specified in the configuration file.

getTextAttribute

public java.lang.String getTextAttribute(org.apache.xpath.XPath attrXpath)
Returns:
a string property; a default value is returned if this property was not specified in the configuration file.

setTextAttribute

public void setTextAttribute(org.apache.xpath.XPath xpath,
                             java.lang.String value)
Sets the value of scalar string attribute.


getPrivateTextAttribute

public java.lang.String getPrivateTextAttribute(org.apache.xpath.XPath attrXpath)
Returns:
a string private attribute. No default value is defined for a private attribute.

setPrivateTextAttribute

public void setPrivateTextAttribute(org.apache.xpath.XPath xpath,
                                    java.lang.String value)
Sets the value of private scalar string attribute. If the given attribute (specified by the xpath) doesn't exist, create it.


getIntProperty

public int getIntProperty(java.lang.String attribute,
                          int defaultValue)
Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getIntProperty that does not accept a caller provided default value.

Gets the value of an integer attribute. A caller provided default value is returned if no value for this attribute was specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as an integer.

getIntProperty

public int getIntProperty(java.lang.String attribute)
Deprecated. use getIntAttribute (final XPath attrXpath)

Gets the value of an integer attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as an integer.

getIntAttribute

public int getIntAttribute(org.apache.xpath.XPath attrXpath)
Gets the value of an integer attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as an integer.

getNonNegativeIntProperty

public int getNonNegativeIntProperty(java.lang.String attribute,
                                     int defaultValue)
Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getNonNegativeIntProperty that does not accept a caller provided default value.

Gets the value of a non-negative integer attribute. A caller provided default value is returned if no value for this attribute was specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a non-negative integer.
HyperCastFatalRuntimeException - if the caller provided default value is not non-negative.

getNonNegativeIntProperty

public int getNonNegativeIntProperty(java.lang.String attribute)
Deprecated. use getNonNegativeIntAttribute (final XPath attrXpath)

Gets the value of a non-negative integer attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a non-negative integer.

getNonNegativeIntAttribute

public int getNonNegativeIntAttribute(org.apache.xpath.XPath attrXpath)
Gets the value of a non-negative integer attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a non-negative integer.

getPositiveIntProperty

public int getPositiveIntProperty(java.lang.String attribute,
                                  int defaultValue)
Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getPositiveIntProperty that does not accept a caller provided default value.

Gets the value of a positive integer attribute. A caller provided default value is returned if no value for this attribute was specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a postive integer.
HyperCastFatalRuntimeException - if the caller provided default value is not positive.

getPositiveIntProperty

public int getPositiveIntProperty(java.lang.String attribute)
Deprecated. use getPositiveIntAttribute (final XPath attrXpath)

Gets the value of a positive integer attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a positive integer.

getPositiveIntAttribute

public int getPositiveIntAttribute(org.apache.xpath.XPath attrXpath)
Gets the value of a positive integer attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a positive integer.

getShortProperty

public short getShortProperty(java.lang.String attribute,
                              short defaultValue)
Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getShortProperty that does not accept a caller provided default value.

Gets the value of an short attribute. A caller provided default value is returned if no value for this attribute was specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as an short.

getShortProperty

public short getShortProperty(java.lang.String attribute)
Deprecated. use getShortAttribute (final XPath attrXpath)

Gets the value of an short attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as an short.

getShortAttribute

public short getShortAttribute(org.apache.xpath.XPath attrXpath)
Gets the value of an short attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as an short.

getNonNegativeShortProperty

public short getNonNegativeShortProperty(java.lang.String attribute,
                                         short defaultValue)
Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getNonNegativeShortProperty that does not accept a caller provided default value.

Gets the value of a non-negative short attribute. A caller provided default value is returned if no value for this attribute was specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a non-negative short.
HyperCastFatalRuntimeException - if the caller provided default value is not non-negative.

getNonNegativeShortProperty

public short getNonNegativeShortProperty(java.lang.String attribute)
Deprecated. use getNonNegativeShortAttribute (final XPath attrXpath)

Gets the value of a non-negative short attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a non-negative short.

getNonNegativeShortAttribute

public short getNonNegativeShortAttribute(org.apache.xpath.XPath attrXpath)
Gets the value of a non-negative short attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a non-negative short.

getPositiveShortProperty

public short getPositiveShortProperty(java.lang.String attribute,
                                      short defaultValue)
Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getPositiveShortProperty that does not accept a caller provided default value.

Gets the value of a positive short attribute. A caller provided default value is returned if no value for this attribute was specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a postive short.
HyperCastFatalRuntimeException - if the caller provided default value is not positive.

getPositiveShortProperty

public short getPositiveShortProperty(java.lang.String attribute)
Deprecated. use getPositiveShortAttribute (final XPath attrXpath)

Gets the value of a positive short attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a positive short.

getPositiveShortAttribute

public short getPositiveShortAttribute(org.apache.xpath.XPath attrXpath)
Gets the value of a positive short attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a positive short.

getLongProperty

public long getLongProperty(java.lang.String attribute,
                            long defaultValue)
Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getLongProperty that does not accept a caller provided default value.

Gets the value of an long attribute. A caller provided default value is returned if no value for this attribute was specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as an long.

getLongProperty

public long getLongProperty(java.lang.String attribute)
Deprecated. use getLongAttribute (final XPath attrXpath)

Gets the value of an long attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as an long.

getLongAttribute

public long getLongAttribute(org.apache.xpath.XPath attrXpath)
Gets the value of an long attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as an long.

getNonNegativeLongProperty

public long getNonNegativeLongProperty(java.lang.String attribute,
                                       long defaultValue)
Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getNonNegativeLongProperty that does not accept a caller provided default value.

Gets the value of a non-negative long attribute. A caller provided default value is returned if no value for this attribute was specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a non-negative long.
HyperCastFatalRuntimeException - if the caller provided default value is not non-negative.

getNonNegativeLongProperty

public long getNonNegativeLongProperty(java.lang.String attribute)
Deprecated. use getNonNegativeLongAttribute (final XPath attrXpath)

Gets the value of a non-negative long attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a non-negative long.

getNonNegativeLongAttribute

public long getNonNegativeLongAttribute(org.apache.xpath.XPath attrXpath)
Gets the value of a non-negative long attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a non-negative long.

getPositiveLongProperty

public long getPositiveLongProperty(java.lang.String attribute,
                                    long defaultValue)
Deprecated. Default values are stored in the HyperCast XML Schema file which acts as a centralized repository for default values. By using the defaults stored in the XML Schema file, constants or "magic numbers" are not spread throughout the code. Use a version of getPositiveLongProperty that does not accept a caller provided default value.

Gets the value of a positive long attribute. A caller provided default value is returned if no value for this attribute was specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a postive long.
HyperCastFatalRuntimeException - if the caller provided default value is not positive.

getPositiveLongProperty

public long getPositiveLongProperty(java.lang.String attribute)
Deprecated. use getPositiveLongAttribute (final XPath attrXpath)

Gets the value of a positive long attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a positive long.

getPositiveLongAttribute

public long getPositiveLongAttribute(org.apache.xpath.XPath attrXpath)
Gets the value of a positive long attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a positive long.

getBooleanProperty

public boolean getBooleanProperty(java.lang.String attribute)
Deprecated. use getBooleanAttribute (final XPath attrXpath)

Gets the value of a boolean attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a boolean. Note that Boolean.valueOf is not used here because it always returns either true or false regardless of the value of the string, for instance "foo" would result in false.

getBooleanAttribute

public boolean getBooleanAttribute(org.apache.xpath.XPath attrXpath)
Gets the value of a boolean attribute. A default value from the XML schema file is returned if this attribute was not specified in the configuration file.

Throws:
HyperCastConfigException - if the configured value cannot be parsed as a boolean. Note that Boolean.valueOf is not used here because it always returns either true or false regardless of the value of the string, for instance "foo" would result in false.

booleanFromYesNoString

public boolean booleanFromYesNoString(java.lang.String yesNoString)

getURLAttribute

public java.net.URL getURLAttribute(org.apache.xpath.XPath xpath)
Returns:
a URL property; a default value is returned if this property was not specified in the configuration file.

createandsetOverlayId

public void createandsetOverlayId()
Creates a random overlay ID and sets it into the property Document.


getOverlayHash

public int getOverlayHash()
Returns the hash calculated from overlay hash attributes. This is a used to determine if two messages are from the same Overlay.


setOverlayHash

public int setOverlayHash()
Creates hash from overlay hash attributes. This is a used to determine if two messages are from the same Overlay.


hash

public static int hash(byte[] array)
Generates a hash of a byte array for the generateOverlayHash function. I could just use Java's hashCode for a string object, but I wanted something that would be available to any other implementation language.


getStatsName

public java.lang.String getStatsName()
Description copied from interface: I_Stats
Gets the element name of this I_Stats instance. The element name is originally assigned from the attribute StstsName in the configuration file, and can be changed by this method.

Specified by:
getStatsName in interface I_Stats
See Also:
I_Stats.getStatsName()

setStatsName

public void setStatsName(java.lang.String name)
Description copied from interface: I_Stats
Assigns a name to this I_Stats instance. The assigned name becomes the tag of the element associated to this I_Stats instance on the statistics tree.

Specified by:
setStatsName in interface I_Stats
Parameters:
name - the name assigned to the I_Stats instance.
See Also:
I_Stats.setStatsName(String)

getStats

public org.w3c.dom.Element[] getStats(org.w3c.dom.Document doc,
                                      org.apache.xpath.XPath xpath)
                               throws HyperCastStatsException
Return the result of query for the statistics specified by the given xpath.

Specified by:
getStats in interface I_Stats
Parameters:
doc - Document used for create new elements or nodes.
xpath - XPath instance represents the statistics to be queried.
Throws:
HyperCastStatsException - If the xpath does not specify a valid subtree.
See Also:
I_Stats.getStats(org.w3c.dom.Document, org.apache.xpath.XPath)

setStats

public org.w3c.dom.Element[] setStats(org.w3c.dom.Document doc,
                                      org.apache.xpath.XPath xpath,
                                      org.w3c.dom.Element newValue)
                               throws HyperCastStatsException
Set the statistics specified by the given xpath. The value actually set is returned.

Specified by:
setStats in interface I_Stats
Parameters:
doc - Document used for create new elements or nodes.
xpath - XPath instance represents the statistics to be queried.
newValue - Element representing the value or sub-tree to be set.
Throws:
HyperCastStatsException - If the xpath does not specify a valid subtree or if any part of the the subtree is read-only, or if the newValue does not conform with the expected format.
See Also:
I_Stats.setStats(org.w3c.dom.Document, org.apache.xpath.XPath, org.w3c.dom.Element)

getReadSchema

public org.w3c.dom.Element[] getReadSchema(org.w3c.dom.Document doc,
                                           org.apache.xpath.XPath xpath)
                                    throws HyperCastStatsException
Return the schema element which represents the root of the sub-tree, specified by the given xpath, in read schema tree.

Specified by:
getReadSchema in interface I_Stats
Parameters:
doc - Document used for create new elements or nodes.
xpath - XPath instance representing the statistics which is the root of the sub-tree to be queried.
Throws:
HyperCastStatsException - If some part of the specified subtree does not correctly implement this interface method.
See Also:
I_Stats.getReadSchema(Document, XPath)

getWriteSchema

public org.w3c.dom.Element[] getWriteSchema(org.w3c.dom.Document doc,
                                            org.apache.xpath.XPath xpath)
                                     throws HyperCastStatsException
Return the schema element which represents the root of the sub-tree, specified by the given xpath, in write schema tree.

Specified by:
getWriteSchema in interface I_Stats
Parameters:
doc - Document used for create new elements or nodes.
xpath - XPath instance representing the statistics which is the root of the sub-tree to be queried.
Throws:
HyperCastStatsException - If some part of the specified subtree does not correctly implement this interface method.
See Also:
I_Stats.getWriteSchema(Document, XPath)