public final class ChannelAccessUserNameMessage extends ChannelAccessMessage
CA_PROTO_CLIENT_NAME message. This message
is sent from a client to a server via TCP in order to communicate the name of
the local user. This information might be used for access control.ChannelAccessCommand.CA_PROTO_CLIENT_NAMEcommand, originalMessageHeader| Constructor and Description |
|---|
ChannelAccessUserNameMessage(String userName)
Constructor for creating a
CA_PROTO_CLIENT_NAME message. |
| Modifier and Type | Method and Description |
|---|---|
protected static ChannelAccessUserNameMessage |
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.
|
String |
getUserName()
Returns the name of the user that is using the Channel Access client.
|
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, verifyHeaderpublic ChannelAccessUserNameMessage(String userName)
CA_PROTO_CLIENT_NAME message.userName - name of the user that is using the Channel Access client.protected void serialize(ByteSink byteSink, ChannelAccessVersion version, int maxPayloadSize, Charset charset)
ChannelAccessMessageChannelAccessMessageCodec.serialize in class ChannelAccessMessagebyteSink - 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)
ChannelAccessMessageChannelAccessMessageCodec.verify in class ChannelAccessMessageversion - 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)
ChannelAccessMessageTells 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 ChannelAccessMessageobj - 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()
ChannelAccessMessageReturns 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 ChannelAccessMessagepublic String toString()
ChannelAccessMessagetoString in class ChannelAccessMessageprotected static ChannelAccessUserNameMessage 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 user name. Usually, user
names should consist of ASCII characters only, however this is
not strictly enforced by the protocol, so the encoding might
matter.BufferUnderflowException - if there is not enough data in the byte source to read the
complete message (including the payload).public String getUserName()
null
if this message instance has been reconstructed without its
payload (as part of the payload of an error message).Copyright © 2014–2016 aquenos GmbH. All rights reserved.