Java Code Examples for org.msgpack.core.MessageUnpacker#close()
The following examples show how to use
org.msgpack.core.MessageUnpacker#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MsgpackIOUtil.java From protostuff with Apache License 2.0 | 6 votes |
/** * Merges the {@code message} with the byte array using the given {@code schema}. */ public static <T> void mergeFrom(byte[] data, int offset, int length, T message, Schema<T> schema, boolean numeric) throws IOException { ArrayBufferInput bios = new ArrayBufferInput(data, offset, length); MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(bios); try { mergeFrom(unpacker, message, schema, numeric); } finally { unpacker.close(); } }
Example 2
Source File: MessagePackParser.java From jackson-dataformat-msgpack with Apache License 2.0 | 5 votes |
@Override public void close() throws IOException { try { MessageUnpacker messageUnpacker = getMessageUnpacker(); messageUnpacker.close(); } catch (Exception e) { e.printStackTrace(); } finally { isClosed = true; } }
Example 3
Source File: MsgpackIOUtil.java From protostuff with Apache License 2.0 | 5 votes |
/** * Merges the {@code message} from the {@link MessageBufferInput} using the given {@code schema}. */ public static <T> void mergeFrom(MessageBufferInput in, T message, Schema<T> schema, boolean numeric) throws IOException { MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(in); try { mergeFrom(unpacker, message, schema, numeric); } finally { unpacker.close(); } }
Example 4
Source File: MsgpackIOUtil.java From protostuff with Apache License 2.0 | 5 votes |
/** * Merges the {@code message} from the {@link InputStream} using the given {@code schema}. */ public static <T> void mergeFrom(InputStream in, T message, Schema<T> schema, boolean numeric) throws IOException { MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(in); try { mergeFrom(unpacker, message, schema, numeric); } finally { unpacker.close(); } }
Example 5
Source File: MsgpackIOUtil.java From protostuff with Apache License 2.0 | 5 votes |
/** * Parses the {@code messages} from the stream using the given {@code schema}. */ public static <T> List<T> parseListFrom(MessageBufferInput in, Schema<T> schema, boolean numeric) throws IOException { MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(in); try { return parseListFrom(unpacker, schema, numeric); } finally { unpacker.close(); } }
Example 6
Source File: MsgpackIOUtil.java From protostuff with Apache License 2.0 | 5 votes |
/** * Parses the {@code messages} from the stream using the given {@code schema}. */ public static <T> List<T> parseListFrom(InputStream in, Schema<T> schema, boolean numeric) throws IOException { MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(in); try { return parseListFrom(unpacker, schema, numeric); } finally { unpacker.close(); } }
Example 7
Source File: Message.java From locust4j with MIT License | 4 votes |
public Message(byte[] bytes) throws IOException { MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(bytes); int arrayHeader = unpacker.unpackArrayHeader(); this.type = unpacker.unpackString(); // unpack data if (unpacker.getNextFormat() != MessageFormat.NIL) { int mapSize = unpacker.unpackMapHeader(); this.data = new HashMap<>(6); while (mapSize > 0) { String key = null; // unpack key if (unpacker.getNextFormat() == MessageFormat.NIL) { unpacker.unpackNil(); } else { key = unpacker.unpackString(); } // unpack value MessageFormat messageFormat = unpacker.getNextFormat(); Object value; switch (messageFormat.getValueType()) { case BOOLEAN: value = unpacker.unpackBoolean(); break; case FLOAT: value = unpacker.unpackFloat(); break; case INTEGER: value = unpacker.unpackInt(); break; case NIL: value = null; unpacker.unpackNil(); break; case STRING: value = unpacker.unpackString(); break; default: throw new IOException("Message received unsupported type: " + messageFormat.getValueType()); } if (null != key) { this.data.put(key, value); } mapSize--; } } else { unpacker.unpackNil(); this.data = null; } if (unpacker.getNextFormat() != MessageFormat.NIL) { this.nodeID = unpacker.unpackString(); } else { unpacker.unpackNil(); this.nodeID = null; } unpacker.close(); }