Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.document
Class XMLUtils

    java.lang.Object
      com.bea.document.XMLUtils

public class XMLUtils
extends Object

The XMLUtils class contains utility methods used to work with XML documents.

Constructor Summary
`XMLUtils()`

Method Summary
`static String` | `decodeXML(String encoded)` Decode XML markup characters (< > & " ' &#;).
`static String` | `encodeXML(String s)` Encode XML markup characters (< > & " ').
`static String` | `encodeXML(String s, boolean canonical)` Encode XML markup characters (< > & " ').
`static Calendar` | `getCalendarFromXMLDate(String strXMLDate)` Parses `strXMLDate` into a Java Calendar object
`static Calendar` | `getCalendarFromXMLDateTime(String strXMLDateTime)` Parses `strXMLDateTime` into a Java Calendar object
`static Calendar` | `getCalendarFromXMLTime(String strXMLTime)` Parses `strXMLTime` into a Java Calendar object
`static String` | `getXMLDateFromCalendar(Calendar cal)` Returns the XML date representation for a Calendar object `cal`
`static String` | `getXMLDateTimeFromCalendar(Calendar cal)`
`static String` | `getXMLTimeFromCalendar(Calendar cal)` Returns the XML time representation for a Calendar object `cal`
`static boolean` | `isTextEmpty(Text text)` Test if a Text node is empty (contains only whitespace)
`static void` | `saveElement(Writer writer, int indent, String name, boolean bEnd)`
`static void` | `saveElement(Writer writer, int indent, String name, String value)`
`static void` | `saveElement(Writer writer, int indent, String name, String[][] attributes, boolean bEnd)`
`static void` | `saveElement(Writer writer, int indent, String name, String[][] attributes, String value)`
`static void` | `serializeXML(Document document, Writer writer)` Serialize (write to storage) a W3C DOM Document
`static void` | `serializeXML(Document document, Writer writer, String encoding)` Serialize (write to storage) a W3C DOM Document
`static void` | `serializeXMLNode(Writer writer, int indent, Node node)` Serializes (write to storage) an XML node and its descendents.
`static String` | `translateXMLString(String value)` Deprecated. superceded by `encodeXML()`.
`static void` | `writeIndent(Writer writer, int indent)`
`static String` | `XMLtoString(Document document)` Serialize (write to storage) a W3C DOM Document.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### XMLUtils

    public XMLUtils()

Method Detail

### getCalendarFromXMLDate

    public static final Calendar getCalendarFromXMLDate(String strXMLDate)
                                                 throws IllegalArgumentException

  Parses `strXMLDate` into a Java Calendar object

  Parameters:
    `strXMLDate` - - a non-null Gregorian calendar date; the following formats are valid according to the XML Schema specification: CCYY-MM-DD CCYY-MM-DDZ CCYY-MM-DD-hh:mm CCYY-MM-DD+hh:mm CCYY-MM-DD-hh CCYY-MM-DD+hh XX..XCCYY-MM-DD, for dates beyond 9999 -CCYY..., for dates before 0 AD
  Returns:
    a Java Calendar
  Throws:
    `IllegalArgumentException` - if `strXMLDate` is not a valid date according to the XML schema specification.

### getXMLDateFromCalendar

    public static final String getXMLDateFromCalendar(Calendar cal)

  Returns the XML date representation for a Calendar object `cal`

  Parameters:
    `cal` - - a Java Calendar; must not be null
  Returns:
    a String date formatted according to the XML schema specification for the XML date datatype.
  Throws:
    `IllegalArgumentException` - if the argument is null

### getCalendarFromXMLDateTime

    public static final Calendar getCalendarFromXMLDateTime(String strXMLDateTime)
                                                     throws IllegalArgumentException

  Parses `strXMLDateTime` into a Java Calendar object

  Returns:
    a Java Calendar
  Throws:
    `IllegalArgumentException` - if `strXMLDate` is not a valid date according to the XML schema specification.

### getXMLDateTimeFromCalendar

    public static final String getXMLDateTimeFromCalendar(Calendar cal)

### getCalendarFromXMLTime

    public static final Calendar getCalendarFromXMLTime(String strXMLTime)
                                                 throws IllegalArgumentException

  Parses `strXMLTime` into a Java Calendar object

  Parameters:
    `strXMLTime` - - a non-null Gregorian calendar time; the following formats are valid according to the XML Schema specification: hh:mm:ss hh:mm:ssZ hh:mm:ss.sss hh:mm:ss.sssZ hh:mm:ss+hh:mm hh:mm:ss-hh:mm hh:mm:ss+hh hh:mm:ss-hh hh:mm:ss.sss+hh:mm hh:mm:ss.sss-hh:mm hh:mm:ss.sss+hh hh:mm:ss.sss-hh
  Returns:
    a Java Calendar
  Throws:
    `IllegalArgumentException` - if `strXMLDate` is not a valid date according to the XML schema specification.

### getXMLTimeFromCalendar

    public static final String getXMLTimeFromCalendar(Calendar cal)

  Returns the XML time representation for a Calendar object `cal`

  Parameters:
    `cal` - - a Java Calendar; must not be null
  Returns:
    a String time formatted according to the XML schema specification for the XML time datatype.
  Throws:
    `IllegalArgumentException` - if the argument is null

### decodeXML

    public static String decodeXML(String encoded)

  Decode XML markup characters (< > & " ' &#;).

  Parameters:
    `encoded` - - The encoded XML document.
  Returns:
    A decoded XML document.

### encodeXML

    public static String encodeXML(String s)

  Encode XML markup characters (< > & " ').

  Parameters:
    `s` - - The XML document to encode.
  Returns:
    A encoded XML document.

### encodeXML

    public static String encodeXML(String s,
                                   boolean canonical)

  Encode XML markup characters (< > & " ').

  Parameters:
    `s` - - The XML document to encode.
    `canonical` - - If true \n and \r are encoded as &#;
  Returns:
    A encoded XML document.

### isTextEmpty

    public static boolean isTextEmpty(Text text)

  Test if a Text node is empty (contains only whitespace)

  Parameters:
    `text` - - the Text node to test
  Returns:
    - true if Text node is null or contains only whitespace; false otherwise.

### translateXMLString

    public static String translateXMLString(String value)

  Deprecated. superceded by `encodeXML()`.

  Encode XML String.

  Parameters:
    `value` - XML string to be encoded
  Returns:
    encoded XML

### writeIndent

    public static void writeIndent(Writer writer,
                                   int indent)
                            throws IOException

  Throws:
    `IOException`

### saveElement

    public static void saveElement(Writer writer,
                                   int indent,
                                   String name,
                                   String value)
                            throws IOException

  Throws:
    `IOException`

### saveElement

    public static void saveElement(Writer writer,
                                   int indent,
                                   String name,
                                   String[][] attributes,
                                   String value)
                            throws IOException

  Throws:
    `IOException`

### saveElement

    public static void saveElement(Writer writer,
                                   int indent,
                                   String name,
                                   boolean bEnd)
                            throws IOException

  Throws:
    `IOException`

### saveElement

    public static void saveElement(Writer writer,
                                   int indent,
                                   String name,
                                   String[][] attributes,
                                   boolean bEnd)
                            throws IOException

  Throws:
    `IOException`

### serializeXMLNode

    public static void serializeXMLNode(Writer writer,
                                        int indent,
                                        Node node)
                                 throws IOException

  Serializes (write to storage) an XML node and its descendents.

  Parameters:
    `writer` - The stream to write the serialized representation of an XML element and its descendents.
    `indent` - The number of spaces to indent XML elements.
    `node` - A node to serialize, along with its attributes, and its descendents.
  Throws:
    `IOException`

### XMLtoString

    public static String XMLtoString(Document document)
                              throws IOException

  Serialize (write to storage) a W3C DOM Document. Same as:

           StringWriter out = new StringWriter();
           serializeXML(document, out);

  Parameters:
    `document` - the document to be serialized
  Returns:
    xml in string format
  Throws:
    `IOException`

### serializeXML

    public static void serializeXML(Document document,
                                    Writer writer)
                             throws IOException

  Serialize (write to storage) a W3C DOM Document

  Parameters:
    `document` - the document to be serialized
  Returns:
    xml in string format
  Throws:
    `IOException`

### serializeXML

    public static void serializeXML(Document document,
                                    Writer writer,
                                    String encoding)
                             throws IOException

  Serialize (write to storage) a W3C DOM Document

  Parameters:
    `document` - the document to be serialized
  Returns:
    xml in string format
  Throws:
    `IOException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD