|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.foxsmart.ic.net.AbstractCliProtocolHandler
public abstract class AbstractCliProtocolHandler
The AbstractProtocolHandler class provides base functionality for protocols handlers.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.foxsmart.ic.net.ProtocolHandler |
|---|
ProtocolHandler.Protocol |
| Field Summary | |
|---|---|
protected int |
defaultNoDataReadDelay
|
protected java.lang.Integer |
defaultProtocolTimeout
|
protected org.apache.commons.logging.Log |
log
|
static java.lang.String |
PASSWORD_MASK
|
| Fields inherited from interface com.foxsmart.ic.net.CliProtocolHandler |
|---|
CR, DEFAULT_NO_DATA_READ_DELAY, PASSWORD_PROMPT, USERNAME_PROMPT |
| Fields inherited from interface com.foxsmart.ic.net.ProtocolHandler |
|---|
DEFAULT_PROTOCOL_TIMEOUT_SECONDS |
| Constructor Summary | |
|---|---|
AbstractCliProtocolHandler()
Default Constructor. |
|
| Method Summary | |
|---|---|
void |
disconnect()
This method sets the usernameUsed and passwordUsed flags to false. |
java.lang.String |
expect(java.util.List matches)
Reads data from the device until one of the expected strings is found. |
java.lang.String |
expect(java.util.List matches,
boolean includeMatch)
Reads data from the device until one of the expected strings is found. |
java.lang.String |
expect(java.util.List matches,
boolean includeMatch,
java.lang.Integer timeout)
Reads data from the device until one of a list of expected strings is found. |
java.lang.String |
expect(java.lang.String match)
Reads data from the device until the expected string is found. |
java.lang.String |
expect(java.lang.String match,
boolean includeMatch)
Reads data from the device until the expected string is found. |
java.lang.String |
expect(java.lang.String match,
boolean includeMatch,
java.lang.Integer timeout)
Reads data from the device until the expected string is found. |
java.lang.String |
getAscii(java.lang.String string,
int pos)
Gets a formatted ASCII dump of the passed in string. |
boolean |
getAvailable()
Default implementation returns true. |
int |
getDefaultNoDataReadDelay()
Gets the default no data read delay. |
java.lang.Integer |
getDefaultProtocolTimeout()
Gets the default operation timeout value. |
boolean |
getPasswordUsed()
Gets whether the password was used for authentication. |
boolean |
getUsernameUsed()
Gets whether the username was used for authentication. |
java.lang.String |
read()
Reads the next set of data from the device until enough time has passed that we assume no more data will arrive. |
java.lang.String |
read(java.lang.Integer timeout)
Reads the next set of data from the device until enough time has passed that we assume no more data will arrive. |
void |
sendCommand(java.lang.String command)
Sends a command to the device. |
void |
sendCommand(java.lang.String command,
boolean containsPassword)
Sends a command to the device. |
void |
setDefaultNoDataReadDelay(int delay)
Modifies the default no data read delay in 1/10 seconds. |
void |
setDefaultProtocolTimeout(java.lang.Integer timeout)
Modifies the default operation protocol timeout value. |
void |
setPasswordUsed(boolean passwordUsed)
Sets whether the password was used for authentication. |
void |
setUsernameUsed(boolean usernameUsed)
Sets whether the username was used for authentication. |
java.lang.String |
toString()
|
void |
write(java.lang.String text)
Writes the specified string to the telnet device. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.foxsmart.ic.net.CliProtocolHandler |
|---|
connect, getInputStream, getOutputStream, isConnected |
| Methods inherited from interface com.foxsmart.ic.net.ProtocolHandler |
|---|
getProtocol |
| Field Detail |
|---|
protected org.apache.commons.logging.Log log
protected java.lang.Integer defaultProtocolTimeout
protected int defaultNoDataReadDelay
public static final java.lang.String PASSWORD_MASK
| Constructor Detail |
|---|
public AbstractCliProtocolHandler()
| Method Detail |
|---|
public void write(java.lang.String text)
throws java.io.IOException
write in interface CliProtocolHandlertext - The text to write to the device.
java.io.IOException - if there was a problem writing the data.
public void sendCommand(java.lang.String command)
throws java.io.IOException
CliProtocolHandler
sendCommand in interface CliProtocolHandlercommand - The command to send to the device.
java.io.IOException - if there was a problem sending the command.CliProtocolHandler.sendCommand(String)
public void sendCommand(java.lang.String command,
boolean containsPassword)
throws java.io.IOException
CliProtocolHandler
sendCommand in interface CliProtocolHandlercommand - The command to send to the device.containsPassword - true if the command contains a password or false if not. Send true to cause the password
to only be logged in "trace" mode.
java.io.IOException - if there was a problem sending the command.CliProtocolHandler.sendCommand(String, boolean)
public java.lang.String expect(java.lang.String match,
boolean includeMatch)
throws java.lang.Exception
expect in interface CliProtocolHandlermatch - The string to search for.includeMatch - If true, the match string is returned in the resulting data string. If false, the match
string is not returned as part of the resultant string.
ThreadTimeoutException - if the expected string was not found within the passed in
timeout period.
java.io.IOException - if there was an error reading data from the device.
java.lang.Exception - if any other unexpected error occurs.
public java.lang.String expect(java.util.List matches,
boolean includeMatch)
throws java.lang.Exception
expect in interface CliProtocolHandlermatches - The strings to search for.includeMatch - If true, the match string is returned in the resulting data string. If false, the match
string is not returned as part of the resultant string.
ThreadTimeoutException - if the expected string was not found within the passed in
timeout period.
java.io.IOException - if there was an error reading data from the device.
java.lang.Exception - if any other unexpected error occurs.
public java.lang.String expect(java.lang.String match)
throws java.lang.Exception
expect in interface CliProtocolHandlermatch - The string to search for.
ThreadTimeoutException - if the expected string was not found within the passed in
timeout period.
java.io.IOException - if there was an error reading data from the device.
java.lang.Exception - if any other unexpected error occurs.
public java.lang.String expect(java.util.List matches)
throws java.lang.Exception
expect in interface CliProtocolHandlermatches - The strings to search for.
ThreadTimeoutException - if the expected string was not found within the passed in
timeout period.
java.io.IOException - if there was an error reading data from the device.
java.lang.Exception - if any other unexpected error occurs.
public java.lang.String read()
throws java.lang.Exception
read in interface CliProtocolHandlerThreadTimeoutException - if the expected string was not found within the passed in
timeout period.
java.io.IOException - if there was an error reading data from the device.
java.lang.Exception - if any other unexpected error occurs.
public java.lang.String expect(java.lang.String match,
boolean includeMatch,
java.lang.Integer timeout)
throws java.lang.Exception
expect in interface CliProtocolHandlermatch - The string to search for.includeMatch - If true, the match string is returned in the resulting data string. If false, the match
string is not returned as part of the resultant string.timeout - The timeout value in seconds to wait for the data to be returned. If null is passed, no timeout
will be used. Beware that if the expected match string is not found or if the device doesn't respond, this method
will not return.
ThreadTimeoutException - if the expected string was not found within the passed in
timeout period.
java.io.IOException - if there was an error reading data from the device.
java.lang.Exception - if any other unexpected error occurs.
public java.lang.String expect(java.util.List matches,
boolean includeMatch,
java.lang.Integer timeout)
throws java.lang.Exception
expect in interface CliProtocolHandlermatches - The strings to search for.includeMatch - If true, the match string is returned in the resulting data string. If false, the match
string is not returned as part of the resultant string.timeout - The timeout value in seconds to wait for the data to be returned. If null is passed, no timeout
will be used. Beware that if the expected match string is not found or if the device doesn't respond, this method
will not return.
ThreadTimeoutException - if the expected string was not found within the passed in
timeout period.
java.io.IOException - if there was an error reading data from the device.
java.lang.Exception - if any other unexpected error occurs.
public java.lang.String read(java.lang.Integer timeout)
throws java.lang.Exception
read in interface CliProtocolHandlertimeout - The timeout value in seconds to wait for the data to be returned. If null is passed, no timeout
will be used. Beware that if the expected match string is not found or if the device doesn't respond, this method
will not return.
ThreadTimeoutException - if the expected string was not found within the passed in
timeout period.
java.io.IOException - if there was an error reading data from the device.
java.lang.Exception - if any other unexpected error occurs.
public java.lang.String getAscii(java.lang.String string,
int pos)
getAscii in interface CliProtocolHandlerstring - the string to logpos - the byte position of the read string
public void setDefaultProtocolTimeout(java.lang.Integer timeout)
setDefaultProtocolTimeout in interface ProtocolHandlertimeout - The default timeout value in seconds to wait for the data to be returned. If null is passed, no
timeout will be used. Beware that if an expected match string is not found or if the device doesn't respond, the
expect method will not return.public java.lang.Integer getDefaultProtocolTimeout()
getDefaultProtocolTimeout in interface ProtocolHandlerpublic void setDefaultNoDataReadDelay(int delay)
setDefaultNoDataReadDelay in interface CliProtocolHandlerdelay - The default no data read delay.public int getDefaultNoDataReadDelay()
getDefaultNoDataReadDelay in interface CliProtocolHandlerpublic void setUsernameUsed(boolean usernameUsed)
setUsernameUsed in interface CliProtocolHandlerusernameUsed - True if the username was used or false if not.public boolean getUsernameUsed()
getUsernameUsed in interface CliProtocolHandlerpublic void setPasswordUsed(boolean passwordUsed)
setPasswordUsed in interface CliProtocolHandlerpasswordUsed - True if the password was used or false if not.public boolean getPasswordUsed()
getPasswordUsed in interface CliProtocolHandler
public void disconnect()
throws java.io.IOException
disconnect in interface CliProtocolHandlerjava.io.IOException - If there is an error closing the socket.public boolean getAvailable()
getAvailable in interface ProtocolHandlerpublic java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||