|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.bea.document.XMLUtils
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 |
public XMLUtils()
Method Detail |
public static final Calendar getCalendarFromXMLDate(String strXMLDate) throws IllegalArgumentException
strXMLDate
into a Java Calendar object
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
IllegalArgumentException
- if strXMLDate
is not a valid
date according to the XML schema specification.public static final String getXMLDateFromCalendar(Calendar cal)
cal
cal
- - a Java Calendar; must not be null
IllegalArgumentException
- if the argument is nullpublic static final Calendar getCalendarFromXMLDateTime(String strXMLDateTime) throws IllegalArgumentException
strXMLDateTime
into a Java Calendar object
IllegalArgumentException
- if strXMLDate
is not a valid
date according to the XML schema specification.public static final String getXMLDateTimeFromCalendar(Calendar cal)
public static final Calendar getCalendarFromXMLTime(String strXMLTime) throws IllegalArgumentException
strXMLTime
into a Java Calendar object
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
IllegalArgumentException
- if strXMLDate
is not a valid
date according to the XML schema specification.public static final String getXMLTimeFromCalendar(Calendar cal)
cal
cal
- - a Java Calendar; must not be null
IllegalArgumentException
- if the argument is nullpublic static String decodeXML(String encoded)
encoded
- - The encoded XML document.
public static String encodeXML(String s)
s
- - The XML document to encode.
public static String encodeXML(String s, boolean canonical)
s
- - The XML document to encode.canonical
- - If true \n and \r are encoded as public static boolean isTextEmpty(Text text)
text
- - the Text node to test
public static String translateXMLString(String value)
encodeXML()
.
value
- XML string to be encoded
public static void writeIndent(Writer writer, int indent) throws IOException
IOException
public static void saveElement(Writer writer, int indent, String name, String value) throws IOException
IOException
public static void saveElement(Writer writer, int indent, String name, String[][] attributes, String value) throws IOException
IOException
public static void saveElement(Writer writer, int indent, String name, boolean bEnd) throws IOException
IOException
public static void saveElement(Writer writer, int indent, String name, String[][] attributes, boolean bEnd) throws IOException
IOException
public static void serializeXMLNode(Writer writer, int indent, Node node) throws IOException
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.
IOException
public static String XMLtoString(Document document) throws IOException
StringWriter out = new StringWriter(); serializeXML(document, out);
document
- the document to be serialized
IOException
public static void serializeXML(Document document, Writer writer) throws IOException
document
- the document to be serialized
IOException
public static void serializeXML(Document document, Writer writer, String encoding) throws IOException
document
- the document to be serialized
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |