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 = MessagePackFactory.DEFAULT.newUnpacker(...);
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;
}
// ...
}
}
Constructor and Description |
---|
MessageUnpacker(MessageBufferInput in)
Create an MessageUnpacker that reads data from the given MessageBufferInput
|
MessageUnpacker(MessageBufferInput in,
MessagePack.Config config)
Create an MessageUnpacker
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
Cursor |
getCursor()
Get a
Cursor for traversing message-packed values |
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) |
MessageBuffer |
readPayloadAsReference(int length) |
MessageBufferInput |
reset(MessageBufferInput in)
Reset input.
|
void |
skipBytes(int numBytes)
Skip reading the specified number of bytes.
|
void |
skipValue()
Skip the next value, then move the cursor at the end of the value
|
int |
unpackArrayHeader() |
java.math.BigInteger |
unpackBigInteger() |
int |
unpackBinaryHeader() |
boolean |
unpackBoolean() |
byte |
unpackByte() |
double |
unpackDouble() |
ExtendedTypeHeader |
unpackExtendedTypeHeader() |
float |
unpackFloat() |
void |
unpackFloat(FloatHolder holder) |
void |
unpackFloat(ValueHolder holder) |
int |
unpackInt() |
void |
unpackInteger(IntegerHolder holder)
Unpack an integer, then store the read value to the given holder
|
long |
unpackLong() |
int |
unpackMapHeader() |
java.lang.Object |
unpackNil() |
int |
unpackRawStringHeader() |
short |
unpackShort() |
java.lang.String |
unpackString() |
MessageFormat |
unpackValue(ValueHolder holder) |
public MessageUnpacker(MessageBufferInput in)
in
- public MessageUnpacker(MessageBufferInput in, MessagePack.Config config)
in
- config
- configurationpublic MessageBufferInput reset(MessageBufferInput in) throws java.io.IOException
in
- new inputjava.io.IOException
public long getTotalReadBytes()
public boolean hasNext() throws java.io.IOException
getNextFormat()
returns an
MessageFormat instance. If false, getNextFormat()
will throw an EOFException.java.io.IOException
public MessageFormat getNextFormat() throws java.io.IOException
hasNext()
returns true.
If hasNext()
returns false, calling this method throws EOFException
.
This method does not proceed the internal cursor.java.io.IOException
- when failed to read the input data.java.io.EOFException
- when the end of file reached, i.e. hasNext()
== false.public void skipBytes(int numBytes) throws java.io.IOException
skipValue()
.numBytes
- java.io.IOException
public void skipValue() throws java.io.IOException
java.io.IOException
public MessageFormat unpackValue(ValueHolder holder) throws java.io.IOException
java.io.IOException
public java.lang.Object unpackNil() throws java.io.IOException
java.io.IOException
public boolean unpackBoolean() throws java.io.IOException
java.io.IOException
public byte unpackByte() throws java.io.IOException
java.io.IOException
public short unpackShort() throws java.io.IOException
java.io.IOException
public int unpackInt() throws java.io.IOException
java.io.IOException
public long unpackLong() throws java.io.IOException
java.io.IOException
public java.math.BigInteger unpackBigInteger() throws java.io.IOException
java.io.IOException
public void unpackInteger(IntegerHolder holder) throws java.io.IOException
holder
- an integer holder to which the unpacked integer will be set.java.io.IOException
public float unpackFloat() throws java.io.IOException
java.io.IOException
public double unpackDouble() throws java.io.IOException
java.io.IOException
public void unpackFloat(ValueHolder holder) throws java.io.IOException
java.io.IOException
public void unpackFloat(FloatHolder holder) throws java.io.IOException
java.io.IOException
public java.lang.String unpackString() throws java.io.IOException
java.io.IOException
public int unpackArrayHeader() throws java.io.IOException
java.io.IOException
public int unpackMapHeader() throws java.io.IOException
java.io.IOException
public ExtendedTypeHeader unpackExtendedTypeHeader() throws java.io.IOException
java.io.IOException
public int unpackRawStringHeader() throws java.io.IOException
java.io.IOException
public int unpackBinaryHeader() throws java.io.IOException
java.io.IOException
public void readPayload(java.nio.ByteBuffer dst) throws java.io.IOException
java.io.IOException
public void readPayload(byte[] dst) throws java.io.IOException
java.io.IOException
public 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.IOException
public MessageBuffer readPayloadAsReference(int length) throws java.io.IOException
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException