jsdsi.sexp
Class Sexp

java.lang.Object
  extended byjsdsi.sexp.Sexp
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
SexpList, SexpString

public abstract class Sexp
extends java.lang.Object
implements java.io.Serializable

Abstract S-expression superclass. Provides static utility functions. S-expressions are immutable.

Version:
$Revision: 1.2.2.1 $ $Date: 2005/11/08 03:12:52 $
Author:
Sameer Ajmani
See Also:
SexpString, SexpList, Serialized Form

Field Summary
static char[] base64Digit
          Maps integers to base-64 digits.
static char[] hexDigit
          Maps integers to hexadecimal digits.
 
Constructor Summary
Sexp()
           
 
Method Summary
static java.lang.String decodeString(byte[] b)
          Converts a byte array to a string using the 8859_1 encoding.
static byte[] encodeString(java.lang.String s)
          Converts a string to a byte array using the 8859_1 encoding.
static java.lang.String getEncoding()
          Returns the character encoding for S-expressions (8859_1).
 int getReadableLen()
          Returns the length of this S-expression as if it were printed on one line.
static boolean isBase64Digit(int c)
          Tests if a character is a base 64 digit.
static boolean isDecimalDigit(int c)
          Tests if a character is a decimal digit.
static boolean isHexDigit(int c)
          Tests if a character is a hexadecimal digit.
static boolean isTokenChar(int c)
          Tests if a character is a token character.
static boolean isWhiteSpace(int c)
          Tests if a character is whitespace.
abstract  void writeCanonical(java.io.OutputStream out)
          Writes this S-expression to a byte stream in canonical form.
abstract  void writeReadable(java.io.Writer out, int offset, int width, int last)
          Writes this S-expression to a character stream in readable form.
 void writeTransport(java.io.OutputStream out)
          Writes this S-expression to a byte stream in transport form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hexDigit

public static final char[] hexDigit
Maps integers to hexadecimal digits.


base64Digit

public static final char[] base64Digit
Maps integers to base-64 digits.

Constructor Detail

Sexp

public Sexp()
Method Detail

getEncoding

public static final java.lang.String getEncoding()
Returns the character encoding for S-expressions (8859_1).

Returns:
"8859_1"

isWhiteSpace

public static final boolean isWhiteSpace(int c)
Tests if a character is whitespace.

Parameters:
c - the character to be tested
Returns:
true if the character is whitespace, false otherwise

isDecimalDigit

public static final boolean isDecimalDigit(int c)
Tests if a character is a decimal digit.

Parameters:
c - the character to be tested
Returns:
true if the character is a digit between 0 and 9 inclusive, false otherwise

isHexDigit

public static final boolean isHexDigit(int c)
Tests if a character is a hexadecimal digit.

Parameters:
c - the character to be tested.
Returns:
true if the character is a decimal digit or a letter between 'a' and 'f' upper or lowercase, false otherwise .

isBase64Digit

public static final boolean isBase64Digit(int c)
Tests if a character is a base 64 digit.

Parameters:
c - the character to be tested.
Returns:
true if the character is a decimal digit, a letter of the alphabet or '+' or '/', false otherwise.

isTokenChar

public static final boolean isTokenChar(int c)
Tests if a character is a token character.

Parameters:
c - the character to be tested.
Returns:
true if the character is a legal token character for an S-expression, false otherwise.

decodeString

public static java.lang.String decodeString(byte[] b)
Converts a byte array to a string using the 8859_1 encoding.


encodeString

public static byte[] encodeString(java.lang.String s)
Converts a string to a byte array using the 8859_1 encoding.


writeCanonical

public abstract void writeCanonical(java.io.OutputStream out)
                             throws java.io.IOException
Writes this S-expression to a byte stream in canonical form.

Throws:
java.io.IOException

writeTransport

public final void writeTransport(java.io.OutputStream out)
                          throws java.io.IOException
Writes this S-expression to a byte stream in transport form.

Throws:
java.io.IOException

writeReadable

public abstract void writeReadable(java.io.Writer out,
                                   int offset,
                                   int width,
                                   int last)
                            throws java.io.IOException
Writes this S-expression to a character stream in readable form.

Parameters:
offset - spaces indented from left.
width - total width of window, in characters.
last - spaces reserved on right (e.g., for closing parens).
Throws:
java.io.IOException

getReadableLen

public final int getReadableLen()
Returns the length of this S-expression as if it were printed on one line. Caches result for efficiency.

See Also:
#getReadableLenImpl()


Copyright © 2002-2006 JSDSI. All Rights Reserved.