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;
}
// ...
}
}
Constructor and Description |
---|
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
|
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) |
public MessageUnpacker(MessageBufferInput in, MessagePack.UnpackerConfig config)
in
- public 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, next getNextFormat()
call will throw an MessageInsufficientBufferException.java.io.IOException
public 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.IOException
public ImmutableValue unpackValue() throws java.io.IOException
java.io.IOException
public Variable unpackValue(Variable var) throws java.io.IOException
java.io.IOException
public void 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 float unpackFloat() throws java.io.IOException
java.io.IOException
public double unpackDouble() 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 ExtensionTypeHeader unpackExtensionTypeHeader() 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 byte[] readPayload(int length) 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