Package com.esotericsoftware.kryo.util

Examples of com.esotericsoftware.kryo.util.ObjectMap


    super(kryo, type);
  }

  public void write (Kryo kryo, Output output, T object) {
    CachedField[] fields = getFields();
    ObjectMap context = kryo.getGraphContext();
    if (!context.containsKey(this)) {
      context.put(this, null);
      if (TRACE) trace("kryo", "Write " + fields.length + " field names.");
      output.writeVarInt(fields.length, true);
      for (int i = 0, n = fields.length; i < n; i++)
        output.writeString(fields[i].field.getName());
    }
View Full Code Here


  }

  public T read (Kryo kryo, Input input, Class<T> type) {
    T object = create(kryo, input, type);
    kryo.reference(object);
    ObjectMap context = kryo.getGraphContext();
    CachedField[] fields = (CachedField[])context.get(this);
    if (fields == null) {
      int length = input.readVarInt(true);
      if (TRACE) trace("kryo", "Read " + length + " field names.");
      String[] names = new String[length];
      for (int i = 0; i < length; i++)
        names[i] = input.readString();

      fields = new CachedField[length];
      CachedField[] allFields = getFields();
      outer:
      for (int i = 0, n = names.length; i < n; i++) {
        String schemaName = names[i];
        for (int ii = 0, nn = allFields.length; ii < nn; ii++) {
          if (allFields[ii].field.getName().equals(schemaName)) {
            fields[i] = allFields[ii];
            continue outer;
          }
        }
        if (TRACE) trace("kryo", "Ignore obsolete field: " + schemaName);
      }
      context.put(this, fields);
    }

    InputChunked inputChunked = new InputChunked(input, 1024);
    for (int i = 0, n = fields.length; i < n; i++) {
      CachedField cachedField = fields[i];
View Full Code Here

        }
      }
      nextClass = nextClass.getSuperclass();
    }

    ObjectMap context = kryo.getContext();

    IntArray useAsm = new IntArray();

    // Sort fields by their offsets
    if (useMemRegions && !useAsmEnabled && unsafeAvailable) {
View Full Code Here

    return (T)instantiator.newInstance();
  }

  /** Name/value pairs that are available to all serializers. */
  public ObjectMap getContext () {
    if (context == null) context = new ObjectMap();
    return context;
  }
View Full Code Here

  }

  /** Name/value pairs that are available to all serializers and are cleared after each object graph is serialized or
   * deserialized. */
  public ObjectMap getGraphContext () {
    if (graphContext == null) graphContext = new ObjectMap();
    return graphContext;
  }
View Full Code Here

        }
      }
      nextClass = nextClass.getSuperclass();
    }

    ObjectMap context = kryo.getContext();

    IntArray useAsm = new IntArray();

    // Sort fields by their offsets
    if (useMemRegions && !useAsmEnabled && unsafe() != null) {
View Full Code Here

        }
      }
      nextClass = nextClass.getSuperclass();
    }

    ObjectMap context = kryo.getContext();

    IntArray useAsm = new IntArray();

    // Sort fields by their offsets
    if (useMemRegions && !useAsmEnabled && unsafeAvailable) {
View Full Code Here

    return (T)instantiator.newInstance();
  }

  /** Name/value pairs that are available to all serializers. */
  public ObjectMap getContext () {
    if (context == null) context = new ObjectMap();
    return context;
  }
View Full Code Here

  }

  /** Name/value pairs that are available to all serializers and are cleared after each object graph is serialized or
   * deserialized. */
  public ObjectMap getGraphContext () {
    if (graphContext == null) graphContext = new ObjectMap();
    return graphContext;
  }
View Full Code Here

    while (nextClass != Object.class) {
      Collections.addAll(allFields, nextClass.getDeclaredFields());
      nextClass = nextClass.getSuperclass();
    }

    ObjectMap context = kryo.getContext();

    ArrayList<CachedField> asmFields = new ArrayList();
    ArrayList<CachedField> cachedFields = new ArrayList(allFields.size());
    for (int i = 0, n = allFields.size(); i < n; i++) {
      Field field = allFields.get(i);

      int modifiers = field.getModifiers();
      if (Modifier.isTransient(modifiers)) continue;
      if (Modifier.isStatic(modifiers)) continue;
      if (field.isSynthetic() && ignoreSyntheticFields) continue;

      if (!field.isAccessible()) {
        if (!setFieldsAsAccessible) continue;
        try {
          field.setAccessible(true);
        } catch (AccessControlException ex) {
          continue;
        }
      }

      Optional optional = field.getAnnotation(Optional.class);
      if (optional != null && !context.containsKey(optional.value())) continue;

      Class fieldClass = field.getType();

      CachedField cachedField = newCachedField(field);
      if (cachedField == null) continue;
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryo.util.ObjectMap

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.