|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.InputStream
org.jscience.io.InterceptInputStream
public class InterceptInputStream
A specialized stream that allows to provide custom actions upon the occurence of a given byte pattern. The custom actions occur through registered Handler objects; bytes can be skipped from the stream (to not have the given pattern occur in the stream) and bytes can be inserted into the stream through given methods. The class may be subclassed to provide more sophisticated pattern matching, as this implementation only acts upon exact matches of a search pattern found.
ReplaceInputStream| Nested Class Summary | |
|---|---|
static interface |
InterceptInputStream.Handler
used to handle pattern occurences for an InterceptInputStream |
| Constructor Summary | |
|---|---|
InterceptInputStream(java.io.InputStream in,
byte[] searchPattern)
Creates a new InterceptInputStream object. |
|
| Method Summary | |
|---|---|
void |
addHandler(InterceptInputStream.Handler handler)
DOCUMENT ME! |
protected int |
checkForMatch(byte[] buffer1,
byte[] buffer2,
byte[] searchPattern,
int cursor)
checks whether the exact searchPattern can be found in buffer1 or in the intersection between buffer1 and buffer2. |
void |
close()
DOCUMENT ME! |
void |
insertBytes(byte[] bytes)
inserts the given bytes into the stream, so that these bytes are read next before all others that would normally follow at this point. |
boolean |
markSupported()
returns false |
int |
read()
DOCUMENT ME! |
long |
readSoFar()
returns the total number of bytes read from the original stream so far (not considering inserted bytes but counting skipped bytes) |
void |
reset()
throws IOException |
long |
skip(long numberOfBytes)
skips bytes only from the source input stream - ignoring inserted bytes |
| Methods inherited from class java.io.InputStream |
|---|
available, mark, read, read |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public InterceptInputStream(java.io.InputStream in,
byte[] searchPattern)
in - DOCUMENT ME!searchPattern - DOCUMENT ME!| Method Detail |
|---|
public void addHandler(InterceptInputStream.Handler handler)
handler - DOCUMENT ME!
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.InputStreamjava.io.IOException - DOCUMENT ME!public boolean markSupported()
markSupported in class java.io.InputStream
public void reset()
throws java.io.IOException
reset in class java.io.InputStreamjava.io.IOException - DOCUMENT ME!public void insertBytes(byte[] bytes)
bytes - DOCUMENT ME!
public long skip(long numberOfBytes)
throws java.io.IOException
skip in class java.io.InputStreamnumberOfBytes - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public int read()
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOException - DOCUMENT ME!public long readSoFar()
protected int checkForMatch(byte[] buffer1,
byte[] buffer2,
byte[] searchPattern,
int cursor)
buffer1 - byte array containing the current stream bufferbuffer2 - byte array containing the following buffer (to enable
pattern search in intersections of two buffers, so that all
occurences within the stream can be found)searchPattern - the pattern that is used for the pattern matchingcursor - the current position of the stream within buffer1
IOUtils.indexOf(byte[],byte[],int,int),
(byte[], byte[], byte[])
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||