| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
org.sadun.util.TelnetInputStreamConsumer
This class wraps over a TelnetInputStreamto provide
 stream consumption capabilities.
 
 Input from the stream can be consumed until on a certain
 criterium(i.e., a condition)
 holds.
 
 A timeoutcan be set on
 consumption operations to handle situations where the telnet host does not
 behave as expected.
 
Common criteria, based on looking for strings in the input, are already implemented as methods.
 A general #consumeByCriteria(Criterium)method allows the user to
 provide customized criteria if necessary.
 
 The class
 CompositeCriterium
 allows to combine a set of criteria into one, use it to drive input
 consumption and then find out which one of the set did indeed hold.
| Nested Class Summary | |
| static class | TelnetInputStreamConsumer.AndCriteriumA criterium which holds if all its composing criteria hold. | 
| static class | TelnetInputStreamConsumer.CompositeCriteriumAn abstract criterium based on other criteria. | 
| static class | TelnetInputStreamConsumer.ContainsStringCriteriumA criterium which holds if a certain string is found in the input. | 
| static interface | TelnetInputStreamConsumer.CriteriumA criterium for evaluating input from a TelnetInputStream. | 
| static class | TelnetInputStreamConsumer.NoMoreInputAvailableCriteriumA criterium which holds if no more input is available within a certain amount of time (i.e. we can suppose that the host has nothing more to say). | 
| static class | TelnetInputStreamConsumer.OrCriteriumA criterium which holds if one of its composing criteria hold. | 
| static class | TelnetInputStreamConsumer.PatternBasedCriteriumA criterium based on regular expression matching. | 
| static class | TelnetInputStreamConsumer.StringEndBasedCriteriumA criterium which holds if a certain string is found at the end of the input. | 
| Field Summary | |
| static long | BASIC_CRITERIA_CHECK_TIMEThe minimum granularity (in milliseconds) with which consumption criteria are checked. | 
| Fields inherited from class java.io.FilterInputStream | 
| in | 
| Constructor Summary | |
| TelnetInputStreamConsumer(TelnetInputStream is) | |
| Method Summary | |
|  java.lang.String | consumeByCriteria(TelnetInputStreamConsumer.Criterium criteria)Consumes the input based on some criterium. | 
|  java.lang.String | consumeInput(long timeout)Consumes all input that appears within a certain timeout. | 
|  java.lang.String | consumeInput(java.util.regex.Pattern toMatch)Consume all the input until a pattern is matched at the end of the input sequence | 
|  java.lang.String | consumeInput(java.util.regex.Pattern toMatch,
             boolean onlyAtEnd)Consume all the input until a pattern is matched - possibly only at the end of the input sequence | 
|  java.lang.String | consumeInputUntilStringFound(java.lang.String s)Consume all the input until a string is found in it (may be faster than {@link #consumeInput(Pattern) for constant patterns). | 
|  java.lang.String | consumeInputUntilStringFound(java.lang.String[] s)Consume all the input until one of a set strings is found in it (may be faster than {@link #consumeInput(Pattern) for constant patterns). | 
|  java.lang.String | consumeInputUntilStringFoundAtEnd(java.lang.String s)Consume all the input until a given string is found at the end of it (faster than {@link #consumeInput(Pattern) for constant patterns). | 
|  java.lang.String | consumeInputUntilStringFoundAtEnd(java.lang.String[] s)Consume all the input until one of a set of given strings is found at the end of it (faster than {@link #consumeInput(Pattern) for constant patterns). | 
|  boolean | consumeUntilResultOrFailure(java.lang.String successString,
                            java.lang.String failureString,
                            java.lang.String[] result)This method implements a typical consumption pattern when a command is sent programmaticly over a telnet channel, and one of two results may incur as a result in the host output (that is, this inputstream). | 
|  long | getConsumptionOperationsTimeout()Get the timeout on all consumption operations. | 
|  void | registerTelnetCommandListener(TelnetInputStream.TelnetCommandListener tcl)Register a listener to Telnet commands. | 
|  void | removeTelnetCommandListener(TelnetInputStream.TelnetCommandListener tcl)Remove a listener to Telnet commands. | 
|  void | setConsumptionOperationsTimeout(long consumptionOperationsTimeout)Set the timeout on all consumption operations. | 
| Methods inherited from class java.io.FilterInputStream | 
| available, close, mark, markSupported, read, read, read, reset, skip | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
public static final long BASIC_CRITERIA_CHECK_TIME
| Constructor Detail | 
public TelnetInputStreamConsumer(TelnetInputStream is)
| Method Detail | 
public void registerTelnetCommandListener(TelnetInputStream.TelnetCommandListener tcl)
tcl - the listener to registerpublic void removeTelnetCommandListener(TelnetInputStream.TelnetCommandListener tcl)
tcl - the listener to remove
public java.lang.String consumeInput(long timeout)
                              throws java.io.IOException
java.io.IOException
public java.lang.String consumeInput(java.util.regex.Pattern toMatch,
                                     boolean onlyAtEnd)
                              throws java.io.IOException,
                                     OperationTimedoutException
toMatch - onlyAtEnd - 
java.io.IOException
OperationTimedoutException
public java.lang.String consumeInput(java.util.regex.Pattern toMatch)
                              throws java.io.IOException,
                                     OperationTimedoutException
toMatch - 
java.io.IOException
OperationTimedoutException
public java.lang.String consumeInputUntilStringFoundAtEnd(java.lang.String s)
                                                   throws java.io.IOException,
                                                          OperationTimedoutException
s - 
java.io.IOException
OperationTimedoutException
public java.lang.String consumeInputUntilStringFoundAtEnd(java.lang.String[] s)
                                                   throws java.io.IOException,
                                                          OperationTimedoutException
s - 
java.io.IOException
OperationTimedoutException
public java.lang.String consumeInputUntilStringFound(java.lang.String s)
                                              throws java.io.IOException,
                                                     OperationTimedoutException
s - 
java.io.IOException
OperationTimedoutException
public java.lang.String consumeInputUntilStringFound(java.lang.String[] s)
                                              throws java.io.IOException,
                                                     OperationTimedoutException
s - 
java.io.IOException
OperationTimedoutException
public java.lang.String consumeByCriteria(TelnetInputStreamConsumer.Criterium criteria)
                                   throws java.io.IOException,
                                          OperationTimedoutException
criterium.
 
 The
 consumption operations timeout
 is used for checking timeouts.
criteria - 
java.io.IOException
OperationTimedoutException
public boolean consumeUntilResultOrFailure(java.lang.String successString,
                                           java.lang.String failureString,
                                           java.lang.String[] result)
                                    throws java.io.IOException,
                                           OperationTimedoutException
 setConsumptionOperationsTimeout(long)can be used to impose a
 timeout on the result.
result - 
OperationTimedoutException
java.io.IOExceptionpublic long getConsumptionOperationsTimeout()
public void setConsumptionOperationsTimeout(long consumptionOperationsTimeout)
consumptionOperationsTimeout - the timeout on all consumption operations.| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||