org.basex.io
Class PrintOutput

java.lang.Object
  extended by java.io.OutputStream
      extended by org.basex.io.PrintOutput
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable
Direct Known Subclasses:
CachedOutput, ConsoleOutput, NullOutput

public class PrintOutput
extends java.io.OutputStream

This class is a stream-wrapper for textual data. Note that the internal byte representation (usually UTF8) will be directly output without further character conversion.

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

Constructor Summary
PrintOutput(java.io.OutputStream out)
          Constructor given an output stream.
 
Method Summary
 void close()
           
 boolean finished()
          Checks if stream can output more characters; overwritten by CachedOutput to allow interruptions when the buffer is full.
 void flush()
           
 void print(byte[] token)
          Writes a token to the output stream.
 void print(char ch)
          Writes a character to the output stream.
 void print(java.lang.String str)
          Writes a string to the output stream.
 void println()
          Writes a newline to the output stream.
 void println(byte[] token)
          Writes a token to the output stream.
 void println(java.lang.String str)
          Writes a string and newline to the output stream.
 void printToken(byte[] token, boolean entity)
          Writes a token to the output stream and encodes standard entities if the entity flag is set.
 int size()
          Returns the number of written bytes.
 void write(int b)
           
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrintOutput

public PrintOutput(java.io.OutputStream out)
Constructor given an output stream.

Parameters:
out - the OutputStream to operate on
Method Detail

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException

finished

public boolean finished()
Checks if stream can output more characters; overwritten by CachedOutput to allow interruptions when the buffer is full.

Returns:
result of check

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException

print

public final void print(byte[] token)
                 throws java.io.IOException
Writes a token to the output stream.

Parameters:
token - token to be written
Throws:
java.io.IOException - in case of write errors

print

public final void print(char ch)
                 throws java.io.IOException
Writes a character to the output stream.

Parameters:
ch - string to be written
Throws:
java.io.IOException - in case of write errors

print

public final void print(java.lang.String str)
                 throws java.io.IOException
Writes a string to the output stream.

Parameters:
str - string to be written
Throws:
java.io.IOException - in case of write errors

println

public final void println()
                   throws java.io.IOException
Writes a newline to the output stream.

Throws:
java.io.IOException - in case of write errors

println

public final void println(byte[] token)
                   throws java.io.IOException
Writes a token to the output stream.

Parameters:
token - token to be written
Throws:
java.io.IOException - in case of write errors

println

public final void println(java.lang.String str)
                   throws java.io.IOException
Writes a string and newline to the output stream.

Parameters:
str - string to be written
Throws:
java.io.IOException - in case of write errors

printToken

public final void printToken(byte[] token,
                             boolean entity)
                      throws java.io.IOException
Writes a token to the output stream and encodes standard entities if the entity flag is set.

Parameters:
token - token to be written
entity - entity encoding
Throws:
java.io.IOException - in case of write errors

size

public final int size()
Returns the number of written bytes.

Returns:
number of written bytes.

write

public void write(int b)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException