org.norther.tammi.acorn.lang
Class XML

java.lang.Object
  extended by org.norther.tammi.acorn.lang.XML

public abstract class XML
extends Object

Encodes and decodes XML strings.

Version:
$Id: XML.java,v 1.10 2009/10/29 15:50:51 cvsimp Exp $
Author:
Ilkka Priha

Field Summary
static String AMP
          XML reference for &.
static String APOS
          XML reference for '.
static int ENTITY_LENGTH
          The max length of supported XML entities.
static String EURO
          XML reference for €.
static String EXTERNALS
          XML reserved external characters.
static String GT
          XML reference for >.
static String INTERNALS
          XML reserved internal characters.
static String LT
          XML reference for <.
static String QUOT
          XML reference for ".
static String XAPOS
          XML hex reference for '.
static String XML_VERSION_1_0
          XML version.
static String XML_VERSION_1_0_UTF_8
          XML version with UTF-8 encoding.
static String XQUOT
          XML hex reference for ".
 
Constructor Summary
XML()
           
 
Method Summary
static String fromXML(Object object)
          Converts the specified XML encoded object to a text string.
static String fromXML(Object object, int limit, String exceptions)
          Converts the specified XML encoded object to a text string with exceptions.
static String toName(Object object)
          Converts the specified string to a valid id or name attribute.
static CharSequence toXML(char[] chars, int start, int count, int limit, String encodings, int offset, StringBuilder... buffer)
          Converts the specified char array to an XML encoded char sequence.
static CharSequence toXML(Object object, int limit, String encodings, int offset, StringBuilder... buffer)
          Converts the specified object to an XML encoded char sequence.
static CharSequence toXML(Object object, int limit, String encodings, StringBuilder... buffer)
          Converts the specified object to an XML encoded char sequence.
static CharSequence toXML(Object object, StringBuilder... buffer)
          Converts the specified object to an XML encoded char sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_VERSION_1_0

public static final String XML_VERSION_1_0
XML version.

See Also:
Constant Field Values

XML_VERSION_1_0_UTF_8

public static final String XML_VERSION_1_0_UTF_8
XML version with UTF-8 encoding.

See Also:
Constant Field Values

LT

public static final String LT
XML reference for <.

See Also:
Constant Field Values

GT

public static final String GT
XML reference for >.

See Also:
Constant Field Values

AMP

public static final String AMP
XML reference for &.

See Also:
Constant Field Values

QUOT

public static final String QUOT
XML reference for ".

See Also:
Constant Field Values

XQUOT

public static final String XQUOT
XML hex reference for ".

See Also:
Constant Field Values

APOS

public static final String APOS
XML reference for '.

See Also:
Constant Field Values

XAPOS

public static final String XAPOS
XML hex reference for '.

See Also:
Constant Field Values

EURO

public static final String EURO
XML reference for €.

See Also:
Constant Field Values

INTERNALS

public static final String INTERNALS
XML reserved internal characters.

See Also:
Constant Field Values

EXTERNALS

public static final String EXTERNALS
XML reserved external characters.

See Also:
Constant Field Values

ENTITY_LENGTH

public static final int ENTITY_LENGTH
The max length of supported XML entities.

Constructor Detail

XML

public XML()
Method Detail

toXML

public static CharSequence toXML(Object object,
                                 StringBuilder... buffer)
Converts the specified object to an XML encoded char sequence. Internal entities and character entities are supported and not encoded twice. All reserved characters are encoded.

Parameters:
object - the object to convert.
buffer - an optional result buffer.
Returns:
the XML encoded char sequence.

toXML

public static CharSequence toXML(Object object,
                                 int limit,
                                 String encodings,
                                 StringBuilder... buffer)
Converts the specified object to an XML encoded char sequence. Internal entities and character entities are supported and not encoded twice. Only characters above the limit and in encodings are encoded.

Parameters:
object - the object to convert.
limit - the encoding limit.
encodings - a list of encodings.
buffer - an optional result buffer.
Returns:
the XML encoded char sequence.

toXML

public static CharSequence toXML(Object object,
                                 int limit,
                                 String encodings,
                                 int offset,
                                 StringBuilder... buffer)
Converts the specified object to an XML encoded char sequence. Internal entities and character entities are supported and not encoded twice. Only characters above the limit and in encodings are encoded.

Parameters:
object - the object to convert.
limit - the encoding limit.
encodings - a list of encodings.
offset - the offset in the buffer (-1 = append).
buffer - an optional result buffer.
Returns:
the XML encoded char sequence.

toXML

public static CharSequence toXML(char[] chars,
                                 int start,
                                 int count,
                                 int limit,
                                 String encodings,
                                 int offset,
                                 StringBuilder... buffer)
Converts the specified char array to an XML encoded char sequence. Internal entities and character entities are supported and not encoded twice. Only characters above the limit and in encodings are encoded.

Parameters:
chars - the char array to convert.
start - the offset in the array.
count - the count in the array.
limit - the encoding limit.
encodings - a list of encodings.
offset - the offset in the buffer (-1 = append).
buffer - an optional result buffer.
Returns:
the XML encoded char sequence.

fromXML

public static String fromXML(Object object)
Converts the specified XML encoded object to a text string. Internal entities and character entities are supported.

Parameters:
object - the object to convert.
Returns:
the text string.

fromXML

public static String fromXML(Object object,
                             int limit,
                             String exceptions)
Converts the specified XML encoded object to a text string with exceptions. Internal entities and character entities are supported. Characters above the limit and exceptions are not unescaped.

Parameters:
object - the object to convert.
limit - the encoding limit.
exceptions - a list of exceptions.
Returns:
the text string.

toName

public static String toName(Object object)
Converts the specified string to a valid id or name attribute.

Parameters:
object - the object to convert.
Returns:
the valid id or name attribute.
See Also:
SGML basic types


Copyright © 2004 The Norther Organization. All rights reserved.