public final class MessageReader extends java.lang.Object implements BinaryMessage
Message.BuilderBODY_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.
|
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.
|
byte[] |
getSignature()
Returns the Ed25519 signature
over this binary message.
|
java.nio.ByteBuffer |
getSignedMessage()
Returns the whole 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, waitfromBytes, getMessageNoSignature, hash, sign, verifymessageSize, signatureOffsetpublic 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()
MessagegetNetworkId in interface Messagepublic byte getVersion()
MessagegetVersion in interface Messagepublic short getServiceId()
MessagegetServiceId in interface Messagepublic short getMessageType()
MessagegetMessageType in interface Messagepublic java.nio.ByteBuffer getBody()
The returned byte buffer shares the content of the underlying byte buffer of this message. Its position is zero, limit is set to the position after-the-last element of the body. The buffer is direct iff the underlying buffer is direct, and it is read-only iff the underlying buffer is read-only.
public byte[] 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 MessageCryptoFunctions.ed25519()public int size()
Messagepublic java.nio.ByteBuffer getSignedMessage()
The returned byte buffer shares the content of the underlying byte buffer of this message, and is read-only.
getSignedMessage in interface BinaryMessageCopyright © 2018 Exonum. All rights reserved.