|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectSerialio.SnoopLoop
Used to look for data patterns in a SnoopInputStream. This is a 'convenience' class in that it does not require method caller to read the SnoopInputStream directly to 'make things happen' and provides a timeout.
| Field Summary | |
protected java.io.InputStream |
in
|
| Constructor Summary | |
SnoopLoop()
This empty constructor is for Bean friendlyness |
|
SnoopLoop(SnoopLoopListener lsnr,
SnoopInputStream sis,
int napTime)
Create an input stream that allows 'snooping' for data patterns on incoming data |
|
| Method Summary | |
void |
abort()
Abort this task |
boolean |
getDataDiscard(boolean onOff)
Get the 'data discard' mode. |
int |
getNapTime()
Get the nap time used when the method sleeps. |
byte[] |
getReadBuffer()
Get the current read buffer. |
void |
setDataDiscard(boolean onOff)
Set the 'data discard' mode. |
void |
setNapTime(int time)
Set the nap time used when the method sleeps. |
void |
setReadBuffer(byte[] buf)
Set the read buffer used when snooping for data |
void |
snoopEvent(byte[] data)
This method is called by the SnoopInputStream when the data pattern is sighted. |
int |
waitFor(byte[] sData,
int tmo)
Wait for data pattern to occur on SnoopInputStream. |
int |
waitFor(int wCnt,
int tmo)
Wait for specified number of bytes to arrive on the stream. |
int |
waitFor(java.lang.String sData,
int tmo)
Wait for data pattern to occur on SnoopInputStream. |
| 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
| Constructor Detail |
public SnoopLoop()
public SnoopLoop(SnoopLoopListener lsnr,
SnoopInputStream sis,
int napTime)
lsnr - The SnoopLoopListener that will be called when data is received
on the stream.sis - The SnoopInputStream to look for data pattern.napTime - The timeout if the pattern is not seen.| Method Detail |
public int waitFor(java.lang.String sData,
int tmo)
throws java.io.IOException,
java.lang.InterruptedException
sData - The data pattern.tmo - The timeout if the pattern is not seen.
Notes:
- If other snoops exist for the given SnoopInputStream they may be
called before this method completes.
- If the data received is larger than the size of the save buffer
the data at the start of the buffer will be overwritten.
- For performance reasons the save buffer is not cleared between calls
if you wish to clear the save buffer between calls use setReadBuffer.
java.io.IOException
java.lang.InterruptedException
public int waitFor(byte[] sData,
int tmo)
throws java.io.IOException,
java.lang.InterruptedException
sData - The data pattern.tmo - The timeout if the pattern is not seen.
Notes:
- If other snoops exist for the given SnoopInputStream they may be
called before this method completes.
- If the data received is larger than the size of the save buffer
the data at the start of the buffer will be overwritten.
- For performance reasons the save buffer is not cleared between calls
if you wish to clear the save buffer between calls use setReadBuffer.
java.io.IOException
java.lang.InterruptedException
public int waitFor(int wCnt,
int tmo)
throws java.io.IOException,
java.lang.InterruptedException
wCnt - The number of bytes to wait for.tmo - The timeout to wait for wCnt bytes.
Notes:
- If other snoops exist for the given SnoopInputStream they may be
called before this method completes.
- If the data received is larger than the size of the save buffer
the data at the start of the buffer will be overwritten.
- For performance reasons the save buffer is not cleared between calls
if you wish to clear the save buffer between calls use setReadBuffer.
java.io.IOException
java.lang.InterruptedExceptionpublic void snoopEvent(byte[] data)
snoopEvent in interface SnoopListenerpublic void setDataDiscard(boolean onOff)
onOff - Mode statepublic boolean getDataDiscard(boolean onOff)
public void setReadBuffer(byte[] buf)
buf - The byte[] bufferpublic byte[] getReadBuffer()
public void setNapTime(int time)
time - The time the thread sleeps between data checks.public int getNapTime()
public void abort()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||