public final class MessageReader extends java.lang.Object implements BinaryMessage
Message.Builder
BODY_OFFSET, HEADER_SIZE, MAX_BODY_SIZE, MESSAGE_TYPE_OFFSET, NET_ID_OFFSET, PAYLOAD_LENGTH_OFFSET, SERVICE_ID_OFFSET, SIGNATURE_SIZE, VERSION_OFFSET
Modifier and Type | Method and Description |
---|---|
java.nio.ByteBuffer |
getBody()
Returns the body of the message as a view in the underlying byte buffer.
|
java.nio.ByteBuffer |
getMessage()
Returns the whole binary message.
|
short |
getMessageType()
Returns the type of this message within a service (e.g., a transaction identifier).
|
byte |
getNetworkId()
Returns the blockchain network id.
|
short |
getServiceId()
Returns the identifier of the service this message belongs to,
or zero if this message is an internal Exonum message.
|
java.nio.ByteBuffer |
getSignature()
Returns the Ed25519 signature
over this binary message.
|
byte |
getVersion()
Returns the major version of the Exonum serialization protocol.
|
int |
size()
Returns the size of a binary representation of this message in bytes.
|
static MessageReader |
wrap(java.nio.ByteBuffer buffer)
Creates a MessageReader from the given byte buffer.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
fromBytes, hash
messageSize, signatureOffset
public static MessageReader wrap(java.nio.ByteBuffer buffer)
buffer
- a byte buffer to read. Its position must be zero,
and the limit must be set to the size of the messagejava.lang.IllegalArgumentException
- if the message has invalid sizepublic byte getNetworkId()
Message
getNetworkId
in interface Message
public byte getVersion()
Message
getVersion
in interface Message
public short getServiceId()
Message
getServiceId
in interface Message
public short getMessageType()
Message
getMessageType
in interface Message
public java.nio.ByteBuffer getBody()
The returned byte buffer shares the content of the underlying byte buffer of this message, and is read-only. Its position is zero, limit is set to the position after-the-last element of the body.
public java.nio.ByteBuffer getSignature()
The signature is not guaranteed to be valid and must be verified against the signer’s public key.
The returned byte buffer shares the content of the underlying byte buffer of this message, and is read-only.
getSignature
in interface Message
public int size()
Message
public java.nio.ByteBuffer getMessage()
The returned byte buffer shares the content of the underlying byte buffer of this message, and is read-only.
getMessage
in interface BinaryMessage
Copyright © 2018 Exonum. All rights reserved.