|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.InputStream
Serialio.SnoopInputStream
Create an 'snoop' input stream on the serial port that searches for data patterns. Note that timeouts are not supported in this class since caller controls readinging via SnoopInputStream.read.
| Field Summary | |
protected java.io.InputStream |
in
|
protected byte |
lastByte
|
| Constructor Summary | |
SnoopInputStream()
This empty constructor is for Bean friendlyness |
|
SnoopInputStream(java.io.InputStream in)
Create an input stream that allows 'snooping' for data patterns on incoming data |
|
| Method Summary | |
void |
addSnoop(SnoopListener lsnr,
byte[] data,
boolean ignoreCase)
Add a 'Snoop' on input stream |
void |
addSnoop(SnoopListener lsnr,
java.lang.String data,
boolean ignoreCase)
Add a 'Snoop' on input stream |
void |
addTokenSnoop(SnoopTokenListener stl,
byte[] tokBeg,
byte[] tokEnd,
byte separator,
int tok,
int id)
Add a 'Token Snoop' on input stream. |
void |
addTokenSnoop(SnoopTokenListener stl,
byte[] tokBeg,
byte[] tokEnd,
byte separator,
int tok,
int id,
int tokLenMax)
Add a 'Token Snoop' on input stream. |
void |
addTokenSnoop(SnoopTokenListener stl,
java.lang.String tokBeg,
java.lang.String tokEnd,
java.lang.String separator,
int tok,
int id)
Add a 'Token Snoop' on input stream. |
void |
addTokenSnoop(SnoopTokenListener stl,
java.lang.String tokBeg,
java.lang.String tokEnd,
java.lang.String separator,
int tok,
int id,
int tokLenMax)
Add a 'Token Snoop' on input stream. |
int |
available()
Indicates the number of bytes in the read queue |
void |
checkDataForMatch(byte b)
Check byte for match with existing snoops |
void |
checkForTokenMatch(int bt)
|
void |
close()
Closes this input stream |
boolean |
dataMatch(byte[] d1,
byte[] d2)
Check for match of two byte arrays. |
java.io.InputStream |
getInputStream()
Get input stream this object is snooping on |
boolean |
getSnoopEnable()
Get state of snooping on input stream |
int |
getSubTokenCount()
Get number of sub-tokens in current token when snooping for Tokens. |
void |
mark(int rdLimit)
|
boolean |
markSupported()
|
protected void |
notifySighting(Serialio.SnoopInputStream.Snoop s)
Notify listeners |
int |
read()
Reads data from the input stream. |
int |
read(byte[] buf)
Reads data from the input stream |
int |
read(byte[] buf,
int off,
int len)
Reads data from the input stream |
void |
removeSnoop(SnoopListener lsnr)
Remove 'Snoop' on input stream |
void |
removeSnoop(SnoopListener lsnr,
byte[] data)
Remove snoop on input stream |
void |
removeSnoop(SnoopListener lsnr,
java.lang.String data)
Remove 'Snoop' on input stream |
void |
removeTokenSnoop(int id)
Remove the Token snoop on input stream |
void |
reset()
|
void |
setEndTokenSnoop(SnoopTokenListener stl,
byte[] tokEnd,
int id)
Set a 'Token Snoop' on the input stream. |
void |
setInputStream(java.io.InputStream in)
Set input stream this object will snooping on |
void |
setSnoopEnable(boolean onOff)
Enable/disable snooping on input stream |
void |
setStreamID(int id)
Set the stream ID |
void |
snoop(byte b)
Forces the data through the snoop logic without having to read data from the input stream. |
void |
snoopEvent(byte[] data)
Receives notification when searched for data is sighted or timeout |
| Methods inherited from class java.io.InputStream |
skip |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.io.InputStream in
protected byte lastByte
| Constructor Detail |
public SnoopInputStream()
public SnoopInputStream(java.io.InputStream in)
| Method Detail |
public void setStreamID(int id)
public void snoop(byte b)
throws java.io.IOException,
ExTokenOverflow
java.io.IOException - if an I/O error occurs.
java.lang.ArrayIndexOutOfBoundsException - if token buffer gets exceeded
ExTokenOverflow
public int read()
throws java.io.IOException,
ExTokenOverflow
java.io.IOException - if an I/O error occurs.
java.lang.ArrayIndexOutOfBoundsException - if token buffer gets exceeded
ExTokenOverflow
public int read(byte[] buf)
throws java.io.IOException,
ExTokenOverflow
java.io.IOException - if an I/O error occurs.
java.lang.ArrayIndexOutOfBoundsException - if token buffer gets exceeded
ExTokenOverflow
public int read(byte[] buf,
int off,
int len)
throws java.io.IOException,
ExTokenOverflow
off - The beginning offset in the buffer where data will be putlen - The length of data requested to be put in the buffer
java.io.IOException - if an error occurs.
java.lang.ArrayIndexOutOfBoundsException - if token buffer gets exceeded
ExTokenOverflow
public void checkForTokenMatch(int bt)
throws ExTokenOverflow
ExTokenOverflow
public int available()
throws java.io.IOException
java.io.IOException - if an I/O error occurs.
public void close()
throws java.io.IOException
java.io.IOException - if an I/O error occurs.public void setSnoopEnable(boolean onOff)
onOff - The state of snoopingpublic boolean getSnoopEnable()
public java.io.InputStream getInputStream()
public int getSubTokenCount()
public void setInputStream(java.io.InputStream in)
in - The InputStreampublic boolean markSupported()
public void mark(int rdLimit)
public void reset()
throws java.io.IOException
java.io.IOException
public void addTokenSnoop(SnoopTokenListener stl,
byte[] tokBeg,
byte[] tokEnd,
byte separator,
int tok,
int id,
int tokLenMax)
stl - The listener for the Snoop (data pattern)tokBeg - The begin token to Snoop (search) fortokEnd - The end token to Snoop (search) forseparator - The separator which separates the tokenstok - The token number to be returnedid - The token id given to the tokentokLenMax - The maximum length of the token
public void setEndTokenSnoop(SnoopTokenListener stl,
byte[] tokEnd,
int id)
stl - The listener for the Snoop (data pattern)tokEnd - The end token to Snoop (search) forid - The token id given to the token
public void addTokenSnoop(SnoopTokenListener stl,
byte[] tokBeg,
byte[] tokEnd,
byte separator,
int tok,
int id)
stl - The listener for the Snoop (data pattern)tokBeg - The begin token to Snoop (search) fortokEnd - The end token to Snoop (search) forseparator - The separator which separates the tokensid - The token id given to the token
public void addTokenSnoop(SnoopTokenListener stl,
java.lang.String tokBeg,
java.lang.String tokEnd,
java.lang.String separator,
int tok,
int id)
stl - The listener for the Snoop (data pattern)tokBeg - The begin token to Snoop (search) fortokEnd - The end token to Snoop (search) forseparator - The separator which separates the tokensid - The token id given to the token
public void addTokenSnoop(SnoopTokenListener stl,
java.lang.String tokBeg,
java.lang.String tokEnd,
java.lang.String separator,
int tok,
int id,
int tokLenMax)
stl - The listener for the Snoop (data pattern)tokBeg - The begin token to Snoop (search) fortokEnd - The end token to Snoop (search) forseparator - The separator which separates the tokens.
Note: Separator is ignored when the parameter tokNum=0.id - The token id given to the tokentokLenMax - The maximum length of the tokenpublic void removeTokenSnoop(int id)
id - The token id to be removed
public void addSnoop(SnoopListener lsnr,
java.lang.String data,
boolean ignoreCase)
lsnr - The listener for the Snoop (data pattern)data - The data pattern to Snoop (search) forignoreCase - Ignore the case (only applies if data is ASCII)
public void addSnoop(SnoopListener lsnr,
byte[] data,
boolean ignoreCase)
lsnr - The listener for the Snoop (data pattern)data - The data pattern to Snoop (search) forignoreCase - Ignore the case (only applies if data is ASCII)
public void removeSnoop(SnoopListener lsnr,
java.lang.String data)
lsnr - Listener of Snoop to be removed.data - Snoop of Snoop to be removed.
Note: Snoop is only removed if lsnr & data match
public void removeSnoop(SnoopListener lsnr,
byte[] data)
lsnr - Listener of Snoop to be removed.data - Snoop of Snoop to be removed.
Note: Snoop is only removed if lsnr & data matchpublic void removeSnoop(SnoopListener lsnr)
lsnr - Listener of Snoop to be removed.
Note: ALL Snoops for this listener will be removed.
public boolean dataMatch(byte[] d1,
byte[] d2)
d1 - Byte array of datad2 - Byte array of datapublic void snoopEvent(byte[] data)
SnoopListener
snoopEvent in interface SnoopListenerprotected void notifySighting(Serialio.SnoopInputStream.Snoop s)
public void checkDataForMatch(byte b)
b - Byte to match.
Patterns are considered 'mutually exclusive' for example consider the
following snoops hi hihi hihihi and the data stream hihihi this will
find a match of hi(2), hi(4), hihi(4), hi(6), hihihi(6)
i.e. it will NOT generate two matches for the 'overlapping' pattern of hihi
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||