Package com.esotericsoftware.kryo

Examples of com.esotericsoftware.kryo.KryoException


      niobuffer.position(0);
      niobuffer.get(tmp);
      niobuffer.position(0);
      outputStream.write(tmp, 0, position);
    } catch (IOException ex) {
      throw new KryoException(ex);
    }
    total += position;
    position = 0;
  }
View Full Code Here


  final public void readBytes (Object dstObj, long offset, long count) throws KryoException {
    /* Unsafe supports efficient bulk reading into arrays of primitives only because of JVM limitations due to GC */
    if (dstObj.getClass().isArray())
      readBytes(dstObj, 0, offset, (int)count);
    else {
      throw new KryoException("Only bulk reads of arrays is supported");
    }
  }
View Full Code Here

  /** @return true if the buffer has been resized. */
  protected boolean require (int required) throws KryoException {
    if (capacity - position >= required) return false;
    if (required > maxCapacity)
      throw new KryoException("Buffer overflow. Max capacity: " + maxCapacity + ", required: " + required);
    flush();
    while (capacity - position < required) {
      if (capacity == maxCapacity)
        throw new KryoException("Buffer overflow. Available: " + (capacity - position) + ", required: " + required);
      // Grow buffer.
      if (capacity == 0) capacity = 1;
      capacity = Math.min(capacity * 2, maxCapacity);
      if (capacity < 0) capacity = maxCapacity;
      ByteBuffer newBuffer = (niobuffer != null && !niobuffer.isDirect()) ? ByteBuffer.allocate(capacity) : ByteBuffer
View Full Code Here

      niobuffer.position(0);
      niobuffer.get(tmp);
      niobuffer.position(0);
      outputStream.write(tmp, 0, position);
    } catch (IOException ex) {
      throw new KryoException(ex);
    }
    total += position;
    position = 0;
  }
View Full Code Here

  final public void readBytes (Object dstObj, long offset, long count) throws KryoException {
    /* Unsafe supports efficient bulk reading into arrays of primitives only because of JVM limitations due to GC */
    if (dstObj.getClass().isArray())
      readBytes(dstObj, 0, offset, (int)count);
    else {
      throw new KryoException("Only bulk reads of arrays is supported");
    }
  }
View Full Code Here

          Date d = (Date)kryo.newInstance(type); // default strategy
          d.setTime(time);
          return d;
        }
      } catch (Exception ex) {
        throw new KryoException(ex);
      }
    }
View Full Code Here

    public Enum read (Kryo kryo, Input input, Class<Enum> type) {
      int ordinal = input.readVarInt(true);
      if (ordinal == NULL) return null;
      ordinal--;
      if (ordinal < 0 || ordinal > enumConstants.length - 1)
        throw new KryoException("Invalid ordinal for enum \"" + type.getName() + "\": " + ordinal);
      Object constant = enumConstants[ordinal];
      return (Enum)constant;
    }
View Full Code Here

    // Unsafe supports efficient bulk reading into arrays of primitives only because
    // of JVM limitations due to GC
    if (dstObj.getClass().isArray())
      readBytes(dstObj, 0, offset, (int)count);
    else {
      throw new KryoException("Only bulk reads of arrays is supported");
    }
  }
View Full Code Here

  static public class EnumSetSerializer extends Serializer<EnumSet> {
    public void write (Kryo kryo, Output output, EnumSet object) {
      Serializer serializer;
      if (object.isEmpty()) {
        EnumSet tmp = EnumSet.complementOf(object);
        if (tmp.isEmpty()) throw new KryoException("An EnumSet must have a defined Enum to be serialized.");
        serializer = kryo.writeClass(output, tmp.iterator().next().getClass()).getSerializer();
      } else {
        serializer = kryo.writeClass(output, object.iterator().next().getClass()).getSerializer();
      }
      output.writeInt(object.size(), true);
View Full Code Here

  protected int fill (byte[] buffer, int offset, int count) throws KryoException {
    if (inputStream == null) return -1;
    try {
      return inputStream.read(buffer, offset, count);
    } catch (IOException ex) {
      throw new KryoException(ex);
    }
  }
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryo.KryoException

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.