scone.util.tokenstream
Class TokenInputStreamBufferImpl

java.lang.Object
  extended by scone.util.tokenstream.TokenInputStream
      extended by scone.util.tokenstream.TokenInputStreamBufferImpl

public class TokenInputStreamBufferImpl
extends TokenInputStream

reads Tokens from the TokenBuffer a TokenOutputStream writes to.

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

Constructor Summary
TokenInputStreamBufferImpl(TokenOutputStream out)
          creates a new TokenInputBufferImpl that reads from a TokenBuffer.
 
Method Summary
 void close()
          Close the input stream.
 java.util.Hashtable getMetaInfo()
          returns the meta info associated with this TokenInputStream
 boolean isClosed()
          Determines if the input stream is closed.
 void mark(int readlimit)
          Mark the stream for later resetting
 boolean markSupported()
          Test whether mark() and reset() are supported.
 Token read()
          Read a Token from the input stream.
 int read(Token[] buf)
          Read Tokens from the input stream filling the specified Token array.
 int read(Token[] buf, int offset, int length)
          Read multiple Tokens from the input stream.
 void reset()
          Reset the stream to its previous mark
 
Methods inherited from class scone.util.tokenstream.TokenInputStream
create, create
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenInputStreamBufferImpl

public TokenInputStreamBufferImpl(TokenOutputStream out)
creates a new TokenInputBufferImpl that reads from a TokenBuffer.

Parameters:
out - the TokenOutputStream that holds the TokenBuffer
Method Detail

read

public 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.

Specified by:
read in class TokenInputStream
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 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.

Specified by:
read in class TokenInputStream
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 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.

Specified by:
read in class TokenInputStream
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 void close()
           throws java.io.IOException
Close the input stream. If the stream is already closed, this method has not effect.

Specified by:
close in class TokenInputStream
Throws:
java.io.IOException

isClosed

public boolean isClosed()
Determines if the input stream is closed.

Specified by:
isClosed in class TokenInputStream
Returns:
true if stream closed; else false.

mark

public void mark(int readlimit)
Mark the stream for later resetting

Specified by:
mark in class TokenInputStream
Parameters:
readlimit - The number of Tokens read beyond which the mark will become invalid.

reset

public void reset()
           throws java.io.IOException
Reset the stream to its previous mark

Specified by:
reset in class TokenInputStream
Throws:
java.io.IOException - if the stream was not marked or the mark has become invalid.

markSupported

public boolean markSupported()
Test whether mark() and reset() are supported.

Specified by:
markSupported in class TokenInputStream
Returns:
true if mark() and reset() are supported, false otherwise.

getMetaInfo

public java.util.Hashtable getMetaInfo()
returns the meta info associated with this TokenInputStream

Specified by:
getMetaInfo in class TokenInputStream
Returns:
the metaInfo