Package com.esotericsoftware.kryo

Examples of com.esotericsoftware.kryo.Serializer


      Method getMethod = property.getReadMethod();
      Method setMethod = property.getWriteMethod();
      if (getMethod == null || setMethod == null) continue; // Require both a getter and setter.

      // Always use the same serializer for this property if the properties' class is final.
      Serializer serializer = null;
      Class returnType = getMethod.getReturnType();
      if (isFinal(returnType)) serializer = kryo.getRegisteredClass(returnType).getSerializer();

      CachedProperty cachedProperty = new CachedProperty();
      cachedProperty.name = name;
View Full Code Here


    for (int i = 0, n = properties.length; i < n; i++) {
      CachedProperty property = properties[i];
      try {
        if (TRACE) trace("kryo", "Writing property: " + property + " (" + type.getName() + ")");
        Object value = property.get(object);
        Serializer serializer = property.serializer;
        if (serializer != null)
          serializer.writeObject(buffer, value);
        else
          kryo.writeClassAndObject(buffer, value);
      } catch (IllegalAccessException ex) {
        throw new SerializationException("Error accessing getter method: " + property + " (" + type.getName() + ")", ex);
      } catch (InvocationTargetException ex) {
View Full Code Here

    for (int i = 0, n = properties.length; i < n; i++) {
      CachedProperty property = properties[i];
      try {
        if (TRACE) trace("kryo", "Reading property: " + property + " (" + object.getClass() + ")");
        Object value;
        Serializer serializer = property.serializer;
        if (serializer != null)
          value = serializer.readObject(buffer, property.setMethodType);
        else
          value = kryo.readClassAndObject(buffer);
        property.set(object, value);
      } catch (IllegalAccessException ex) {
        throw new SerializationException("Error accessing setter method: " + property + " (" + type.getName() + ")", ex);
View Full Code Here

        output.writeInt(((TaggedCachedField)fields[i]).tag, true);

        Object value = cachedField.get(object);

        Serializer serializer = cachedField.serializer;
        if (cachedField.fieldClass == null) {
          if (value == null) {
            kryo.writeClass(output, null);
            continue;
          }
View Full Code Here

        if (TRACE) trace("kryo", "Read field: " + cachedField + " (" + getType().getName() + ")");

        Object value = null;

        Class concreteType = cachedField.fieldClass;
        Serializer serializer = cachedField.serializer;
        if (concreteType == null) {
          Registration registration = kryo.readClass(input);
          if (registration != null) { // Else value is null.
            if (serializer == null) serializer = registration.getSerializer();
            value = kryo.readObject(input, registration.getType(), serializer);
View Full Code Here

        return;
      }
      output.writeInt(object.length + 1, true);
      Class elementClass = object.getClass().getComponentType();
      if (elementsAreSameType || Modifier.isFinal(elementClass.getModifiers())) {
        Serializer elementSerializer = kryo.getSerializer(elementClass);
        for (int i = 0, n = object.length; i < n; i++) {
          if (elementsCanBeNull)
            kryo.writeObjectOrNull(output, object[i], elementSerializer);
          else
            kryo.writeObject(output, object[i], elementSerializer);
View Full Code Here

    }

    public void read (Kryo kryo, Input input, Object[] object) {
      Class elementClass = object.getClass().getComponentType();
      if (elementsAreSameType || Modifier.isFinal(elementClass.getModifiers())) {
        Serializer elementSerializer = kryo.getSerializer(elementClass);
        for (int i = 0, n = object.length; i < n; i++) {
          if (elementsCanBeNull)
            object[i] = kryo.readObjectOrNull(input, elementClass, elementSerializer);
          else
            object[i] = kryo.readObject(input, elementClass, elementSerializer);
View Full Code Here

          kryo.writeClass(outputChunked, null);
          outputChunked.endChunks();
          continue;
        }

        Serializer serializer = cachedField.serializer;
        if (cachedField.fieldClass == null) {
          Registration registration = kryo.writeClass(outputChunked, value.getClass());
          if (serializer == null) serializer = registration.getSerializer();
          kryo.writeObject(outputChunked, value, serializer);
        } else {
View Full Code Here

        if (TRACE) trace("kryo", "Read field: " + cachedField + " (" + getType().getName() + ")");

        Object value;

        Class concreteType = cachedField.fieldClass;
        Serializer serializer = cachedField.serializer;
        if (concreteType == null) {
          Registration registration = kryo.readClass(inputChunked);
          if (registration == null)
            value = null;
          else {
View Full Code Here

      Method getMethod = property.getReadMethod();
      Method setMethod = property.getWriteMethod();
      if (getMethod == null || setMethod == null) continue; // Require both a getter and setter.

      // Always use the same serializer for this property if the properties' class is final.
      Serializer serializer = null;
      Class returnType = getMethod.getReturnType();
      if (kryo.isFinal(returnType)) serializer = kryo.getRegistration(returnType).getSerializer();

      CachedProperty cachedProperty = new CachedProperty();
      cachedProperty.name = name;
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryo.Serializer

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.