Package jmri.jmrix
Class AbstractMessage
- java.lang.Object
-
- jmri.jmrix.AbstractMessage
-
- All Implemented Interfaces:
Message
- Direct Known Subclasses:
AbstractMRMessage
,AbstractMRReply
,LocoNetMessage
,QsiMessage
,QsiReply
public abstract class AbstractMessage extends java.lang.Object implements Message
Base for various message implementations used by the various abstract TrafficController classes.
-
-
Field Summary
Fields Modifier and Type Field Description protected int[]
_dataChars
protected int
_nDataChars
-
Constructor Summary
Constructors Constructor Description AbstractMessage()
Create a new instance of AbstractMessage.AbstractMessage(int n)
Create a new instance of AbstractMessage of a given byte size.AbstractMessage(java.lang.String s)
AbstractMessage(AbstractMessage m)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Equals operator compares only base data.int
getElement(int n)
Get a particular element in a Message.int
getNumDataElements()
Get the number of data elements in a Message.int
hashCode()
Hash code from base data.void
setElement(int n, int v)
Set a single Data Element at a particular index.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.jmrix.Message
toMonitorString, toString
-
-
-
-
Field Detail
-
_dataChars
protected int[] _dataChars
-
_nDataChars
protected int _nDataChars
-
-
Constructor Detail
-
AbstractMessage
public AbstractMessage()
Create a new instance of AbstractMessage.
-
AbstractMessage
public AbstractMessage(int n)
Create a new instance of AbstractMessage of a given byte size.- Parameters:
n
- number of elements
-
AbstractMessage
public AbstractMessage(java.lang.String s)
-
AbstractMessage
public AbstractMessage(@Nonnull AbstractMessage m)
-
-
Method Detail
-
getElement
public int getElement(int n)
Get a particular element in a Message.- Specified by:
getElement
in interfaceMessage
- Parameters:
n
- Element Index.- Returns:
- single element of message.
-
getNumDataElements
public int getNumDataElements()
Get the number of data elements in a Message.- Specified by:
getNumDataElements
in interfaceMessage
- Returns:
- number elements.
-
setElement
public void setElement(int n, int v)
Set a single Data Element at a particular index.- Specified by:
setElement
in interfaceMessage
- Parameters:
n
- index of element.v
- value of element.
-
equals
public boolean equals(java.lang.Object obj)
Equals operator compares only base data.- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
Hash code from base data.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hashcode from sum of elements.
-
-