ccs.xml
Class XUtil

java.lang.Object
  extended by ccs.xml.XUtil

public class XUtil
extends java.lang.Object

Various utility methods for generating and interacting with XML-style markup languages, including HTML.


Method Summary
static java.lang.String attr(java.lang.String name, java.lang.String value)
          Returns a string of the form ¬name="value" where the '¬' character stands for a single space character.
static java.lang.String elem(java.lang.String name, java.lang.String value)
          Return a string of the form <name>value</name>.
static java.lang.String esc(java.lang.String src)
          Returns a markup-friendly version of the source string.
static java.lang.String esc(java.lang.String src, java.lang.String bypass)
          Returns a markup-friendly version of the source string.
static java.lang.String esca(java.lang.String name, boolean value)
          As esca(String, String), except that the value is a boolean to be encoded as a string (either true or false).
static java.lang.String esca(java.lang.String name, int value)
          As esca(String, String), except that the value is an int to be encoded as a string.
static java.lang.String esca(java.lang.String name, long value)
          As esca(String, String), except that the value is a long to be encoded as a string.
static java.lang.String esca(java.lang.String name, java.lang.String value)
          Returns a string of the form ¬name="value" where the '¬' character stands for a single space character.
static java.lang.String esce(java.lang.String name, boolean value)
          Return a string of the form <name>value</name>.
static java.lang.String esce(java.lang.String name, int value)
          Return a string of the form <name>value</name>.
static java.lang.String esce(java.lang.String name, long value)
          Return a string of the form <name>value</name>.
static java.lang.String esce(java.lang.String name, java.lang.String value)
          Return a string of the form <name>value</name>.
static javax.xml.transform.Templates newTemplates(javax.xml.transform.Source xform)
          Returns a new XSLT templates object based on the supplied transform.
static org.xml.sax.XMLReader newXMLReader()
          Returns a new SAX parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newXMLReader

public static org.xml.sax.XMLReader newXMLReader()
Returns a new SAX parser.


newTemplates

public static javax.xml.transform.Templates newTemplates(javax.xml.transform.Source xform)
Returns a new XSLT templates object based on the supplied transform.


esc

public static java.lang.String esc(java.lang.String src,
                                   java.lang.String bypass)
Returns a markup-friendly version of the source string. In this version, various characters which tend to break markup when inserted into it in places where plain text is expected, are expanded into HTML entities, which should be harmless.

Parameters:
src - The source text.
bypass - If not null, any characters in this string will not be escaped.
Returns:
The escaped version.

esc

public static java.lang.String esc(java.lang.String src)
Returns a markup-friendly version of the source string. In this version, various characters which tend to break markup when inserted into it in places where plain text is expected, are expanded into HTML entities, which should be harmless. Equivalent to esc(src, null).

Parameters:
src - The source text.
Returns:
The escaped version.

esca

public static java.lang.String esca(java.lang.String name,
                                    java.lang.String value)
Returns a string of the form ¬name="value" where the '¬' character stands for a single space character. This form is what an XML attribute looks like, which makes this form useful when generating XML documents from data objects. The value string is escaped by passing it through esc; the name isn't.

Parameters:
name - The attribute name.
value - The attribute value.
Returns:
An XML-ised representation of the pair.

esca

public static java.lang.String esca(java.lang.String name,
                                    boolean value)
As esca(String, String), except that the value is a boolean to be encoded as a string (either true or false).

Parameters:
name - The attribute name.
value - The attribute value.
Returns:
An XML-ised representation of the pair.

esca

public static java.lang.String esca(java.lang.String name,
                                    int value)
As esca(String, String), except that the value is an int to be encoded as a string.

Parameters:
name - The attribute name.
value - The attribute value.
Returns:
An XML-ised representation of the pair.

esca

public static java.lang.String esca(java.lang.String name,
                                    long value)
As esca(String, String), except that the value is a long to be encoded as a string.

Parameters:
name - The attribute name.
value - The attribute value.
Returns:
An XML-ised representation of the pair.

esce

public static java.lang.String esce(java.lang.String name,
                                    java.lang.String value)
Return a string of the form <name>value</name>. This form is useful when generating XML documents from data objects. The value string is escaped by passing it through esc; the name isn't.

Parameters:
name - The attribute name.
value - The attribute value.
Returns:
An XML-ised representation of the pair.

esce

public static java.lang.String esce(java.lang.String name,
                                    int value)
Return a string of the form <name>value</name>. This form is useful when generating XML documents from data objects.

Parameters:
name - The attribute name.
value - The attribute value.
Returns:
An XML-ised representation of the pair.

esce

public static java.lang.String esce(java.lang.String name,
                                    long value)
Return a string of the form <name>value</name>. This form is useful when generating XML documents from data objects.

Parameters:
name - The attribute name.
value - The attribute value.
Returns:
An XML-ised representation of the pair.

esce

public static java.lang.String esce(java.lang.String name,
                                    boolean value)
Return a string of the form <name>value</name>. This form is useful when generating XML documents from data objects.

Parameters:
name - The attribute name.
value - The attribute value.
Returns:
An XML-ised representation of the pair.

attr

public static java.lang.String attr(java.lang.String name,
                                    java.lang.String value)
Returns a string of the form ¬name="value" where the '¬' character stands for a single space character. This form is what an XML attribute looks like, which makes this form useful when generating XML documents from data objects. Note that the value is not escaped: use with caution.

Parameters:
name - The attribute name.
value - The attribute value.
Returns:
An XML-ised representation of the pair.

elem

public static java.lang.String elem(java.lang.String name,
                                    java.lang.String value)
Return a string of the form <name>value</name>. This form is useful when generating XML documents from data objects. Note that the value is not escaped: use with caution.

Parameters:
name - The attribute name.
value - The attribute value.
Returns:
An XML-ised representation of the pair.