public class MessageUnpacker
extends java.lang.Object
implements java.io.Closeable
getNextFormat() followed by an appropriate unpackXXX method according to the the returned format type.
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(...);
while(unpacker.hasNext()) {
MessageFormat f = unpacker.getNextFormat();
switch(f) {
case MessageFormat.POSFIXINT:
case MessageFormat.INT8:
case MessageFormat.UINT8: {
int v = unpacker.unpackInt();
break;
}
case MessageFormat.STRING: {
String v = unpacker.unpackString();
break;
}
// ...
}
}
| Modifier | Constructor and Description |
|---|---|
protected |
MessageUnpacker(MessageBufferInput in,
MessagePack.UnpackerConfig config)
Create an MessageUnpacker that reads data from the given MessageBufferInput.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
MessageFormat |
getNextFormat()
Returns the next MessageFormat type.
|
long |
getTotalReadBytes() |
boolean |
hasNext()
Returns true true if this unpacker has more elements.
|
void |
readPayload(byte[] dst) |
void |
readPayload(byte[] dst,
int off,
int len)
Read up to len bytes of data into the destination array
|
void |
readPayload(java.nio.ByteBuffer dst) |
byte[] |
readPayload(int length) |
MessageBuffer |
readPayloadAsReference(int length) |
MessageBufferInput |
reset(MessageBufferInput in)
Reset input.
|
void |
skipValue()
Skip the next value, then move the cursor at the end of the value
|
void |
skipValue(int count)
Skip next values, then move the cursor at the end of the value
|
int |
unpackArrayHeader() |
java.math.BigInteger |
unpackBigInteger() |
int |
unpackBinaryHeader() |
boolean |
unpackBoolean() |
byte |
unpackByte() |
double |
unpackDouble() |
ExtensionTypeHeader |
unpackExtensionTypeHeader() |
float |
unpackFloat() |
int |
unpackInt() |
long |
unpackLong() |
int |
unpackMapHeader() |
void |
unpackNil() |
int |
unpackRawStringHeader() |
short |
unpackShort() |
java.lang.String |
unpackString() |
ImmutableValue |
unpackValue() |
Variable |
unpackValue(Variable var) |
protected MessageUnpacker(MessageBufferInput in, MessagePack.UnpackerConfig config)
in - public MessageBufferInput reset(MessageBufferInput in) throws java.io.IOException
in - new inputjava.io.IOExceptionpublic long getTotalReadBytes()
public boolean hasNext()
throws java.io.IOException
getNextFormat() returns an
MessageFormat instance. If false, next getNextFormat() call will throw an MessageInsufficientBufferException.java.io.IOExceptionpublic MessageFormat getNextFormat() throws java.io.IOException
hasNext() returns true.
If hasNext() returns false, calling this method throws MessageInsufficientBufferException.
This method does not proceed the internal cursor.java.io.IOException - when failed to read the input data.MessageInsufficientBufferException - when the end of file reached, i.e. hasNext() == false.public void skipValue()
throws java.io.IOException
java.io.IOExceptionpublic void skipValue(int count)
throws java.io.IOException
count - number of values to skipjava.io.IOExceptionpublic ImmutableValue unpackValue() throws java.io.IOException
java.io.IOExceptionpublic Variable unpackValue(Variable var) throws java.io.IOException
java.io.IOExceptionpublic void unpackNil()
throws java.io.IOException
java.io.IOExceptionpublic boolean unpackBoolean()
throws java.io.IOException
java.io.IOExceptionpublic byte unpackByte()
throws java.io.IOException
java.io.IOExceptionpublic short unpackShort()
throws java.io.IOException
java.io.IOExceptionpublic int unpackInt()
throws java.io.IOException
java.io.IOExceptionpublic long unpackLong()
throws java.io.IOException
java.io.IOExceptionpublic java.math.BigInteger unpackBigInteger()
throws java.io.IOException
java.io.IOExceptionpublic float unpackFloat()
throws java.io.IOException
java.io.IOExceptionpublic double unpackDouble()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String unpackString()
throws java.io.IOException
java.io.IOExceptionpublic int unpackArrayHeader()
throws java.io.IOException
java.io.IOExceptionpublic int unpackMapHeader()
throws java.io.IOException
java.io.IOExceptionpublic ExtensionTypeHeader unpackExtensionTypeHeader() throws java.io.IOException
java.io.IOExceptionpublic int unpackRawStringHeader()
throws java.io.IOException
java.io.IOExceptionpublic int unpackBinaryHeader()
throws java.io.IOException
java.io.IOExceptionpublic void readPayload(java.nio.ByteBuffer dst)
throws java.io.IOException
java.io.IOExceptionpublic void readPayload(byte[] dst)
throws java.io.IOException
java.io.IOExceptionpublic byte[] readPayload(int length)
throws java.io.IOException
java.io.IOExceptionpublic void readPayload(byte[] dst,
int off,
int len)
throws java.io.IOException
dst - the buffer into which the data is readoff - the offset in the dst arraylen - the number of bytes to readjava.io.IOExceptionpublic MessageBuffer readPayloadAsReference(int length) throws java.io.IOException
java.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException