com.webmethods.rtl.encode
Class XMLEncoder

java.lang.Object
  extended by com.webmethods.rtl.encode.Encoder
      extended by com.webmethods.rtl.encode.XMLEncoder

public class XMLEncoder
extends Encoder

Encodes to and from XML. Escapes & \' > < \".


Nested Class Summary
 
Nested classes/interfaces inherited from class com.webmethods.rtl.encode.Encoder
Encoder.FixedCharArrayWriter
 
Field Summary
protected static char[] AMP_REF
           
protected static char[] APOS_REF
           
protected static char[] CHAR_REF_START
           
protected static Encoder encoder
           
protected static char[] GT_REF
           
protected static char[] LT_REF
           
protected static char[] QUOT_REF
           
static Map XMLEntities
           
 
Constructor Summary
XMLEncoder()
           
 
Method Summary
 int decode(char[] src, int soff, int len, Writer dst)
          Decodes from XML.
 int decode(char[] src, int soff, int len, Writer dst, Map entities)
          Decodes from XML.
 int encode(char[] src, int soff, int len, Writer dst)
          Encodes to XML.
static Encoder encoder()
          Returns the encoder instance.
 
Methods inherited from class com.webmethods.rtl.encode.Encoder
decode, decode, decode, decode, decode, decode, encode, encode, encode, encode, encode, encode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AMP_REF

protected static final char[] AMP_REF

APOS_REF

protected static final char[] APOS_REF

GT_REF

protected static final char[] GT_REF

LT_REF

protected static final char[] LT_REF

QUOT_REF

protected static final char[] QUOT_REF

CHAR_REF_START

protected static final char[] CHAR_REF_START

encoder

protected static Encoder encoder

XMLEntities

public static Map XMLEntities
Constructor Detail

XMLEncoder

public XMLEncoder()
Method Detail

encoder

public static Encoder encoder()
Returns the encoder instance.


encode

public int encode(char[] src,
                  int soff,
                  int len,
                  Writer dst)
           throws IOException
Encodes to XML.

Specified by:
encode in class Encoder
Parameters:
src - Char array to encode.
soff - Offset in the src array at which to begin reading.
len - Length of src array to encode.
dst - Writer in which to write the encoded chars.
Returns:
Length of chars written to dst.
Throws:
IOException

decode

public int decode(char[] src,
                  int soff,
                  int len,
                  Writer dst)
           throws IOException
Decodes from XML.

Specified by:
decode in class Encoder
Parameters:
src - Char array to decode.
soff - Offset in the src array at which to begin reading.
len - Length of src array to decode.
dst - Writer in which to write the decoded chars.
Returns:
Length of chars written to dst.
Throws:
IOException

decode

public int decode(char[] src,
                  int soff,
                  int len,
                  Writer dst,
                  Map entities)
           throws IOException
Decodes from XML.

Parameters:
src - Char array to decode.
soff - Offset in the src array at which to begin reading.
len - Length of src array to decode.
dst - Writer in which to write the decoded chars.
entities - Mapping of entity names to replacement texts. If passed null, unrecognized entities will not be decoded.
Returns:
Length of chars written to dst.
Throws:
IOException