From 0c0bf3c324dfe8b39f32a71c9cedda5168f89c77 Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Fri, 10 Feb 2017 07:35:46 +0100 Subject: [PATCH] Updated README.md, custom readers take precedence --- README.md | 3 +++ src/main/java/ch/dissem/msgpack/Reader.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f1a5897..2ada957 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,9 @@ Limitations * `MPFloat` uses the data type you're using to decide on precision (float 32 or 64) - not the actual value. E.g. 0.5 could be saved perfectly as a float 42, but if you provide a double value, it will be stored as float 64, wasting 4 bytes. +* If you want to use the 'ext format family', you'll need to implement and register your own `MPType` and + `MPType.Unpacker`. Be aware that they take precedence over the default unpackers, meaning if you accidentally define + your unpacker to handle strings, for example, you won't be able to unpack any regular strings anymore. Setup ----- diff --git a/src/main/java/ch/dissem/msgpack/Reader.java b/src/main/java/ch/dissem/msgpack/Reader.java index 9b4e5ee..e24ebf8 100644 --- a/src/main/java/ch/dissem/msgpack/Reader.java +++ b/src/main/java/ch/dissem/msgpack/Reader.java @@ -27,7 +27,7 @@ import java.util.List; * Reads MPType object from an {@link InputStream}. */ public class Reader { - private List> unpackers = new LinkedList<>(); + private LinkedList> unpackers = new LinkedList<>(); private static final Reader instance = new Reader(); @@ -50,7 +50,7 @@ public class Reader { * Register your own extensions */ public void register(MPType.Unpacker unpacker) { - unpackers.add(unpacker); + unpackers.addFirst(unpacker); } public MPType read(InputStream in) throws IOException {