com.webmethods.rtl.encode
Class JSEncoder

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

public class JSEncoder
extends Encoder

Encodes to and from JavaScript. Escapes \" \' \\ \n \r and \t.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.webmethods.rtl.encode.Encoder
Encoder.FixedCharArrayWriter
 
Field Summary
protected static char[] CARRIAGE_RETURN
           
protected static Encoder encoder
           
protected static char[] GREATER_THAN
           
protected static char[] LESS_THAN
           
protected static char[] LINE_FEED
           
protected static char[] UNICODE
           
 
Constructor Summary
JSEncoder()
           
 
Method Summary
 int decode(char[] src, int soff, int len, Writer dst)
          Decodes from JavaScript.
 int encode(char[] src, int soff, int len, Writer dst)
          Encodes to JavaScript.
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

LINE_FEED

protected static final char[] LINE_FEED

CARRIAGE_RETURN

protected static final char[] CARRIAGE_RETURN

LESS_THAN

protected static final char[] LESS_THAN

GREATER_THAN

protected static final char[] GREATER_THAN

UNICODE

protected static final char[] UNICODE

encoder

protected static Encoder encoder
Constructor Detail

JSEncoder

public JSEncoder()
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 JavaScript.

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 JavaScript.

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