Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## sexp
Class Sexp

    java.lang.Object
      |
      +--sexp.BaseSexp
            |
            +--sexp.Sexp

public class Sexp
extends BaseSexp
implements SExpression

This class implements the octet-string aspect of a SExpression.

Version:
  $Id: Sexp.java,v 1.2 2002/07/07 17:04:56 tep Exp $
Author:
  Per Harald Myrvang <perm@pasta.cs.uit.no>
See Also:
  `SExpression`, `SList`

Field Summary
`private static String` | `__me`
`String` | `byte_encoding` Encoding used when converting from a byte array to whatever.
`protected String` | `cached_hint`
`protected String` | `cached_string`
`private static boolean` | `debug`
`protected static String` | `default_encoding`
`protected SimpleString` | `hint`
`private static boolean` | `pedantic`
`protected SimpleString` | `string`
`String` | `string_encoding` Encoding used when converting from a String to whatever.

Fields inherited from class sexp.BaseSexp
`__me`

Fields inherited from interface sexp.SExpression
`versionString`

Constructor Summary
`Sexp(byte[] ba)` Instantiate and initialize an octet-string from a byte array.
`Sexp(byte[] ba, byte[] hint)` Instantiate and initialize an octet-string from a byte array.
`Sexp(SimpleString input)` Instantiate and initialize an octet-string from a SimpleString
`Sexp(SimpleString input, SimpleString hint)` Instantiate and initialize an octet-string and its displayhint from SimpleStrings.
`Sexp(String s)` Instantiate and initialize an octet-string from the string s.

Method Summary
`void` | `clearHint()` Clears this object's presentation hint.
`Object` | `clone()` Return a clone of this object.
`SExpression` | `copy()` Return a copy of this object.
`boolean` | `equals(Object that)` See if this S-Expression is equal to the given Object.
`void` | `finalize()`
`void` | `free()` Destroy and free the resouces associated with this Sexp.
`byte[]` | `getBytes()` Get raw data.
`SimpleString` | `getHint()` Returns any presentation-hint associated with this S-Expression.
`SimpleString` | `getString()` Returns the SimpleString of this S-Expression.
`boolean` | `isList()` Returns `true` if this S-Expression is a list of simpler S-Expressions, or `false` if this object is an octet-string object.
`static boolean` | `isStartofHint(char c)` Determine if character might be in start of S-Expression presentation-/display-hint.
`static boolean` | `isStartofSexp(char c)` Determine if character might be in start of S-Expression.
`void` | `setHint(byte[] input)` Set the presentation-hint associated with this S-Expression.
`void` | `setHint(SimpleString input)` Set the presentation-hint associated with this S-Expression.
`void` | `setHint(String input)` Set the presentation-hint associated with this S-Expression.
`private static byte[]` | `silentconvert(String s, String caller)`
`String` | `toString()` Returns this S-Expression in its Advanced representation, as a `String`.

Methods inherited from class sexp.BaseSexp
`toAdvanced, toAdvanced, toCanonical, toCanonical, toTransport, toTransport`

Methods inherited from class java.lang.Object
`, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait`

Field Detail

### __me

    private static final String __me

### default_encoding

    protected static String default_encoding

### string_encoding

    public String string_encoding

  Encoding used when converting from a String to whatever.

### byte_encoding

    public String byte_encoding

  Encoding used when converting from a byte array to whatever.

### string

    protected SimpleString string

### hint

    protected SimpleString hint

### cached_string

    protected String cached_string

### cached_hint

    protected String cached_hint

### debug

    private static boolean debug

### pedantic

    private static boolean pedantic

Constructor Detail

### Sexp

    public Sexp(SimpleString input)

  Instantiate and initialize an octet-string from a SimpleString
  Parameters:
    `input` - Simplestring to construct this object from

### Sexp

    public Sexp(SimpleString input,
                SimpleString hint)

  Instantiate and initialize an octet-string and its displayhint from SimpleStrings.
  Parameters:
    `input` - Simplestring to construct this object from
    `hint` - this object's displayhint. May be `null`

### Sexp

    public Sexp(byte[] ba)
         throws SexpException

  Instantiate and initialize an octet-string from a byte array.
  Parameters:
    `ba` - Byte array to build this object from.
  Throws:
    SexpException - Whatever the SimpleString constructor barfed on.

