org.basex.io.in
Class TextInput

java.lang.Object
  extended by java.io.InputStream
      extended by org.basex.io.in.BufferInput
          extended by org.basex.io.in.TextInput
All Implemented Interfaces:
java.io.Closeable
Direct Known Subclasses:
NewlineInput

public class TextInput
extends BufferInput

This class provides buffered access to textual input. The input encoding will initially be guessed by analyzing the first bytes; it can also be explicitly set by calling encoding(). UTF-8 will be used as default encoding.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Field Summary
 
Fields inherited from class org.basex.io.in.BufferInput
bpos, bsize, buffer, input, length
 
Constructor Summary
TextInput(java.io.InputStream is)
          Constructor.
TextInput(IO io)
          Constructor.
 
Method Summary
 TokenBuilder cache()
          Retrieves the whole text and closes the stream.
 byte[] content()
          Retrieves and returns the whole data and closes the stream.
 java.lang.String encoding()
          Returns the encoding.
 TextInput encoding(java.lang.String enc)
          Sets a new encoding.
 int read()
          Returns the next character.
 TextInput validate(boolean v)
          Checks the input for valid XML characters and throws an exception if invalid characters are found.
 
Methods inherited from class org.basex.io.in.BufferInput
close, io, length, mark, markSupported, readByte, readBytes, readString, reset, size
 
Methods inherited from class java.io.InputStream
available, read, read, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextInput

public TextInput(java.io.InputStream is)
          throws java.io.IOException
Constructor.

Parameters:
is - input stream
Throws:
java.io.IOException - I/O exception

TextInput

public TextInput(IO io)
          throws java.io.IOException
Constructor.

Parameters:
io - input
Throws:
java.io.IOException - I/O exception
Method Detail

encoding

public final java.lang.String encoding()
Returns the encoding.

Returns:
encoding

validate

public final TextInput validate(boolean v)
Checks the input for valid XML characters and throws an exception if invalid characters are found.

Parameters:
v - flag to be set
Returns:
self reference

encoding

public TextInput encoding(java.lang.String enc)
                   throws java.io.IOException
Sets a new encoding.

Parameters:
enc - encoding
Returns:
self reference
Throws:
java.io.IOException - I/O Exception

read

public int read()
         throws java.io.IOException
Returns the next character.

Overrides:
read in class BufferInput
Returns:
next codepoint
Throws:
java.io.IOException - I/O exception
See Also:
InputStream.read()

content

public final byte[] content()
                     throws java.io.IOException
Description copied from class: BufferInput
Retrieves and returns the whole data and closes the stream.

Overrides:
content in class BufferInput
Returns:
contents
Throws:
java.io.IOException - I/O exception

cache

public final TokenBuilder cache()
                         throws java.io.IOException
Retrieves the whole text and closes the stream.

Returns:
token builder instance
Throws:
java.io.IOException - I/O exception