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

## scone.util.tokenstream
Class TokenInputStream

    java.lang.Object
      scone.util.tokenstream.TokenInputStream

Direct Known Subclasses:
  TokenInputStreamBufferImpl, TokenInputStreamTokenizerImpl

    public abstract class TokenInputStream

extends java.lang.Object

an InputStream that works on Tokens.
TokenInputStreams are similar to MegInputStreams, but they operate on Token objects instead of bytes. TokenInputStream and TokenOutputStream are examples for the use of MegObject. This class provides static methods that create TokenInputStreams that read data from RequestEvents.

Version:
  1.0
Author:
  Volkert Buchmann, IBM Almaden Research Center, (c) Copyright IBM Corp 2000

Constructor Summary
`TokenInputStream()`

Method Summary
`abstract void` | `close()` Close the input stream.
`static TokenInputStream` | `create(RequestEvent e)` Returns a TokenInputStream that allows to acces the input data provided by the RequestEvent as Tokens.
`static TokenInputStream` | `create(RequestEvent e, java.lang.String tokenizer)` Returns a TokenInputStream that allows to acces the input data provided by the RequestEvent as Tokens.
`abstract java.util.Hashtable` | `getMetaInfo()` returns the meta info associated with this TokenInputStream
`abstract boolean` | `isClosed()` Determines if the input stream is closed.
`abstract void` | `mark(int readAheadLimit)` Mark the stream for later resetting
`abstract boolean` | `markSupported()` Test whether `mark()` and `reset()` are supported.
`abstract Token` | `read()` Read a Token from the input stream.
`abstract int` | `read(Token[] buf)` Read Tokens from the input stream filling the specified Token array.
`abstract int` | `read(Token[] buf, int offset, int length)` Read multiple Tokens from the input stream.
`abstract void` | `reset()` Reset the stream to its previous mark

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

Constructor Detail

### TokenInputStream

    public TokenInputStream()

Method Detail

### create

    public static TokenInputStream create(RequestEvent e,
                                          java.lang.String tokenizer)
                                   throws java.lang.Exception

  Returns a TokenInputStream that allows to acces the input data provided by the RequestEvent as Tokens. If the RequestEvent does not provide a TokenOutputStream as token source, the Tokenizer specified by the tokenizer string will parse the MegInputStream.

  Parameters:
    `e` - the RequestEvent
    `tokenizer` - the class name of the tokenizer
  Returns:
    the TokenInputStream
  Throws:
    `java.lang.Exception`

### create

    public static TokenInputStream create(RequestEvent e)
                                   throws java.lang.Exception

  Returns a TokenInputStream that allows to acces the input data provided by the RequestEvent as Tokens. If the RequestEvent does not provide a TokenOutputStream as token source, the HtmlTokenizer is used to parse the MegReader.

  Parameters:
    `e` - the RequestEvent
  Returns:
    the TokenInputStream
  Throws:
    `java.lang.Exception`

### read

    public abstract Token read()
                        throws java.io.IOException

  Read a Token from the input stream. Blocks if no data available and end of stream not yet reached. If no Token is available because the end of the stream has been reached, null is returned.

  Returns:
    The next Token from the stream, or null if the end of the stream has been reached
  Throws:
    `java.io.IOException` - If stream closed.
    `MarkPreservedException` - If read would invalidate preserved mark

### read

    public abstract int read(Token[] buf,
                             int offset,
                             int length)
                      throws java.io.IOException

  Read multiple Tokens from the input stream. Blocks if no data available and end of stream not yet reached.

  Parameters:
    `buf` - The Token buffer to populate.
    `offset` - The offset in `buf` to starting writing to.
    `length` - The amount of Tokens to write.
  Returns:
    The amount of Tokens read, or -1 if no more Tokens available to read.
  Throws:
    `java.io.IOException` - If stream closed.
    `MarkPreservedException` - If read would invalidate preserved mark

### read

    public abstract int read(Token[] buf)
                      throws java.io.IOException

  Read Tokens from the input stream filling the specified Token array. Blocks if no data available and end of stream not yet reached.

  Parameters:
    `buf` - The Token buffer to populate.
  Returns:
    The amount of Tokens read, or -1 if no more Tokens available to read.
  Throws:
    `java.io.IOException` - If stream closed.
    `MarkPreservedException` - If read would invalidate preserved mark

### close

    public abstract void close()
                        throws java.io.IOException

  Close the input stream. If the stream is already closed, this method has not effect.

  Throws:
    `java.io.IOException`

### isClosed

    public abstract boolean isClosed()

  Determines if the input stream is closed.

  Returns:
    `true` if stream closed; else `false`.

### markSupported

    public abstract boolean markSupported()

  Test whether `mark()` and `reset()` are supported.

  Returns:
    `true` if `mark()` and `reset()` are supported, `false` otherwise.

### mark

    public abstract void mark(int readAheadLimit)
                       throws java.io.IOException

  Mark the stream for later resetting

  Parameters:
    `readlimit` - The number of Tokens read beyond which the mark will become invalid.
  Throws:
    `java.io.IOException`

### reset

    public abstract void reset()
                        throws java.io.IOException

  Reset the stream to its previous mark

  Throws:
    `java.io.IOException` - if the stream was not marked or the mark has become invalid.

### getMetaInfo

    public abstract java.util.Hashtable getMetaInfo()

  returns the meta info associated with this TokenInputStream

  Returns:
    the metaInfo

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