ecologylab.generic
Class StringInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by ecologylab.generic.StringInputStream
All Implemented Interfaces:
java.io.Closeable

public class StringInputStream
extends java.io.InputStream

A mechanism for reading Strings from java.io.InputStreams of various formats. Used especially in drag and drop, for getting values.


Field Summary
protected  java.lang.CharSequence buffer
          The string from which bytes are read.
protected  int count
          The number of valid characters in the input stream buffer.
protected  int pos
          The index of the next character to read from the input stream buffer.
static int UTF16
           
static int UTF16_BE
           
static int UTF16_LE
           
static int UTF8
           
 
Constructor Summary
StringInputStream(java.lang.CharSequence charSequence)
           
StringInputStream(java.lang.CharSequence charSequence, int format)
          Creates a string input stream to read data from the specified string.
 
Method Summary
 int available()
           
 int read()
          Reads the next byte of data from this input stream.
 int read(byte[] buf, int off, int len)
           
 
Methods inherited from class java.io.InputStream
close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTF16_LE

public static final int UTF16_LE
See Also:
Constant Field Values

UTF16_BE

public static final int UTF16_BE
See Also:
Constant Field Values

UTF16

public static final int UTF16
See Also:
Constant Field Values

UTF8

public static final int UTF8
See Also:
Constant Field Values

buffer

protected java.lang.CharSequence buffer
The string from which bytes are read.


pos

protected int pos
The index of the next character to read from the input stream buffer.

See Also:
StringBufferInputStream.buffer

count

protected int count
The number of valid characters in the input stream buffer.

See Also:
StringBufferInputStream.buffer
Constructor Detail

StringInputStream

public StringInputStream(java.lang.CharSequence charSequence,
                         int format)
Creates a string input stream to read data from the specified string.

Parameters:
charSequence - the underlying input buffer.

StringInputStream

public StringInputStream(java.lang.CharSequence charSequence)
Method Detail

read

public int read()
Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned.

The read method of StringBufferInputStream cannot block. It returns the low eight bits of the next character in this input stream's buffer.

Specified by:
read in class java.io.InputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.

read

public int read(byte[] buf,
                int off,
                int len)
Overrides:
read in class java.io.InputStream

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException