public abstract class AsciiCommandResponderBase extends AsciiResponseBase implements IAsciiCommandResponder
Modifier | Constructor and Description |
---|---|
protected |
AsciiCommandResponderBase()
Initializes a new instance of the AsciiCommandResponderBase class to respond to all commands
|
protected |
AsciiCommandResponderBase(java.lang.String commandName)
Initializes a new instance of the AsciiCommandResponderBase class to respond to a specific command
|
Modifier and Type | Method and Description |
---|---|
protected void |
buildCommandLine(java.lang.StringBuilder line)
Builds the command line to send to the reader to execute the command
|
void |
clearLastResponse()
Clears the response ready to receive a new one
|
java.lang.String |
getCommandLine()
Returns the Ascii command line (including terminators) to be sent to the device
|
java.lang.String |
getCommandName() |
ICommandResponseLifecycleDelegate |
getResponseLifecycleDelegate() |
protected boolean |
getResponseStarted() |
boolean |
isResponseFinished()
Gets a value indicating whether the response is complete (i.e.
|
java.lang.Iterable<java.lang.String> |
parseParameters(java.lang.String parameterLine)
Parses a PR: value for parameters and updates the command with the values parsed
|
boolean |
processReceivedLine(java.lang.String fullLine,
boolean moreLinesAvailable)
Each correctly terminated line from the device is passed to this method for processing
|
protected boolean |
processReceivedLine(java.lang.String fullLine,
java.lang.String header,
java.lang.String value,
boolean moreAvailable)
Each correctly terminated line from the device is passed to this method for processing
|
protected void |
responseDidFinish(boolean async)
The is called when the responder received a line with an OK: or an ER: header.
|
protected boolean |
responseDidReceiveParameter(java.lang.String parameter)
This method is called for each parameter in the parameters (PR:) list.
|
protected void |
responseDidStart()
This is called when the responder receives the CS: line
|
protected void |
setCommandName(java.lang.String value) |
void |
setResponseLifecycleDelegate(ICommandResponseLifecycleDelegate delegate) |
protected void |
setResponseStarted(boolean value) |
static java.util.Collection<java.lang.String> |
splitParameters(java.lang.String value)
Splits the given line into parameters separated by '-' but preserving quoted ("like - this") strings
|
appendToMessages, appendToParameters, appendToResponse, getErrorCode, getMessages, getParameters, getResponse, isSuccessful, setErrorCode, setIsSuccessful, setResponse
protected AsciiCommandResponderBase()
protected AsciiCommandResponderBase(java.lang.String commandName)
commandName
- The command name e.g. '.iv' for Inventory or string.Empty to respond to all commandspublic final java.lang.String getCommandName()
protected final void setCommandName(java.lang.String value)
public final boolean isResponseFinished()
IAsciiCommandResponder
isResponseFinished
in interface IAsciiCommandResponder
protected final boolean getResponseStarted()
protected final void setResponseStarted(boolean value)
public ICommandResponseLifecycleDelegate getResponseLifecycleDelegate()
public void setResponseLifecycleDelegate(ICommandResponseLifecycleDelegate delegate)
public static java.util.Collection<java.lang.String> splitParameters(java.lang.String value)
value
- The parameters to parsepublic java.lang.String getCommandLine()
public final java.lang.Iterable<java.lang.String> parseParameters(java.lang.String parameterLine)
parameterLine
- The line containing parameters to parsepublic void clearLastResponse()
clearLastResponse
in interface IAsciiCommandResponder
clearLastResponse
in class AsciiResponseBase
public final boolean processReceivedLine(java.lang.String fullLine, boolean moreLinesAvailable) throws java.lang.Exception
processReceivedLine
in interface IAsciiCommandResponder
fullLine
- The line to be processedmoreLinesAvailable
- When true indicates there are additional lines to be processed (and will also be passed to this method)java.lang.Exception
protected void buildCommandLine(java.lang.StringBuilder line)
line
- The command line to append to
When overriding this method call the base class to construct the command line as known to the base class and
then append the additional parameters to the end of the lineprotected boolean processReceivedLine(java.lang.String fullLine, java.lang.String header, java.lang.String value, boolean moreAvailable) throws java.lang.Exception
fullLine
- The line to be processedheader
- The response line header excluding the colon e.g. 'CS' for a command started responsevalue
- The response line following the colon e.g. '.iv'moreAvailable
- When true indicates there are additional lines to be processed (and will also be passed to this method)java.lang.Exception
protected void responseDidFinish(boolean async)
async
- True if the command finished asynchronously
Warning: To ensure correct operation of synchronous commands the super class method must be invokedprotected boolean responseDidReceiveParameter(java.lang.String parameter)
parameter
- A single parameter extracted from the PR: response, excluding the '-' and trimmed of leading and trailing whitespaceprotected void responseDidStart()