當前位置: 首頁>>代碼示例>>Java>>正文


Java Kryo.readObjectOrNull方法代碼示例

本文整理匯總了Java中com.esotericsoftware.kryo.Kryo.readObjectOrNull方法的典型用法代碼示例。如果您正苦於以下問題:Java Kryo.readObjectOrNull方法的具體用法?Java Kryo.readObjectOrNull怎麽用?Java Kryo.readObjectOrNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.esotericsoftware.kryo.Kryo的用法示例。


在下文中一共展示了Kryo.readObjectOrNull方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public BSpline read(Kryo kryo, Input input, Class<BSpline> type) {
    BSpline bSpline = new BSpline();
    Class<? extends Vector> vectorType = kryo.readClass(input).getType();
    int controlPointsLength = input.readInt();
    if (controlPointsLength >= 0){
        Vector<?>[] controlPoints = (Vector<?>[])java.lang.reflect.Array.newInstance(vectorType, controlPointsLength);
        for (int i = 0; i < controlPointsLength; i++) {
            controlPoints[i] = kryo.readObjectOrNull(input, vectorType); // vector type won't be null if control points had a length
        }
        bSpline.controlPoints = controlPoints;
    }
    bSpline.knots = kryo.readObjectOrNull(input, Array.class);
    bSpline.degree = input.readInt(true);
    bSpline.continuous = input.readBoolean();
    bSpline.spanCount = input.readInt(true);
    return bSpline;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:19,代碼來源:BSplineSerializer.java

示例2: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public CatmullRomSpline read(Kryo kryo, Input input, Class<CatmullRomSpline> type) {
    CatmullRomSpline catmullRomSpline = new CatmullRomSpline();
    Class<? extends Vector> vectorType = kryo.readClass(input).getType();
    int controlPointsLength = input.readInt();
    if (controlPointsLength >= 0){
        Vector<?>[] controlPoints = (Vector<?>[])java.lang.reflect.Array.newInstance(vectorType, controlPointsLength);
        for (int i = 0; i < controlPointsLength; i++) {
            controlPoints[i] = kryo.readObjectOrNull(input, vectorType); // vector type won't be null if control points had a length
        }
        catmullRomSpline.controlPoints = controlPoints;
    }
    catmullRomSpline.continuous = input.readBoolean();
    catmullRomSpline.spanCount = input.readInt(true);
    return catmullRomSpline;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:17,代碼來源:CatmullRomSplineSerializer.java

示例3: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public FloatCounter read(Kryo kryo, Input input, Class<FloatCounter> type) {
    WindowedMean windowedMean = kryo.readObjectOrNull(input, WindowedMean.class);
    FloatCounter floatCounter = new FloatCounter(windowedMean == null ? 0 : windowedMean.getWindowSize());
    if (windowedMean != null) {
        float[] windowedMeanValues = windowedMean.getWindowValues();
        for (float f : windowedMeanValues) { // restores the private WindowedMean
            floatCounter.put(f);
        }
    }
    floatCounter.count = input.readInt();
    floatCounter.total = input.readFloat();
    floatCounter.min = input.readFloat();
    floatCounter.max = input.readFloat();
    floatCounter.average = input.readFloat();
    floatCounter.latest = input.readFloat();
    floatCounter.value = input.readFloat();
    return floatCounter;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:20,代碼來源:FloatCounterSerializer.java

示例4: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public SortedIntList read(Kryo kryo, Input input, Class<SortedIntList> type) {
    int length = input.readVarInt(true);
    SortedIntList list = new SortedIntList();
    kryo.reference(list);
    Class elementClass = null;
    Serializer serializer = null;
    if (genericType != null) {
        elementClass = genericType;
        serializer = kryo.getSerializer(genericType);
        genericType = null;
    }
    for (int i = 0; i < length; i++) {
        int index = input.readInt();
        Object value = serializer != null ?
                kryo.readObjectOrNull(input, elementClass, serializer) : kryo.readClassAndObject(input);
        list.insert(index, value);
    }
    return list;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:21,代碼來源:SortedIntListSerializer.java

示例5: deserialize

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public Object[] deserialize(byte[] message) {
  try {
    Input input = new Input(new ByteArrayInputStream(message));

    Kryo kryo = pool.borrow();
    Object[] objects = kryo.readObjectOrNull(input, Object[].class);
    pool.release(kryo);

    return objects;
  } catch (KryoException e) {
    throw new OmegaException("Unable to deserialize message", e);
  }
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-saga,代碼行數:15,代碼來源:KryoMessageFormat.java

示例6: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
public T read (Kryo kryo, Input input, Class<T> type) {
    int length = input.readVarInt(true);
    input.readBoolean(); // currently unused
    T map = create(length);

    Class keyClass = null;
    Class valueClass = null;

    Serializer keySerializer = null;
    if (keyGenericType != null) {
        keyClass = keyGenericType;
        if (keySerializer == null) keySerializer = kryo.getSerializer(keyClass);
        keyGenericType = null;
    }
    Serializer valueSerializer = null;
    if (valueGenericType != null) {
        valueClass = valueGenericType;
        if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass);
        valueGenericType = null;
    }

    kryo.reference(map);

    for (int i = 0; i < length; i++) {
        Object key;
        if (keySerializer != null) {
            key = kryo.readObject(input, keyClass, keySerializer);
        } else
            key = kryo.readClassAndObject(input);
        Object value;
        if (valueSerializer != null) {
            value = kryo.readObjectOrNull(input, valueClass, valueSerializer);
        } else
            value = kryo.readClassAndObject(input);
        map.put(key, value);
    }
    return map;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:39,代碼來源:ObjectMapSerializer.java

示例7: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
public IdentityMap read (Kryo kryo, Input input, Class<IdentityMap> type) {
    int length = input.readVarInt(true);
    input.readBoolean(); // currently unused
    IdentityMap map = new IdentityMap(length);

    Class keyClass = null;
    Class valueClass = null;

    Serializer keySerializer = null;
    if (keyGenericType != null) {
        keyClass = keyGenericType;
        if (keySerializer == null) keySerializer = kryo.getSerializer(keyClass);
        keyGenericType = null;
    }
    Serializer valueSerializer = null;
    if (valueGenericType != null) {
        valueClass = valueGenericType;
        if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass);
        valueGenericType = null;
    }

    kryo.reference(map);

    for (int i = 0; i < length; i++) {
        Object key;
        if (keySerializer != null) {
            key = kryo.readObject(input, keyClass, keySerializer);
        } else
            key = kryo.readClassAndObject(input);
        Object value;
        if (valueSerializer != null) {
            value = kryo.readObjectOrNull(input, valueClass, valueSerializer);
        } else
            value = kryo.readClassAndObject(input);
        map.put(key, value);
    }
    return map;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:39,代碼來源:IdentityMapSerializer.java

示例8: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
public LongMap read (Kryo kryo, Input input, Class<LongMap> type) {
    int length = input.readVarInt(true);
    input.readBoolean(); // currently unused
    LongMap map = new LongMap(length);

    Class valueClass = null;

    Serializer valueSerializer = null;
    if (valueGenericType != null) {
        valueClass = valueGenericType;
        if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass);
        valueGenericType = null;
    }

    kryo.reference(map);

    for (int i = 0; i < length; i++) {
        long key = input.readLong();
        Object value;
        if (valueSerializer != null) {
            value = kryo.readObjectOrNull(input, valueClass, valueSerializer);
        } else
            value = kryo.readClassAndObject(input);
        map.put(key, value);
    }
    return map;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:28,代碼來源:LongMapSerializer.java

示例9: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
public IntMap read (Kryo kryo, Input input, Class<IntMap> type) {
    int length = input.readVarInt(true);
    input.readBoolean(); // currently unused
    IntMap map = new IntMap(length);

    Class valueClass = null;

    Serializer valueSerializer = null;
    if (valueGenericType != null) {
        valueClass = valueGenericType;
        if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass);
        valueGenericType = null;
    }

    kryo.reference(map);

    for (int i = 0; i < length; i++) {
        int key = input.readInt();
        Object value;
        if (valueSerializer != null) {
            value = kryo.readObjectOrNull(input, valueClass, valueSerializer);
        } else
            value = kryo.readClassAndObject(input);
        map.put(key, value);
    }
    return map;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:28,代碼來源:IntMapSerializer.java

示例10: skipObsoleteObjectOrNull

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
/** Reads an object or null using the registered serializer, but does not return it. If the object type is a {@link Disposable},
 * uses native memory, or is time consuming to instantiate, it should use an implementation of {@link SkippableSerializer}
 * to avoid memory leaks or wasted instantiation time. */
public static <T> void skipObsoleteObjectOrNull (Kryo kryo, Input input, Class<T> type){
    com.esotericsoftware.kryo.util.ObjectMap graphContext = kryo.getGraphContext();
    final int branchDepth = graphContext.containsKey(OBSOLETE_BRANCH_KEY) ? (Integer)graphContext.get(OBSOLETE_BRANCH_KEY) : 0;
    graphContext.put(OBSOLETE_BRANCH_KEY, branchDepth + 1);

    kryo.readObjectOrNull(input, type);

    graphContext.put(OBSOLETE_BRANCH_KEY, branchDepth);
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:13,代碼來源:GdxToKryo.java

示例11: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public Bezier read(Kryo kryo, Input input, Class<Bezier> type) {
    Bezier bezier = new Bezier();
    bezier.points = kryo.readObjectOrNull(input, Array.class);
    return bezier;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:7,代碼來源:BezierSerializer.java

示例12: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
public ArrayMap read (Kryo kryo, Input input, Class<ArrayMap> type) {
    boolean ordered = input.readBoolean();
    int length = input.readVarInt(true);
    Class knownKeyClass = kryo.readClass(input).getType();
    Class knownValueClass = kryo.readClass(input).getType();

    ArrayMap map = new ArrayMap(ordered, length, knownKeyClass, knownValueClass);

    Class keyClass = null;
    Class valueClass = null;

    Serializer keySerializer = null;
    if (keyGenericType != null) {
        keyClass = keyGenericType;
        if (keySerializer == null) keySerializer = kryo.getSerializer(keyClass);
        keyGenericType = null;
    }
    Serializer valueSerializer = null;
    if (valueGenericType != null) {
        valueClass = valueGenericType;
        if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass);
        valueGenericType = null;
    }

    kryo.reference(map);

    for (int i = 0; i < length; i++) {
        Object key;
        if (keySerializer != null) {
            key = kryo.readObject(input, keyClass, keySerializer);
        } else
            key = kryo.readClassAndObject(input);
        Object value;
        if (valueSerializer != null) {
            value = kryo.readObjectOrNull(input, valueClass, valueSerializer);
        } else
            value = kryo.readClassAndObject(input);
        map.put(key, value);
    }
    return map;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:42,代碼來源:ArrayMapSerializer.java


注:本文中的com.esotericsoftware.kryo.Kryo.readObjectOrNull方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。