org.basex.io.in
Class NewlineInput

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

public final class NewlineInput
extends TextInput

This class provides a convenient access to text input. System dependent line breaks (\r\n, \n, \r) will be normalized to newline characters \n, and the input encoding will be guessed by analyzing the first bytes.

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
NewlineInput(java.io.InputStream is)
          Constructor.
NewlineInput(IO in)
          Constructor.
 
Method Summary
 NewlineInput encoding(java.lang.String encoding)
          Sets a new encoding.
 int read()
          Returns the next character.
 java.lang.String readLine()
          Reads and returns a single line.
 boolean readLine(TokenBuilder tb)
          Copies a single line to the specified token builder.
 
Methods inherited from class org.basex.io.in.TextInput
cache, content, encoding, validate
 
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

NewlineInput

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

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

NewlineInput

public NewlineInput(IO in)
             throws java.io.IOException
Constructor.

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

encoding

public NewlineInput encoding(java.lang.String encoding)
                      throws java.io.IOException
Description copied from class: TextInput
Sets a new encoding.

Overrides:
encoding in class TextInput
Parameters:
encoding - encoding
Returns:
self reference
Throws:
java.io.IOException - I/O Exception

read

public int read()
         throws java.io.IOException
Description copied from class: TextInput
Returns the next character.

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

readLine

public java.lang.String readLine()
                          throws java.io.IOException
Reads and returns a single line.

Returns:
line, or null
Throws:
java.io.IOException - I/O exception

readLine

public boolean readLine(TokenBuilder tb)
                 throws java.io.IOException
Copies a single line to the specified token builder.

Parameters:
tb - token builder to be filled.
Returns:
true if more input was found
Throws:
java.io.IOException - I/O exception