Package org.msgpack

Examples of org.msgpack.MessageTypeException


    private BooleanArrayTemplate() { }

    public void write(Packer pk, boolean[] 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


    private ByteBufferTemplate() { }

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

    private DateTemplate() { }

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

    @Override
    protected Value nextValue() {
        if(in == null) {
            // FIXME exception
            throw new MessageTypeException(new EOFException());
        }
        return super.nextValue();
    }
View Full Code Here

        if(counts[top] > 0) {
            return;
        }

        if(types[top] == TYPE_ARRAY) {
            throw new MessageTypeException("Array is end but readArrayEnd() is not called");

        } else if(types[top] == TYPE_MAP) {
            throw new MessageTypeException("Map is end but readMapEnd() is not called");

        } else {
            // empty
            return;
        }
View Full Code Here

        flags[stack.getDepth()] = FLAG_FIRST_ELEMENT;
    }

    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

        flags[stack.getDepth()] = FLAG_FIRST_ELEMENT | FLAG_MAP_KEY;
    }

    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

  if (fallbackDefault) {
      tmpl = new DefaultTemplate(this, (Class<?>) targetClass);
      register(targetClass, tmpl);
      return tmpl;
  } else {
      throw new MessageTypeException(
        "Cannot find template for " + targetClass + " class. Try to add @Message annotation to the class or call MessagePack.register(Type).");
  }
    }
View Full Code Here

    private ByteTemplate() { }

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

    }

    public void write(Packer pk, MessagePackable target, boolean required) throws IOException {
        if (target == null) {
            if (required) {
                throw new MessageTypeException("Attempted to write null");
            }
            pk.writeNil();
            return;
        }
        target.writeTo(pk);
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.