public class NetServerMessage extends LayoutMessage
NetServerChannel
. A
message is composed of a fixed set of codes, zero or more
labels, and zero or more data bytes. A NetServerMessage
is transmitted through the wire in the following serialized format:
+-+-----+-+-+----------------------------------------------------+ |V|12345|F|T|QOI<FS>KVVV...V<FS>KVVV...V<GS>SSIRMMPDDD......DDXXX| +-+-----+-+-+----------------------------------------------------+ Message Header (8 Bytes) V: Version Code (0x1E) L: Length (12345) F: Padding Count (X) T: Type Code Message Data (L-8 Bytes) Q: Sequence Number O: Operation Code <FS>: Field Separator (0x1C) K: Label Name V: Label Data Bytes <GS>: Group Separator (0x1D) S: Server Code I: Session ID Code R: Request/Reply Code M: Form Code P: Protection Code D: Data Bytes X: Padding Bytes (F)
Modifier and Type | Class and Description |
---|---|
static interface |
NetServerMessage.Label
Defines the possible labels of a
NetServerMessage . |
static interface |
NetServerMessage.Oper
Defines the operation codes of a
NetServerMessage . |
static interface |
NetServerMessage.Prot
Defines the protection codes of a
NetServerMessage . |
static interface |
NetServerMessage.Reply
Defines the reply codes of a
NetServerMessage . |
static interface |
NetServerMessage.Type
Defines the possible types of a
NetServerMessage . |
Constructor and Description |
---|
NetServerMessage()
Creates a new
NetServerMessage instance with zero length data. |
NetServerMessage(String data)
Creates a new
NetServerMessage with the supplied data . |
Modifier and Type | Method and Description |
---|---|
NetServerMessage |
clone()
Returns a "deep" copy of this
NetServerMessage . |
void |
copyFrom(NetServerMessage source)
Copies all the properties of source into this
NetServerMessage . |
String |
getData()
Returns the text data of this
NetServerMessage with trailing
spaces removed (right trimmed). |
String |
getDataAll()
Returns the text data of this
NetServerMessage with trailing
spaces preserved (not removed). |
byte[] |
getDataBytes()
Returns the binary data of this
NetServerMessage . |
int |
getFormCode()
Returns the form code of this
NetServerMessage . |
String |
getLabel(int key)
Returns the string value of the label identified by
key . |
String |
getMulticatName()
Returns the multicast name of this
NetServerMessage . |
int |
getOpCode()
Returns the operation code of this
NetServerMessage . |
int |
getProtCode()
Returns the protection code of this
NetServerMessage . |
int |
getReplyCode()
Returns the reply code of this
NetServerMessage . |
int |
getSequence()
Returns the sequence of this
NetServerMessage . |
int |
getServerCode()
Returns the server code of this
NetServerMessage . |
int |
getSessionID()
Returns the session ID of this
NetServerMessage . |
int |
getTranCode()
Returns the transaction code of this
NetServerMessage . |
int |
getType()
Returns the type of this
NetServerMessage . |
boolean |
isDataOnly()
Returns
true if this NetServerMessage has data and no headers. |
boolean |
isLabelDefined(int key)
Returns
true if the label indexed by key is defined. |
void |
removeLabel(int key)
Removes the label identified by
key from this NetServerMessage . |
void |
removeLabels()
Removes all the labels defined in this
NetServerMessage . |
byte[] |
serialize()
Returns a serialized version of this
NetServerMessage . |
byte[] |
serialize(boolean withType)
Returns a serialized version of this
NetServerMessage with
optional type code. |
void |
setData(String data)
Changes the text data of this
NetServerMessage . |
void |
setDataBytes(byte[] bytes)
Changes the binary data of this
NetServerMessage . |
void |
setDataOnly(boolean isDataOnly)
Changes whether this
NetServerMessage has data and no headers. |
void |
setFormCode(int formCode)
Changes the form code of this
NetServerMessage . |
void |
setLabel(int key,
String value)
Changes the string value of the label identified by
key . |
void |
setOpCode(int opcode)
Changes the operation code of this
NetServerMessage . |
void |
setProtCode(int protCode)
Changes the protection code of this
NetServerMessage . |
void |
setReplyCode(int replyCode)
Changes the reply code of this
NetServerMessage . |
void |
setSequence(int sequence)
Changes the sequence of this
NetServerMessage . |
void |
setServerCode(int serverCode)
Changes the server code of this
NetServerMessage . |
void |
setSessionID(int sessionID)
Changes the session ID of this
NetServerMessage . |
void |
setTranCode(int tranCode)
Changes the transaction code of this
NetServerMessage . |
void |
setType(int type)
Changes the type of this
NetServerMessage . |
String |
toString()
Returns a string representation of this
NetServerMessage . |
static NetServerMessage |
unserialize(byte[] bytes,
int offset,
int length)
Creates a new
NetServerMessage by unserializing the supplied byte
array. |
static NetServerMessage |
unserialize(byte[] bytes,
int offset,
int length,
boolean withType)
Creates a new
NetServerMessage by unserializing the supplied byte
array. |
copyFrom, exists, getChar, getChar, getDate, getDate, getDefaultSignANSI, getDouble, getDouble, getField, getInteger, getInteger, getLayout, getLong, getLong, getNumber, getNumber, getOccurs, getString, getString, getSubstring, getSubstring, getText, getText, getTextLen, getTextTrim, getValue, getValue, initFields, initFields, isNull, isNull, isNull, isSignANSI, setChar, setChar, setDate, setDate, setDefaultSignANSI, setDouble, setDouble, setInteger, setInteger, setLayout, setLong, setLong, setNull, setNull, setNumber, setNumber, setSignANSI, setString, setString, setSubstring, setText, setValue, setValue, toXml, toXml, verifyLayout
public NetServerMessage()
NetServerMessage
instance with zero length data.
The message codes are set to default values, and no message labels are
defined.public NetServerMessage(String data)
NetServerMessage
with the supplied data
.
The codes of the new message are set to default values, and no message
labels are defined.data
- the initial data of the NetServerMessage
.public final int getType()
NetServerMessage
.NetServerMessage
.public final void setType(int type)
NetServerMessage
.type
- the new type of this NetServerMessage
.public final int getSequence()
NetServerMessage
.NetServerMessage
.public final void setSequence(int sequence)
NetServerMessage
.sequence
- new NetServerMessage
sequence.public final int getOpCode()
NetServerMessage
.NetServerMessage
.public final void setOpCode(int opcode)
NetServerMessage
.opcode
- new NetServerMessage
operation code.public final int getServerCode()
NetServerMessage
.NetServerMessage
.public final void setServerCode(int serverCode)
NetServerMessage
.serverCode
- new NetServerMessage
server code.public final int getSessionID()
NetServerMessage
.NetServerMessage
.public final void setSessionID(int sessionID)
NetServerMessage
.sessionID
- new NetServerMessage
session ID.public final int getTranCode()
NetServerMessage
.NetServerMessage
.public final void setTranCode(int tranCode)
NetServerMessage
.tranCode
- new NetServerMessage
transaction code.public final int getReplyCode()
NetServerMessage
.NetServerMessage
.public final void setReplyCode(int replyCode)
NetServerMessage
.replyCode
- new NetServerMessage
reply code.public final int getFormCode()
NetServerMessage
.NetServerMessage
.public final void setFormCode(int formCode)
NetServerMessage
.formCode
- new NetServerMessage
form code.public final int getProtCode()
NetServerMessage
.NetServerMessage
.public final void setProtCode(int protCode)
NetServerMessage
.protCode
- new NetServerMessage
protection code.public final void removeLabels()
NetServerMessage
.public final boolean isLabelDefined(int key)
true
if the label indexed by key is defined.key
- the index of the label (LABEL_XXXXX
).true
if the label indexed by key
is defined.public final String getLabel(int key)
key
. If the
required label is not defined, it returns null
. There is not way
to know if the value of a label is actually null
or if the label
was undefined.key
- the index of the label (LABEL_XXXXX
).IndexOutOfBoundsException
- if key
is out-of-range.public final void removeLabel(int key)
key
from this NetServerMessage
. Nothing happens if the label is not defined in this
NetServerMessage
.key
- the index of the label (LABEL_XXXXX
).IndexOutOfBoundsException
- if key
is out-of-range.public final void setLabel(int key, String value)
key
. Setting
the value of the label to null
has the effect as removing the
label from this NetServerMessage
. That is, it has exactly the
same effect as calling the removeLabel
method with
the same key
.key
- the index of the label (LABEL_XXXXX
).value
- new value of the label or null
.IndexOutOfBoundsException
- if key
is out-of-range.public final String getMulticatName()
NetServerMessage
. If this is
not a multicast message, it returnes null
.null
.public final boolean isDataOnly()
true
if this NetServerMessage
has data and no headers.true
if this NetServerMessage
has data and no headers.public final void setDataOnly(boolean isDataOnly)
NetServerMessage
has data and no headers.isDataOnly
- the new value of the data only property.public final String getDataAll()
NetServerMessage
with trailing
spaces preserved (not removed).public final String getData()
NetServerMessage
with trailing
spaces removed (right trimmed).public final void setData(String data)
NetServerMessage
.data
- the new text data of this NetServerMessage
.public final byte[] getDataBytes()
NetServerMessage
.NetServerMessage
.public final void setDataBytes(byte[] bytes)
NetServerMessage
.bytes
- the new binary data of this NetServerMessage
.public final void copyFrom(NetServerMessage source)
NetServerMessage
.
The values of all properties in this NetServerMessage
are
replaced by copies of the values of corresponding source properties.source
- the source NetServerMessage
to be copied.NullPointerException
- if source
is null
.public NetServerMessage clone()
NetServerMessage
.clone
in class LayoutMessage
NetServerMessage
.public String toString()
NetServerMessage
.toString
in class LayoutMessage
NetServerMessage
.public final byte[] serialize()
NetServerMessage
. This
method has exactly the same effect as calling serialize(false)
.NetServerMessage
.public final byte[] serialize(boolean withType)
NetServerMessage
with
optional type code. See NetServerMessage
for a detailed
explanation of how a NetServerMessage
is serialized.withType
- if true
the result includes the message type.NetServerMessage
.public static NetServerMessage unserialize(byte[] bytes, int offset, int length)
NetServerMessage
by unserializing the supplied byte
array. This method has exactly the same effect as calling unserialize(bytes, offset,
length, false)
.bytes
- array of bytes containing a serialized NetServerMessage
.offset
- initial offset of the bytes
subarray.length
- length of the bytes
subarray.NetServerMessage
.public static NetServerMessage unserialize(byte[] bytes, int offset, int length, boolean withType)
NetServerMessage
by unserializing the supplied byte
array. See NetServerMessage
for a detailed explanation of how a
NetServerMessage
is serialized.bytes
- array of bytes containing a serialized NetServerMessage
.offset
- initial offset of the bytes
subarray.length
- length of the bytes
subarray.withType
- if true
bytes
include the message type.NetServerMessage
.Copyright © OBCOM INGENIERIA S.A. (Chile). All Rights Reserved.