net.groboclown.util.xml.v1
Class XmlUtil

java.lang.Object
  |
  +--net.groboclown.util.xml.v1.XmlUtil

public class XmlUtil
extends Object

A Utility to aid in various XML activities.

Version:
0.9.0 Alpha
Author:
Matt Albrecht

Field Summary
private static char[] IN_RANGE_INVALID
           
private static String IN_RANGE_INVALID_STR
           
private static String[] IN_RANGE_VALID
           
private static char LOWER_RANGE
           
protected static XmlUtil s_instance
           
private static char UPPER_RANGE
           
 
Constructor Summary
protected XmlUtil()
           
 
Method Summary
static XmlUtil getInstance()
           
 String utf2Xml(String javaStr)
          Convert a standard Java String into an XML string.
 void utf2Xml(String javaStr, StringBuffer output)
          Convert a standard Java String into an XML string.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

s_instance

protected static XmlUtil s_instance

LOWER_RANGE

private static final char LOWER_RANGE

UPPER_RANGE

private static final char UPPER_RANGE

IN_RANGE_INVALID

private static final char[] IN_RANGE_INVALID

IN_RANGE_INVALID_STR

private static final String IN_RANGE_INVALID_STR

IN_RANGE_VALID

private static final String[] IN_RANGE_VALID
Constructor Detail

XmlUtil

protected XmlUtil()
Method Detail

getInstance

public static XmlUtil getInstance()

utf2Xml

public String utf2Xml(String javaStr)
Convert a standard Java String into an XML string. It transforms out-of-range characters (<, >, &, ", ', and non-standard character values) into XML formatted values. Since it does correctly escape the quote characters, this may be used for both attribute values as well as standard text.
Parameters:
javaStr - the Java string to be transformed into XML text. If the string is null, then null is returned.
Returns:
the XML version of javaStr.
See Also:
utf2Xml( String, StringBuffer )

utf2Xml

public void utf2Xml(String javaStr,
                    StringBuffer output)
Convert a standard Java String into an XML string. It transforms out-of-range characters (<, >, &, ", ', and non-standard character values) into XML formatted values. Since it does correctly escape the quote characters, this may be used for both attribute values as well as standard text.
Parameters:
javaStr - the Java string to be transformed into XML text. If it is null, then the text "null" is appended to the
output - the StringBuffer to send the transformed XML into.


Written under the LGPL