|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
java.io.BufferedInputStream
chemaxon.marvin.io.PositionedInputStream
public class PositionedInputStream
Positioned input stream that has the ability to set / get the stream position as well as put back some parts already read.
Field Summary | |
---|---|
protected chemaxon.marvin.io.Encoding |
encoding
The encoding. |
protected java.nio.ByteBuffer |
lineByteBuffer
Lines are read into this buffer. |
protected int |
lineCurrentColumn
Column position of the next character to read. |
Fields inherited from class java.io.BufferedInputStream |
---|
buf, count, marklimit, markpos, pos |
Fields inherited from class java.io.FilterInputStream |
---|
in |
Constructor Summary | |
---|---|
|
PositionedInputStream(java.io.InputStream is)
Constructor. |
|
PositionedInputStream(java.io.InputStream is,
int size)
Constructor. |
|
PositionedInputStream(java.io.InputStream is,
int size,
java.lang.String enc)
Constructor. |
protected |
PositionedInputStream(java.io.InputStream is,
int size,
java.lang.String enc,
int initialChunkSize)
Constructor. |
|
PositionedInputStream(java.io.InputStream is,
java.lang.String enc)
Constructor. |
Method Summary | |
---|---|
protected int |
bufincRead()
Reads a character and writes into the buffer. |
java.lang.String |
endGrabLines()
Ends grabbing lines. |
chemaxon.marvin.io.Encoding |
getEncoding()
Gets the encoding. |
long |
getFilePointer()
Get the file pointer. |
java.lang.String |
getGrabbedLines()
Gets the grabbed lines. |
int |
getLineCount()
Gets the current line number. |
protected int |
getWord(java.nio.ByteBuffer bb,
int i)
|
boolean |
isSeekable()
Tests whether the stream is seekable. |
long |
length()
Gets the file length. |
void |
putBackLine()
Puts back the last line into the stream. |
void |
putBackLine(int col)
Puts back the last line into the stream. |
int |
read()
Reads a character. |
int |
read(byte[] b,
int off,
int len)
Reads a byte array. |
java.lang.String |
readLine()
Reads a line. |
void |
reset()
Repositions this stream to the position at the time the mark method was last called on this input stream. |
protected void |
resetFilePointer()
Resets file pointer to zero. |
void |
seek(long p,
int lcount)
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs. |
protected void |
setByteOrder(java.nio.ByteBuffer bb)
|
void |
setDesiredBufferSize(int size)
Sets desired buffer size. |
void |
setEncoding(chemaxon.marvin.io.Encoding enc)
Sets the encoding. |
void |
setEncoding(java.lang.String enc)
Sets the encoding. |
protected void |
setWord(java.nio.ByteBuffer bb,
int i,
int c)
|
long |
skip(long n)
Skips over and discards n bytes of data. |
boolean |
skipLine()
Skips the next line. |
void |
startGrabLines()
Starts grabbing lines. |
Methods inherited from class java.io.BufferedInputStream |
---|
available, close, mark, markSupported |
Methods inherited from class java.io.FilterInputStream |
---|
read |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.nio.ByteBuffer lineByteBuffer
readLine()
protected int lineCurrentColumn
protected chemaxon.marvin.io.Encoding encoding
Constructor Detail |
---|
public PositionedInputStream(java.io.InputStream is) throws java.io.IOException
is
- the original input stream
java.io.IOException
public PositionedInputStream(java.io.InputStream is, int size) throws java.io.IOException
is
- the original input streamsize
- the buffer size
java.io.IOException
public PositionedInputStream(java.io.InputStream is, java.lang.String enc) throws java.io.IOException
null
).
is
- the original input streamenc
- the character encoding or null
java.io.IOException
public PositionedInputStream(java.io.InputStream is, int size, java.lang.String enc) throws java.io.IOException
null
).
is
- the original input streamsize
- the buffer sizeenc
- the character encoding or null
java.io.IOException
protected PositionedInputStream(java.io.InputStream is, int size, java.lang.String enc, int initialChunkSize) throws java.io.IOException
is
- the original input streamsize
- the buffer sizeenc
- the character encoding or nullinitialChunkSize
- number of bytes to read in advance for
encoding recognition
java.io.IOException
Method Detail |
---|
public void setDesiredBufferSize(int size)
size
- the desired buffer sizepublic int read() throws java.io.IOException
read
in class java.io.BufferedInputStream
java.io.IOException
- read error occuredprotected final int bufincRead() throws java.io.IOException
java.io.IOException
- in case of read errorpublic int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.BufferedInputStream
b
- the buffer into which the data is read.off
- the start offset of the datalen
- maximum number of bytes to read
java.io.IOException
- read error occuredpublic long skip(long n) throws java.io.IOException
skip
in class java.io.BufferedInputStream
n
- the number of bytes
java.io.IOException
- read error occuredpublic void reset() throws java.io.IOException
mark
method was last called on this input stream.
reset
in class java.io.BufferedInputStream
java.io.IOException
- if this stream has not been marked or if the
mark has been invalidated.public final void startGrabLines()
endGrabLines()
,
getGrabbedLines()
public final java.lang.String endGrabLines()
public final java.lang.String getGrabbedLines()
public java.lang.String readLine() throws java.io.IOException
java.io.IOException
- If an I/O error has occurred.public boolean skipLine() throws java.io.IOException
true
if a line was skipped successfully,
false
at end of file
java.io.IOException
- If an I/O error has occurred.protected int getWord(java.nio.ByteBuffer bb, int i)
protected void setWord(java.nio.ByteBuffer bb, int i, int c)
public final int getLineCount()
public final void putBackLine() throws java.io.IOException
java.io.IOException
- If an I/O error has occurred.readLine()
,
getFilePointer()
public final void putBackLine(int col) throws java.io.IOException
col
- put back the substring starting at this column
java.io.IOException
- If an I/O error has occurred.readLine()
,
getFilePointer()
protected final void resetFilePointer()
public final long getFilePointer()
public boolean isSeekable()
public void seek(long p, int lcount) throws java.io.IOException
p
- the offset positionlcount
- the line count at the specified position
java.io.IOException
- if pos
is less than
0
or if an I/O error occurs.public long length() throws java.io.IOException
java.io.IOException
- if the file length cannot be determinedpublic final chemaxon.marvin.io.Encoding getEncoding()
public final void setEncoding(chemaxon.marvin.io.Encoding enc)
enc
- the encodingpublic final void setEncoding(java.lang.String enc)
enc
- the encoding
java.nio.charset.IllegalCharsetNameException
- if the encoding is illegal
java.nio.charset.UnsupportedCharsetException
- if the encoding is unsupportedprotected void setByteOrder(java.nio.ByteBuffer bb)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |