public final class ChannelAccessWriteMessage extends ChannelAccessMessage
CA_PROTO_WRITE
message that is sent from a
client to a server. This message is sent in order to write to a channel
without getting a response from the server.ChannelAccessCommand.CA_PROTO_WRITE
command, originalMessageHeader
Constructor and Description |
---|
ChannelAccessWriteMessage(ChannelAccessValueType dataType,
int count,
int sid,
int cid,
ChannelAccessPuttableValue<?> value)
Creates a
CA_PROTO_WRITE message. |
Modifier and Type | Method and Description |
---|---|
protected static ChannelAccessWriteMessage |
deserialize(ChannelAccessMessageHeader messageHeader,
ByteSource byteSource,
boolean headerOnly,
Charset charset)
Constructs a message from a header and a byte source.
|
boolean |
equals(Object obj)
Tells whether the specified object represents the same message.
|
int |
getChannelCID()
Returns the channel CID.
|
int |
getChannelSID()
Returns the channel SID.
|
int |
getCount()
Returns the number of elements the value in this message's payload has.
|
ChannelAccessValueType |
getDataType()
Returns the data type of the value in this message's payload.
|
ChannelAccessPuttableValue<?> |
getValue()
Returns the new value for the channel.
|
int |
hashCode()
Returns a hash code value for this message.
|
protected void |
serialize(ByteSink byteSink,
ChannelAccessVersion version,
int maxPayloadSize,
Charset charset)
Serializes this message to a byte sink.
|
String |
toString()
Returns a string representation of this message.
|
protected void |
verify(ChannelAccessVersion version,
int maxPayloadSize,
Charset charset)
Verifies that this message can be serialized.
|
addByteArrayToStringBuilder, calculatePaddingSize, getCommand, getOriginalMessageHeader, hasOriginalMessageHeader, serializeHeader, verifyHeader
public ChannelAccessWriteMessage(ChannelAccessValueType dataType, int count, int sid, int cid, ChannelAccessPuttableValue<?> value)
CA_PROTO_WRITE
message. This constructor should be
used to create a message that is supposed to be sent from a client to a
server.dataType
- data type of the value in the message's payload (never
null
). This must match the type of
value
.count
- number of value elements in the message's payload. This must
not be negative and not exceed the number of elements in
value
.sid
- server-assigned ID identifying the channel.cid
- client-assigned ID identifying the channel.value
- new value of the channel (never null
).IllegalArgumentException
- if the specified data type does not match the value's data
type or if count
is negative or greater than the
number of elements the value has.public ChannelAccessValueType getDataType()
null
if the specified data-type is unknown to this
implementation.null
if the numeric
identifier cannot be mapped to a data type known by this
implementation.public int getCount()
public int getChannelSID()
public int getChannelCID()
public ChannelAccessPuttableValue<?> getValue()
null
if the data-type sent by the client is not supported by
this implementation (getDataType()
returns null
).null
if the data type
is not supported. The value's data type is the same that is
returned by getDataType()
and the value's element count
is equal to or greater than the number returned by
getCount()
.protected void serialize(ByteSink byteSink, ChannelAccessVersion version, int maxPayloadSize, Charset charset)
ChannelAccessMessage
ChannelAccessMessageCodec
.serialize
in class ChannelAccessMessage
byteSink
- byte sink that is used for writing the serialized data.version
- protocol version to stay compatible with. This is the protocol
version of the peer the message is sent to.maxPayloadSize
- maximum size of the payload.charset
- encoding to use for serializing the string data (e.g. channel
names, error strings, string data-values).protected void verify(ChannelAccessVersion version, int maxPayloadSize, Charset charset)
ChannelAccessMessage
ChannelAccessMessageCodec
.verify
in class ChannelAccessMessage
version
- protocol version to stay compatible with. This is the protocol
version of the peer the message is sent to.maxPayloadSize
- maximum size of the payload.charset
- encoding to use for serializing the string data (e.g. channel
names, error strings, string data-values).public boolean equals(Object obj)
ChannelAccessMessage
Tells whether the specified object represents the same message.
Two messages are considered equal if they are of the same type and have the same headers and payload. For comparing the types, the actual Java type and not just the Channel Access command is compared.
equals
in class ChannelAccessMessage
obj
- reference object with which this object is compared.true
if obj
is a message that is of the
same type and has the same headers and payload as this message.
false
if obj
is null
or of
a different type than this message or differs in the headers or
payload.public int hashCode()
ChannelAccessMessage
Returns a hash code value for this message. This method is supported for the benefit of hash tables. The hash code is calculated as a combination of the hash codes of this messages headers (including the Channel Access command) and its payload (if present).
If two messages are equal (as indicated by the return value of
ChannelAccessMessage.equals(Object)
), they also have the same hash code. However, the
fact that two messages have the same hash code does not imply that they
are equal.
hashCode
in class ChannelAccessMessage
public String toString()
ChannelAccessMessage
toString
in class ChannelAccessMessage
protected static ChannelAccessWriteMessage deserialize(ChannelAccessMessageHeader messageHeader, ByteSource byteSource, boolean headerOnly, Charset charset)
ChannelAccessMessageCodec
.messageHeader
- CA message header.byteSource
- byte source for reading the message's payload (if any).headerOnly
- if true
this method will not try to read the
payload but just read the header. This is useful for reading a
message that is sent in the payload of a
ChannelAccessErrorMessage
. Such a message will have
all headers but no payload (even so the payload size might be
non-zero).charset
- encoding to use for deserializing the host name. Usually, host
names should consist of ASCII characters only, however this is
not strictly enforced by the protocol, so the encoding might
matter.headerOnly
is
false
).BufferUnderflowException
- if there is not enough data in the byte source to read the
complete payload.ShortPayloadException
- if the message's payload size is less than the size needed
for the data type and count.Copyright © 2014–2016 aquenos GmbH. All rights reserved.