org.jcoderz.commons.util
Class XmlUtil

java.lang.Object
  extended by org.jcoderz.commons.util.XmlUtil

public final class XmlUtil
extends Object

This class holds utility methods for common xml topics.

Author:
Andreas Mandel

Field Summary
static Attributes EMPTY_ATTRIBUTES
          Immutable and always empty version of a Attributes object.
 
Method Summary
static String attributeEscape(String attribute)
          Encode a string so that it can be safely used as attribute value in XML output.
static String escape(String text)
          Encode a string so that it can be safely used as text in an element for XML output.
static String formatXml(String org)
          Simple xml formatter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ATTRIBUTES

public static final Attributes EMPTY_ATTRIBUTES
Immutable and always empty version of a Attributes object.

Method Detail

attributeEscape

public static String attributeEscape(String attribute)
Encode a string so that it can be safely used as attribute value in XML output.

Parameters:
attribute - the attribute value to be encoded.
Returns:
a string representing the attribute value that can be safely used in XML output.

escape

public static String escape(String text)
Encode a string so that it can be safely used as text in an element for XML output.

Parameters:
text - the element text body.
Returns:
a string so that it can be safely used as text in an element for XML output.

formatXml

public static String formatXml(String org)
Simple xml formatter. This code might fail for several input. In this case the original input is returned.

Parameters:
org - the input to be formated.
Returns:
the input in xml formated (human readable) form or the input string.


Copyright 2007 The jCoderZ Project.