ABLE 2.0.0 07/02/2003 10:25:01

com.ibm.conversation.base
Class XmlParsingUtils

java.lang.Object
  |
  +--com.ibm.conversation.base.XmlParsingUtils

public class XmlParsingUtils
extends java.lang.Object

Class XmlParsingUtils provides a few convenience functions used in parsing XML files.

These functions are used by CpXmlParser, but they're split out into their own class because they can be applied to general XML documents, not just cpXML docs, and to simplify the already-bloated CpXmlParser class.


Method Summary
static java.lang.String getLeafText(org.w3c.dom.Element element)
          Returns the text inside a leaf element.
static void main(java.lang.String[] args)
          Runs a sequence of unit tests on the functions defined in this class.
static long millisFromDuration(java.lang.String durationString)
          Converts an xs:duration string to milliseconds, using the current System Date as starting Date.
static long millisFromDuration(java.lang.String durationString, java.util.Date startDate)
          Converts an xs:duration string to milliseconds, as measured from the given Date.
static void testMillisFromDuration(java.lang.String durString)
          Runs a unit test of the millisFromDuration() function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLeafText

public static java.lang.String getLeafText(org.w3c.dom.Element element)
Returns the text inside a leaf element.

This method assumes that the arg is indeed a leaf (i.e., there are no other elements inside it) and that there is indeed text inside it.

Parameters:
element - The leaf element.
Returns:
The text inside the leaf element.

millisFromDuration

public static long millisFromDuration(java.lang.String durationString)
Converts an xs:duration string to milliseconds, using the current System Date as starting Date.

The starting Date makes a difference only when the duration string specifies some number of years and/or months, since the number of days per month is not constant.

Parameters:
durationString - The xs:duration string.
Returns:
The number of milliseconds represented by that duration.

millisFromDuration

public static long millisFromDuration(java.lang.String durationString,
                                      java.util.Date startDate)
Converts an xs:duration string to milliseconds, as measured from the given Date.

The starting Date makes a difference only when the duration string specifies some number of years and/or months, since the number of days per month is not constant.

Parameters:
durationString - The xs:duration string.
startDate - The Date to use as starting Date.
Returns:
The number of milliseconds represented by that duration.

main

public static void main(java.lang.String[] args)
Runs a sequence of unit tests on the functions defined in this class.

Parameters:
args - The command-line args. Not used.

testMillisFromDuration

public static void testMillisFromDuration(java.lang.String durString)
Runs a unit test of the millisFromDuration() function.

Calculates the milliseconds and prints both duration string and milliseconds on standard output.

Parameters:
durString - The duration string to convert to milliseconds.

ABLE 2.0.0 07/02/2003 10:25:01

(C) Copyright IBM Corporation 1999, 2003