Package com.esotericsoftware.kryo

Examples of com.esotericsoftware.kryo.Registration


    if (registration.getType().isPrimitive()) classToRegistration.put(getWrapperClass(registration.getType()), registration);
    return registration;
  }

  public Registration registerImplicit (Class type) {
    return register(new Registration(type, kryo.getDefaultSerializer(type), NAME));
  }
View Full Code Here


    return register(new Registration(type, kryo.getDefaultSerializer(type), NAME));
  }

  public Registration getRegistration (Class type) {
    if (type == memoizedClass) return memoizedClassValue;
    Registration registration = classToRegistration.get(type);
    if (registration != null) {
      memoizedClass = type;
      memoizedClassValue = registration;
    }
    return registration;
View Full Code Here

    if (type == null) {
      if (TRACE || (DEBUG && kryo.getDepth() == 1)) log("Write", null);
      output.writeByte(Kryo.NULL);
      return null;
    }
    Registration registration = kryo.getRegistration(type);
    if (registration.getId() == NAME)
      writeName(output, type, registration);
    else {
      if (TRACE) trace("kryo", "Write class " + registration.getId() + ": " + className(type));
      output.writeInt(registration.getId() + 2, true);
    }
    return registration;
  }
View Full Code Here

    if (registration.getType().isPrimitive()) classToRegistration.put(getWrapperClass(registration.getType()), registration);
    return registration;
  }

  public Registration registerImplicit (Class type) {
    return register(new Registration(type, kryo.getDefaultSerializer(type), NAME));
  }
View Full Code Here

    return register(new Registration(type, kryo.getDefaultSerializer(type), NAME));
  }

  public Registration getRegistration (Class type) {
    if (type == memoizedClass) return memoizedClassValue;
    Registration registration = classToRegistration.get(type);
    if (registration != null) {
      memoizedClass = type;
      memoizedClassValue = registration;
    }
    return registration;
View Full Code Here

    if (type == null) {
      if (TRACE || (DEBUG && kryo.getDepth() == 1)) log("Write", null);
      output.writeVarInt(Kryo.NULL, true);
      return null;
    }
    Registration registration = kryo.getRegistration(type);
    if (registration.getId() == NAME)
      writeName(output, type, registration);
    else {
      if (TRACE) trace("kryo", "Write class " + registration.getId() + ": " + className(type));
      output.writeVarInt(registration.getId() + 2, true);
    }
    return registration;
  }
View Full Code Here

        // The concrete type of the field is unknown, write the class first.
        if (value == null) {
          kryo.writeClass(output, null);
          return;
        }
        Registration registration = kryo.writeClass(output, value.getClass());
        if (serializer == null) serializer = registration.getSerializer();
        // if (generics != null)
        serializer.setGenerics(kryo, generics);
        kryo.writeObject(output, value, serializer);
      } else {
        // The concrete type of the field is known, always use the same serializer.
View Full Code Here

      return null;
    case NAME + 2: // Offset for NAME and NULL.
      return readName(input);
    }
    if (classID == memoizedClassId) return memoizedClassIdValue;
    Registration registration = idToRegistration.get(classID - 2);
    if (registration == null) throw new KryoException("Encountered unregistered class ID: " + (classID - 2));
    if (TRACE) trace("kryo", "Read class " + (classID - 2) + ": " + className(registration.getType()));
    memoizedClassId = classID;
    memoizedClassIdValue = registration;
    return registration;
  }
View Full Code Here

      Object value;

      Class concreteType = valueClass;
      Serializer serializer = this.serializer;
      if (concreteType == null) {
        Registration registration = kryo.readClass(input);
        if (registration == null)
          value = null;
        else {
          if (serializer == null) serializer = registration.getSerializer();
          // if (generics != null)
          serializer.setGenerics(kryo, generics);
          value = kryo.readObject(input, registration.getType(), serializer);
        }
      } else {
        if (serializer == null) this.serializer = serializer = kryo.getSerializer(valueClass);
        // if (generics != null)
        serializer.setGenerics(kryo, generics);
View Full Code Here

      kryo.writeClass(output, object);
      output.writeByte((object != null && object.isPrimitive()) ? 1 : 0);
    }

    public Class read (Kryo kryo, Input input, Class<Class> type) {
      Registration registration = kryo.readClass(input);
      int isPrimitive = input.read();
      Class typ = registration != null ? registration.getType() : null;
      if (typ == null || !typ.isPrimitive()) return typ;
      return (isPrimitive == 1) ? typ : getWrapperClass(typ);
    }
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryo.Registration

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.