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 SexpInputStream

    java.lang.Object
      |
      +--java.io.InputStream
            |
            +--java.io.FilterInputStream
                  |
                  +--java.io.BufferedInputStream
                        |
                        +--sexp.SexpInputStream

public class SexpInputStream
extends BufferedInputStream

This class provides S-Expression input stream functionallity, in the same manner as Ron Rivest's reference S-Expression parser.

Version:
  $Id: SexpInputStream.java,v 1.1.1.2 2002/05/08 22:48:27 tep Exp $
Author:
  Per Harald Myrvang <perm@pasta.cs.uit.no>
See Also:
  `SexpOutputStream`

Field Summary
`static String` | `__me`
`private int` | `bits`
`private int` | `byteSize`
`private int` | `count`
`boolean` | `debug`
`private boolean` | `isEOF`
`private int` | `nBits`
`private int` | `nextByte`
`private int[]` | `saved_state`

Fields inherited from class java.io.BufferedInputStream
`buf, count, defaultBufferSize, marklimit, markpos, pos`

Fields inherited from class java.io.FilterInputStream
`in`

Fields inherited from class java.io.InputStream
`SKIP_BUFFER_SIZE, skipBuffer`

Constructor Summary
`SexpInputStream(InputStream stream)` Creates and initializes a new InputStream object.

Method Summary
`void` | `changeByteSize(int base)` Change the input byte size.
`boolean` | `EOF()` Test to see if this stream have reached end-of-file.
`void` | `mark(int readlimit)` Marks the current position and state in this input stream.
`int` | `read()` Reads the next byte of data from this buffered input stream.
`void` | `reset()` Repositions this stream to the position and state at the time the mark method was last called on this input stream.
`void` | `scanBase64String(SimpleString ss, long length)` Scan input as Base64 string of given length.
`long` | `scanDecimal(long val)` Scan input as a decimal number of some encoding.
`void` | `scanHexString(SimpleString ss, long length)` Scan input as hexadecimal string of given length.
`SList` | `scanList()` Scan input as a SList.
`SExpression` | `scanObject()` Scans input for either a SList or a Sexp.
`void` | `scanQuotedString(SimpleString ss, long length)` Scan input as quoted string of given length.
`SimpleString` | `scanSimpleString()` Scan input into a SimpleString.
`Sexp` | `scanString()` Scan input as a Sexp.
`boolean` | `scanToken(SimpleString ss)` Scan one or more characters into the given simple string as a token.
`void` | `scanVerbatimString(SimpleString ss, long length)` Scan input as verbatim string of given length.
`boolean` | `skipChar(int c)` Skip the following input character on input stream is, if it is equal to the character c.
`boolean` | `skipWhiteSpace()` Skip over any white space on the given InputStream.

Methods inherited from class java.io.BufferedInputStream
`, available, close, ensureOpen, fill, markSupported, read, read1, skip`

Methods inherited from class java.io.FilterInputStream
`read`

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

Field Detail

### __me

    public static final String __me

### nextByte

    private int nextByte

### byteSize

    private int byteSize

### bits

    private int bits

### nBits

    private int nBits

### count

    private int count

### isEOF

    private boolean isEOF

### saved_state

    private int[] saved_state

### debug

    public boolean debug

Constructor Detail

### SexpInputStream

    public SexpInputStream(InputStream stream)

  Creates and initializes a new InputStream object. Prefixes stream with one blank, and initializes stream so that it reads from the supplied InputStream.
  Parameters:
    `stream` - InputStream to attach this SexpInputStream to for input.

Method Detail

### mark

    public void mark(int readlimit)

  Marks the current position and state in this input stream.
  Overrides:
    mark in class BufferedInputStream
  See Also:
    `BufferedInputStream.mark(int)`, `reset`

### reset

    public void reset()
               throws IOException

  Repositions this stream to the position and state at the time the mark method was last called on this input stream.
  Overrides:
    reset in class BufferedInputStream
  See Also:
    `BufferedInputStream.reset()`, `mark`

### changeByteSize

    public void changeByteSize(int base)

  Change the input byte size.
  Parameters:
    `newByteSize` - 4 (hexadecimal), 6 (Base64), or 8 (binary raw data).

