Package org.msgpack

Examples of org.msgpack.MessageTypeException


    private LongTemplate() { }

    public void write(Packer pk, Long target, boolean required) throws IOException {
        if (target == null) {
            if (required) {
                throw new MessageTypeException("Attempted to write null");
            }
            pk.writeNil();
            return;
        }
        pk.writeLong(target);
View Full Code Here


        } else if(d.bitLength() == 64 && d.signum() == 1) {
            // unsigned 64
            out.writeByteAndLong((byte)0xcf, d.longValue());
            stack.reduceCount();
        } else {
            throw new MessageTypeException("MessagePack can't serialize BigInteger larger than (2^64)-1");
        }
    }
View Full Code Here

        // TODO encoding error
        byte[] b;
        try {
            b = s.getBytes("UTF-8");
        } catch (UnsupportedEncodingException ex) {
            throw new MessageTypeException();
        }
        writeByteArray(b, 0, b.length);
        stack.reduceCount();
    }
View Full Code Here

    }

    @Override
    public void writeArrayEnd(boolean check) throws IOException {
        if(!stack.topIsArray()) {
            throw new MessageTypeException("writeArrayEnd() is called but writeArrayBegin() is not called");
        }

        int remain = stack.getTopCount();
        if(remain > 0) {
            if(check) {
                throw new MessageTypeException("writeArrayEnd(check=true) is called but the array is not end: "+remain);
            }
            for(int i=0; i < remain; i++) {
                writeNil();
            }
        }
View Full Code Here

    }

    @Override
    public void writeMapEnd(boolean check) throws IOException {
        if(!stack.topIsMap()) {
            throw new MessageTypeException("writeMapEnd() is called but writeMapBegin() is not called");
        }

        int remain = stack.getTopCount();
        if(remain > 0) {
            if(check) {
                throw new MessageTypeException("writeMapEnd(check=true) is called but the map is not end: "+remain);
            }
            for(int i=0; i < remain; i++) {
                writeNil();
            }
        }
View Full Code Here

    public void write(Packer pk, List<E> target, boolean required) throws IOException {
        if (! (target instanceof List)) {
            if (target == null) {
                if (required) {
                    throw new MessageTypeException("Attempted to write null");
                }
                pk.writeNil();
                return;
            }
            throw new MessageTypeException("Target is not a List but " + target.getClass());
        }
        pk.writeArrayBegin(target.size());
        for (E e : target) {
            elementTemplate.write(pk, e);
        }
View Full Code Here

    private IntegerArrayTemplate() { }

    public void write(Packer pk, int[] target, boolean required) throws IOException {
        if (target == null) {
            if (required) {
                throw new MessageTypeException("Attempted to write null");
            }
            pk.writeNil();
            return;
        }
        pk.writeArrayBegin(target.length);
View Full Code Here

    protected Value nextValue() {
        try {
            Object obj = parser.parse(in);
            return objectToValue(obj);
        } catch (ParseException e) { // FIXME exception
            throw new MessageTypeException(e);
        } catch (IOException e) { // FIXME exception
            throw new MessageTypeException(e);
        }
    }
View Full Code Here

            ((MessagePackable) target).writeTo(pk);
            return;
        }
        Template<Object> tmpl = registry.tryLookup(lookupType);
        if (tmpl == this || tmpl == null) {
            throw new MessageTypeException("Template lookup fail: " + lookupType);
        }
        tmpl.write(pk, target);
    }
View Full Code Here

            return null;
        }
        // TODO #MN
        Template<Object> tmpl = registry.tryLookup(lookupType);
        if (tmpl == this || tmpl == null) {
            throw new MessageTypeException("Template lookup fail: " + lookupType);
        }
        return tmpl.read(u, to);
    }
View Full Code Here

TOP

Related Classes of org.msgpack.MessageTypeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.