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 TokenOutputStream

    java.lang.Object
      scone.util.tokenstream.TokenOutputStream

Direct Known Subclasses:
  DummyTokenOutputStream

    public class TokenOutputStream

extends java.lang.Object

writes Tokens into a TokenBuffer

Version:
  1.0
Author:
  Volkert Buchmann (ported from code by Team WBI), IBM Almaden Research Center, (c) Copyright IBM Corp 2000

Constructor Summary
`TokenOutputStream()` creates a new TokenOutputStream with a standard size TokenBuffer.

Method Summary
`void` | `close()` Close the token output stream.
`static TokenOutputStream` | `create(RequestEvent e)` Returns a TokenOutputStream that allows to pass tokens to the next MEG.
`void` | `flush()` Flush the stream.
`protected java.lang.Object` | `getBufferContext()` Get the buffer context.
`MegObject` | `getClone()` returns a copy of this MegObject to preserve the data in its original state.
`java.io.InputStream` | `getInputStream()` provides interoperation with "old" MEGs that do not understand the MegObject and must process the data as a MegInputStream.
`java.util.Hashtable` | `getMetaInfo()`
`java.io.Reader` | `getReader()` getReader provides access to the MegObject as character data rather than bytes.
`java.io.Reader` | `getReader(java.lang.String encoding)` getReader provides access to the MegObject as character data using the specified character encoding.
`long` | `getTimeout()` Access the timeout value for write operations.
`boolean` | `isClosed()` Determine if the stream is closed.
`protected void` | `setMetaInfo(java.util.Hashtable metaInfo)`
`void` | `setTimeout(long timeout)` Set a timeout value for write operations.
`void` | `write(Token token)` Write a Token to the stream.
`void` | `write(Token[] buf)` Write a Token array to the stream.
`void` | `write(Token[] buf, int offset, int length)` Write a portion of the passed Token buffer array.

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

Constructor Detail

### TokenOutputStream

    public TokenOutputStream()

  creates a new TokenOutputStream with a standard size TokenBuffer.

Method Detail

### create

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

  Returns a TokenOutputStream that allows to pass tokens to the next MEG.

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

### getInputStream

    public java.io.InputStream getInputStream()

  provides interoperation with "old" MEGs that do not understand the MegObject and must process the data as a MegInputStream.

  Returns:
    InputStream access to the MEG data.

### getReader

    public java.io.Reader getReader()
                             throws java.io.UnsupportedEncodingException,
                                    NotCharDataException

  getReader provides access to the MegObject as character data rather than bytes.

  Returns:
    Reader access to the MEG data.
  Throws:
    `java.io.UnsupportedEncodingException`
    `NotCharDataException`

### getReader

    public java.io.Reader getReader(java.lang.String encoding)
                             throws java.io.UnsupportedEncodingException,
                                    NotCharDataException

  getReader provides access to the MegObject as character data using the specified character encoding.

  Parameters:
    `encoding` - the desired character encoding.
  Returns:
    Reader access to the MEG data.
  Throws:
    `java.io.UnsupportedEncodingException`
    `NotCharDataException`

### getClone

    public MegObject getClone()

  returns a copy of this MegObject to preserve the data in its original state.

  Returns:
    the clone

### write

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

  Write a portion of the passed Token buffer array.

  Parameters:
    `buf` - The Token buffer array.
    `offset` - Offset in the array to start writing from.
    `length` - The amount from offset to write.
  Throws:
    `java.io.IOException` - If unable to write to stream.

### write

    public void write(Token token)
               throws java.io.IOException

  Write a Token to the stream.

  Parameters:
    `token` - the Token to write.
  Throws:
    `java.io.IOException` - If unable to write to stream.

### write

    public void write(Token[] buf)
               throws java.io.IOException

  Write a Token array to the stream.

  Parameters:
    `buf` - The Token array to write.
  Throws:
    `java.io.IOException` - If unable to write to stream.

### setTimeout

    public void setTimeout(long timeout)

  Set a timeout value for write operations. Writes will not block longer than the timeout time. If a timeout occurs, then an InterruptedIOException will be thrown.

  Parameters:
    `timeout` - The maximum time to block for write operations, in milliseconds. A value of zero (the default) means to never timeout.

### getTimeout

    public long getTimeout()

  Access the timeout value for write operations.

  Returns:
    The maximum time to block for write operations, in milliseconds. A value of zero means to never timeout.

### close

    public void close()
               throws java.io.IOException

  Close the token output stream.

  Throws:
    `java.io.IOException` - If error occurred closing stream.

### isClosed

    public boolean isClosed()

  Determine if the stream is closed.

  Returns:
    `true` if closed.

### flush

    public void flush()
               throws java.io.IOException

  Flush the stream.

  Throws:
    `java.io.IOException`

### getBufferContext

    protected java.lang.Object getBufferContext()

  Get the buffer context. This method is used by TokenInputStreamBufferImpl

  Returns:
    The buffer context.

### getMetaInfo

    public java.util.Hashtable getMetaInfo()

### setMetaInfo

    protected void setMetaInfo(java.util.Hashtable 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