### EOF

    public boolean EOF()

  Test to see if this stream have reached end-of-file.
  Returns:
    `true` if this stream has reached EOF.

### read

    public int read()
             throws IOException,
                    CharConversionException

  Reads the next byte of data from this buffered input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.
  Overrides:
    read in class BufferedInputStream
  Returns:
    the next byte of data, or -1 if the end of the stream is reached.
  Throws:
    IOException - if an I/O Error occurs
    EOFException - if end of file is reached
    CharConversionException - if an error during input conversion occurs
  See Also:
    `BufferedInputStream`

### skipWhiteSpace

    public boolean skipWhiteSpace()
                           throws IOException

  Skip over any white space on the given InputStream.
  Returns:
    `true` if there's more characters to read (not EOF).

### skipChar

    public boolean skipChar(int c)
                     throws IOException

  Skip the following input character on input stream is, if it is equal to the character c. If it is not equal, then an error occurs.
  Returns:
    `true` if there's more characters to read (not EOF).

### scanToken

    public boolean scanToken(SimpleString ss)
                      throws IOException

  Scan one or more characters into the given simple string as a token.
  Parameters:
    `ss` - SimpleString to scan token into
  Returns:
    `true` if there's more characters to read (not EOF).

### scanDecimal

    public long scanDecimal(long val)
                     throws IOException

  Scan input as a decimal number of some encoding. TODO: Make BigInteger version of this method.
  Parameters:
    `val` - starer value (typically 0)
  Returns:
    long integer that is value of decimal number
  Throws:
    NumberFormatException - if some error occured during conversion (typically the string was too large to contain a decimal number)
    EOFException - if input ended prematurely

### scanVerbatimString

    public void scanVerbatimString(SimpleString ss,
                                   long length)
                            throws IOException

  Scan input as verbatim string of given length.
  Parameters:
    `ss` - SimpleString to scan verbatim string into
    `length` - length of verbatim string to scan
  Throws:
    EOFException - if input ended prematurely

### scanQuotedString

    public void scanQuotedString(SimpleString ss,
                                 long length)
                          throws IOException

  Scan input as quoted string of given length. Handles ordinary C escapes.
  Parameters:
    `ss` - SimpleString to scan verbatim string into
    `length` - length of verbatim string to scan. If of indefinite length, use -1.
  Throws:
    EOFException - if input ended prematurely

### scanHexString

    public void scanHexString(SimpleString ss,
                              long length)
                       throws IOException

  Scan input as hexadecimal string of given length.
  Parameters:
    `ss` - SimpleString to scan verbatim string into
    `length` - length of verbatim string to scan. If of indefinite length, use -1.
  Throws:
    EOFException - if input ended prematurely

### scanBase64String

    public void scanBase64String(SimpleString ss,
                                 long length)
                          throws IOException

  Scan input as Base64 string of given length.
  Parameters:
    `ss` - SimpleString to scan verbatim string into
    `length` - length of verbatim string to scan. If of indefinite length, use -1.
  Throws:
    EOFException - if input ended prematurely

### scanSimpleString

    public SimpleString scanSimpleString()
                                  throws IOException

  Scan input into a SimpleString. Determines type of simple string from the initial character, and dispatches to appropriate method based on that.
  Returns:
    SimpleString
  Throws:
    IOException - if something went wrong
    EOFException - if premature end-of-file was detected

### scanString

    public Sexp scanString()
                    throws IOException

  Scan input as a Sexp. Reads and returns a string [presentationhint]string from input stream.
  Returns:
    Sexp
  Throws:
    IOException - if something went wrong
    EOFException - if premature end-of-file was detected

### scanList

    public SList scanList()
                   throws IOException

  Scan input as a SList.
  Returns:
    SList
  Throws:
    IOException - if something went wrong
    EOFException - if premature end-of-file was detected

### scanObject

    public SExpression scanObject()
                           throws IOException

  Scans input for either a SList or a Sexp. This is the highest-level scanning method available.
  Returns:
    SExpression (either a SList or a String) or `null` if the scanned object couldn't be scanned properly.
  Throws:
    IOException - if something went wrong
    EOFException - if premature end-of-file was detected
  See Also:
    `SExpression`

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