Package jmri.jmrix
Class AbstractMRReply
- java.lang.Object
-
- jmri.jmrix.AbstractMessage
-
- jmri.jmrix.AbstractMRReply
-
- All Implemented Interfaces:
Message
- Direct Known Subclasses:
AcelaReply,CanReply,Dcc4PcReply,DCCppReply,EasyDccReply,EcosReply,GridConnectReply,IEEE802154Reply,JMRIClientReply,MarklinReply,NceReply,Reply,Reply,RfidReply,SerialReply,SerialReply,SerialReply,SerialReply,SerialReply,SerialReply,SerialReply,SpeedoReply,SprogReply,SRCPReply,TamsReply,XNetReply,Z21Reply
public abstract class AbstractMRReply extends AbstractMessage
Abstract base class for replies in a message/reply protocol.Handles the character manipulation.
This is a variable length reply, which can grow as needed. The length is given by the largest index written so far.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULTMAXSIZE-
Fields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars
-
-
Constructor Summary
Constructors Constructor Description AbstractMRReply()Create a new AbstractMRReply instance.AbstractMRReply(java.lang.String s)Create a new AbstractMRReply instance from a string.AbstractMRReply(AbstractMRReply m)Copy a Reply to a new AbstractMRReply instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidflush()Flush the message.intgetOpCode()Get the OpCode.booleanisBinary()Get if the Reply has Binary form flag set.booleanisRetransmittableErrorMsg()booleanisUnsolicited()Get flag for Unsolicited.intmatch(java.lang.String s)intmaxSize()intpollValue()voidsetBinary(boolean b)Set flag for if the Reply is Binary form.voidsetElement(int n, int v)Set a single Data Element at a particular index.voidsetOpCode(int i)Set the OpCode.voidsetUnsolicited()Set flag for Unsolicited to true.protected abstract intskipPrefix(int index)intskipWhiteSpace(int index)java.lang.StringtoString()intvalue()-
Methods inherited from class jmri.jmrix.AbstractMessage
equals, getElement, getNumDataElements, hashCode
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.jmrix.Message
toMonitorString
-
-
-
-
Field Detail
-
DEFAULTMAXSIZE
public static final int DEFAULTMAXSIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractMRReply
public AbstractMRReply()
Create a new AbstractMRReply instance.
-
AbstractMRReply
public AbstractMRReply(AbstractMRReply m)
Copy a Reply to a new AbstractMRReply instance.- Parameters:
m- the reply to copy
-
AbstractMRReply
public AbstractMRReply(java.lang.String s)
Create a new AbstractMRReply instance from a string.- Parameters:
s- String to use as reply content
-
-
Method Detail
-
setElement
public void setElement(int n, int v)
Description copied from class:AbstractMessageSet a single Data Element at a particular index.- Specified by:
setElementin interfaceMessage- Overrides:
setElementin classAbstractMessage- Parameters:
n- index of element.v- value of element.
-
setOpCode
public void setOpCode(int i)
Set the OpCode. Sets Element 0 to character value of integer.- Parameters:
i- Opcode value.
-
getOpCode
public int getOpCode()
Get the OpCode.- Returns:
- value of Element 0.
-
flush
public void flush()
Flush the message. Sets number of data characters to 0. Does not reset array length or data.
-
isBinary
public boolean isBinary()
Get if the Reply has Binary form flag set.- Returns:
- true if binary, else false.
-
setBinary
public void setBinary(boolean b)
Set flag for if the Reply is Binary form.- Parameters:
b- true if binary, else false.
-
setUnsolicited
public final void setUnsolicited()
Set flag for Unsolicited to true.
-
isUnsolicited
public boolean isUnsolicited()
Get flag for Unsolicited.- Returns:
- true if Unsolicited, else false.
-
isRetransmittableErrorMsg
public boolean isRetransmittableErrorMsg()
-
skipPrefix
protected abstract int skipPrefix(int index)
-
value
public int value()
-
pollValue
public int pollValue()
-
match
public int match(java.lang.String s)
-
skipWhiteSpace
public int skipWhiteSpace(int index)
-
maxSize
public int maxSize()
-
-