### Sexp

    public Sexp(byte[] ba,
                byte[] hint)
         throws SexpException

  Instantiate and initialize an octet-string from a byte array.
  Parameters:
    `ba` - Byte array to build this object from.
    `hint` - Byte array to build this object's display hint from.
  Throws:
    SexpException - Bogus presentation-hint (can't find ending square-bracket ('`]`').
    SexpException - Presentation-hint without data.
    SexpException - Whatever the SimpleString constructor barfed on.

### Sexp

    public Sexp(String s)
         throws SexpException

  Instantiate and initialize an octet-string from the string s. The string is encoded into a byte-array using this class' default encoding (currently `ISO8859_1`). If the caller want some other encoding scheme, the the conversion must be done beforehand, and the resulting bytearray passed to this class' byte-array accepting constructor.
  Throws:
    SexpException - Illegal presentation-hint (malformed canonical representation)
    SexpException - Bogus presentation-hint (can't find ending square-bracket ('`]`').
    SexpException - Presentation-hint without data.
    SexpException - Whatever the SimpleString constructor barfed on.
  See Also:
    `Sexp(byte[])`

Method Detail

### finalize

    public void finalize()
                  throws Throwable

  Overrides:
    finalize in class Object

### silentconvert

    private static byte[] silentconvert(String s,
                                        String caller)

### clone

    public Object clone()
                 throws CloneNotSupportedException

  Return a clone of this object.
  Overrides:
    clone in class Object

### copy

    public SExpression copy()

  Return a copy of this object.

### free

    public void free()

  Destroy and free the resouces associated with this Sexp.
  Specified by:
    free in interface SExpression

### isList

    public boolean isList()

  Returns `true` if this S-Expression is a list of simpler S-Expressions, or `false` if this object is an octet-string object.
  Specified by:
    isList in interface SExpression
  Returns:
    false, since this object isn't a SList.

### equals

    public boolean equals(Object that)

  See if this S-Expression is equal to the given Object. The comparison is not done toward this' display-hint, if any.
  Specified by:
    equals in interface SExpression
  Overrides:
    equals in class Object
  Parameters:
    `that` - Object to compare this object with. If the object is of some other class than sexp.SimpleString or java.lang.String, its toString() method is called and the comparison uses the result.
  Returns:
    `true` if both objects are equal, `false` if they're not.

### toString

    public String toString()

  Returns this S-Expression in its Advanced representation, as a `String`.
  Specified by:
    toString in interface SExpression
  Overrides:
    toString in class BaseSexp
  Throws:
    RuntimeException - if byte-to-string conversion fails.

### getBytes

    public byte[] getBytes()
                    throws SexpException

  Get raw data. Return the raw data of this object, without any pretty formats, encodings or presentation-hints. The returned data will be a copy.
  Returns:
    byte array containing raw data.
  Throws:
    SexpException - if raw data cannot be obtained.

### getString

    public SimpleString getString()

  Returns the SimpleString of this S-Expression.
  Returns:
    SimpleString containing presentation-hint, or `null` .

### getHint

    public SimpleString getHint()

  Returns any presentation-hint associated with this S-Expression. If there's no presentation-hint, `null` will be returned.
  Returns:
    SimpleString containing presentation-hint, or `null` .

### setHint

    public void setHint(SimpleString input)
                 throws SexpException

  Set the presentation-hint associated with this S-Expression. The presentation-hint input should be given without the enclosing brackets (`[]`).
  Parameters:
    `input` - byte array to construct presentation hint from.
  Throws:
    SexpException - if there's something bogus about the input.

### setHint

    public void setHint(byte[] input)
                 throws SexpException

  Set the presentation-hint associated with this S-Expression. The presentation-hint input should be given without the enclosing brackets (`[]`).
  Parameters:
    `input` - byte array to construct presentation hint from.
  Throws:
    SexpException - if there's something bogus about the input.

### setHint

    public void setHint(String input)
                 throws SexpException

  Set the presentation-hint associated with this S-Expression. The presentation-hint input must be given without the enclosing brackets (`[]`).
  Throws:
    SexpException - if there's something bogus about the input.
    SexpException - Whatever the SimpleString constructor barfed on.

### clearHint

    public void clearHint()

  Clears this object's presentation hint.

### isStartofSexp

    public static boolean isStartofSexp(char c)

  Determine if character might be in start of S-Expression.
  Returns:
    true if c is possibly the start of a S-Expression

### isStartofHint

    public static boolean isStartofHint(char c)

  Determine if character might be in start of S-Expression presentation-/display-hint.
  Returns:
    true if c is possibly the start of a S-Expression presentation-/display-hint.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD