|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface CliProtocolHandler
The CliProtocolHandler handles the communications for various command line interface (CLI) protocols in a consistent manner.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.foxsmart.ic.net.ProtocolHandler |
|---|
ProtocolHandler.Protocol |
| Field Summary | |
|---|---|
static java.lang.String |
CR
A carriage return character. |
static int |
DEFAULT_NO_DATA_READ_DELAY
The number of 1/10 second increments that must pass without getting data before we consider a new data read complete. |
static java.lang.String |
PASSWORD_PROMPT
A password prompt. |
static java.lang.String |
USERNAME_PROMPT
A username prompt. |
| Fields inherited from interface com.foxsmart.ic.net.ProtocolHandler |
|---|
DEFAULT_PROTOCOL_TIMEOUT_SECONDS |
| Method Summary | |
|---|---|
void |
connect(java.lang.String hostname,
java.lang.Integer port,
java.lang.String username,
java.lang.String password,
java.lang.Integer timeout)
Connects to the hostname at the specified port number and authenticates with the remote device. |
void |
disconnect()
Disconnects the socket connection. |
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. |
int |
getDefaultNoDataReadDelay()
Gets the default no data read delay. |
java.io.InputStream |
getInputStream()
Returns the connection input stream. |
java.io.OutputStream |
getOutputStream()
Returns the connection output stream. |
boolean |
getPasswordUsed()
Gets whether the password was used for authentication. |
boolean |
getUsernameUsed()
Gets whether the username was used for authentication. |
boolean |
isConnected()
Returns true if the client is currently connected to a server. |
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 |
setPasswordUsed(boolean passwordUsed)
Sets whether the password was used for authentication. |
void |
setUsernameUsed(boolean usernameUsed)
Sets whether the username was used for authentication. |
void |
write(java.lang.String text)
Writes the specified string to the device. |
| Methods inherited from interface com.foxsmart.ic.net.ProtocolHandler |
|---|
getAvailable, getDefaultProtocolTimeout, getProtocol, setDefaultProtocolTimeout |
| Field Detail |
|---|
static final java.lang.String USERNAME_PROMPT
static final java.lang.String PASSWORD_PROMPT
static final java.lang.String CR
static final int DEFAULT_NO_DATA_READ_DELAY
| Method Detail |
|---|
void connect(java.lang.String hostname,
java.lang.Integer port,
java.lang.String username,
java.lang.String password,
java.lang.Integer timeout)
throws java.lang.Exception
hostname - The name of the remote host.port - The port to connect to on the remote host. If null is passed in, a default port will be used.username - The username to connect with. Null should be passed in if no username is required.password - The password to connect with. Null should be passed in if no password is required.timeout - The timeout in seconds. If null is passed in, a default timeout will be used.
AuthenticationFailedException - when a successful connection could not be made
java.net.SocketException - if the socket timeout could not be set.
java.io.IOException - if the socket could not be opened. In most cases you will only want to catch IOException
since SocketException is derived from it.
ThreadTimeoutException - if a timeout occurred while connecting to the router.
java.net.UnknownHostException - If the hostname cannot be resolved.
java.lang.Exception - if any other problems were encountered.boolean isConnected()
void disconnect()
throws java.io.IOException
java.io.IOException - If there is an error closing the socket.void setUsernameUsed(boolean usernameUsed)
usernameUsed - True if the username was used or false if not.boolean getUsernameUsed()
void setPasswordUsed(boolean passwordUsed)
passwordUsed - True if the password was used or false if not.boolean getPasswordUsed()
java.io.InputStream getInputStream()
java.io.OutputStream getOutputStream()
void write(java.lang.String text)
throws java.io.IOException
text - The text to write to the device.
java.io.IOException - if there was a problem writing the data.
void sendCommand(java.lang.String command)
throws java.io.IOException
command - The command to send to the device.
java.io.IOException - if there was a problem sending the command.
void sendCommand(java.lang.String command,
boolean containsPassword)
throws java.io.IOException
command - 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.
java.lang.String expect(java.lang.String match,
boolean includeMatch)
throws java.lang.Exception
match - 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.
java.lang.String expect(java.util.List matches,
boolean includeMatch)
throws java.lang.Exception
matches - 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.
java.lang.String expect(java.lang.String match)
throws java.lang.Exception
match - 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.
java.lang.String expect(java.util.List matches)
throws java.lang.Exception
matches - 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.
java.lang.String expect(java.lang.String match,
boolean includeMatch,
java.lang.Integer timeout)
throws java.lang.Exception
match - 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.
java.lang.String expect(java.util.List matches,
boolean includeMatch,
java.lang.Integer timeout)
throws java.lang.Exception
matches - 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.
java.lang.String read()
throws java.lang.Exception
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.
java.lang.String read(java.lang.Integer timeout)
throws java.lang.Exception
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.void setDefaultNoDataReadDelay(int delay)
delay - The default no data read delay.int getDefaultNoDataReadDelay()
java.lang.String getAscii(java.lang.String string,
int pos)
string - the string to logpos - the byte position of the read string
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||