org.basex.io
Class CachedOutput

java.lang.Object
  extended by java.io.OutputStream
      extended by org.basex.io.PrintOutput
          extended by org.basex.io.CachedOutput
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public final class CachedOutput
extends PrintOutput

This class caches the output bytes in an array. If a maximum is specified, the returned byte array contains a notice that the output was chopped in case there was more data than specified by the limit.

Author:
Workgroup DBIS, University of Konstanz 2005-08, ISC License, Christian Gruen

Constructor Summary
CachedOutput()
          Default constructor.
CachedOutput(int m)
          Constructor, specifying the maximum number of bytes to write.
 
Method Summary
 void addInfo()
          Adds a textual chopping info to the cached output.
 byte[] buffer()
          Returns the internal buffer.
 byte[] finish()
          Returns the output as byte array.
 boolean finished()
          Checks if stream can output more characters; can be overwritten to interrupt streaming at some point.
 java.lang.String toString()
           
 void write(int b)
           
 
Methods inherited from class org.basex.io.PrintOutput
close, flush, print, print, print, print, print, println, println, println, size
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CachedOutput

public CachedOutput()
Default constructor.


CachedOutput

public CachedOutput(int m)
Constructor, specifying the maximum number of bytes to write. 256 is used as minimum value.

Parameters:
m - maximum
Method Detail

write

public void write(int b)
Overrides:
write in class PrintOutput

finish

public byte[] finish()
Returns the output as byte array.

Returns:
byte array

finished

public boolean finished()
Description copied from class: PrintOutput
Checks if stream can output more characters; can be overwritten to interrupt streaming at some point.

Overrides:
finished in class PrintOutput
Returns:
result of check

buffer

public byte[] buffer()
Returns the internal buffer.

Returns:
buffer

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

addInfo

public void addInfo()
Adds a textual chopping info to the cached output.