Package org.msgpack

Examples of org.msgpack.MessageTypeException


        }
  if (to == null) {
      try {
    to = (MessagePackable) targetClass.newInstance();
      } catch (InstantiationException e) {
    throw new MessageTypeException(e);
      } catch (IllegalAccessException e) {
    throw new MessageTypeException(e);
      }
  }
  to.readFrom(u);
  return to;
    }
View Full Code Here


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

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

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

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

    private ByteArrayTemplate() { }

    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.writeByteArray(target);
View Full Code Here

    }

    @Override
    public void readNil() {
        if(!getTop().isNil()) {
            throw new MessageTypeException("Expected nil but got not nil value");
        }
        stack.reduceCount();
        if(stack.getDepth() == 0) {
            value = null;
        }
View Full Code Here

    @Override
    public int readArrayBegin() {
        Value v = getTop();
        if(!v.isArray()) {
            throw new MessageTypeException("Expected array but got not array value");
        }
        ArrayValue a = v.asArrayValue();
        stack.reduceCount();
        stack.pushArray(a.size());
        values[stack.getDepth()] = a.getElementArray();
View Full Code Here

    }

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

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

    @Override
    public int readMapBegin() {
        Value v = getTop();
        if(!v.isMap()) {
            throw new MessageTypeException("Expected map but got not map value");
        }
        MapValue m = v.asMapValue();
        stack.reduceCount();
        stack.pushMap(m.size());
        values[stack.getDepth()] = m.getKeyValueArray();
View Full Code Here

    }

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

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

    @Override
    public void write(Packer pk, T target, boolean required) throws IOException {
  Integer ordinal = reverse.get(target);
        if(ordinal == null) {
            throw new MessageTypeException(new IllegalArgumentException("ordinal: " + ordinal));
        }
        pk.writeInt((int) ordinal);
    }
View Full Code Here

    @Override
    public T read(Unpacker pac, T to, boolean required) throws IOException, MessageTypeException {
        int ordinal = pac.readInt();
        if(entries.length <= ordinal) {
                throw new MessageTypeException(new IllegalArgumentException("ordinal: " + ordinal));
        }
        return entries[ordinal];
    }
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.