|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.msgpack.core.MessageUnpacker
public class MessageUnpacker
MessageUnpacker lets an application read message-packed values from a data stream.
The application needs to call getNextFormat()
followed by an appropriate unpackXXX method according to the the returned format type.
MessageUnpacker unpacker = new MessageUnpacker(...);
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 Summary | |
---|---|
MessageUnpacker(byte[] arr)
Create an MessageUnpacker that reads data from the given byte array. |
|
MessageUnpacker(java.io.InputStream in)
Create an MessageUnpacker that reads data from the given InputStream. |
|
MessageUnpacker(MessageBufferInput in)
Create an MessageUnpacker that reads data from the given MessageBufferInput |
|
MessageUnpacker(MessageBufferInput in,
MessagePack.Config config)
Create an MessageUnpacker |
|
MessageUnpacker(java.nio.channels.ReadableByteChannel in)
Create an MessageUnpacker that reads data from the given ReadableByteChannel. |
Method Summary | |
---|---|
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)
|
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)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MessageUnpacker(byte[] arr)
arr
- public MessageUnpacker(java.io.InputStream in)
in
- public MessageUnpacker(java.nio.channels.ReadableByteChannel in)
in
- public MessageUnpacker(MessageBufferInput in)
in
- public MessageUnpacker(MessageBufferInput in, MessagePack.Config config)
in
- config
- configurationMethod Detail |
---|
public Cursor getCursor()
Cursor
for traversing message-packed values
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 read
java.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
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |