当前位置: 首页>>代码示例>>Java>>正文


Java Kryo.readObject方法代码示例

本文整理汇总了Java中com.esotericsoftware.kryo.Kryo.readObject方法的典型用法代码示例。如果您正苦于以下问题:Java Kryo.readObject方法的具体用法?Java Kryo.readObject怎么用?Java Kryo.readObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.esotericsoftware.kryo.Kryo的用法示例。


在下文中一共展示了Kryo.readObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public PerspectiveCamera read (Kryo kryo, Input input, Class<PerspectiveCamera> type) {
    PerspectiveCamera camera = new PerspectiveCamera();
    Vector3 position = kryo.readObject(input, Vector3.class);
    Vector3 direction = kryo.readObject(input, Vector3.class);
    Vector3 up = kryo.readObject(input, Vector3.class);
    camera.position.set(position);
    camera.direction.set(direction);
    camera.up.set(up);
    camera.near = input.readFloat();
    camera.far = input.readFloat();
    camera.viewportWidth = input.readFloat();
    camera.viewportHeight = input.readFloat();
    camera.fieldOfView = input.readFloat();
    camera.update();
    return camera;
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:18,代码来源:PerspectiveCameraSerializer.java

示例2: createService

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
protected GoogleAccountsService createService(final Kryo kryo, final Input input, final String id,
        final String originalUrl, final String artifactId) {

    final String requestId = kryo.readObject(input, String.class);
    final String relayState = kryo.readObject(input, String.class);
    try {
        return (GoogleAccountsService) CONSTRUCTOR.newInstance(
                id,
                originalUrl,
                artifactId,
                relayState,
                requestId,
                this.privateKey,
                this.publicKey,
                this.alternateUsername);
    } catch (final Exception e) {
        throw new IllegalStateException("Error creating SamlService", e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:21,代码来源:GoogleAccountsServiceSerializer.java

示例3: decode

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf in, List<Object> out) throws Exception {

        if(in.readableBytes() < 4){
            return;
        }
        in.markReaderIndex();
        int dataLength = in.readInt();
        if(in.readableBytes() < dataLength){
            in.resetReaderIndex();
            return;
        }
        byte[] data = new byte[dataLength];
        in.readBytes(data);
        
        Kryo kryo = null;
        try{
	        kryo = pool.borrow();
	        Input input = new Input(data);
	        Object obj = kryo.readObject(input,this.clazz);
	        out.add(obj);
        }catch(Exception e){
        	LOG.warn("MessageDecoder happen exception.",e);
        }finally{
        	if(kryo != null){
        		pool.release(kryo);
        	}
        }
    }
 
开发者ID:islittlechen,项目名称:lionrpc,代码行数:29,代码来源:MessageDecoder.java

示例4: deserialise

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
public static WebTables deserialise(File location) throws FileNotFoundException {
	System.out.println("Deserialising Web Tables");
	
       Kryo kryo = KryoFactory.createKryoInstance();
       
       Input input = new Input(new FileInputStream(location));
       WebTables web = kryo.readObject(input, WebTables.class);
       input.close();
       
       return web;
}
 
开发者ID:olehmberg,项目名称:T2KMatch,代码行数:12,代码来源:WebTables.java

示例5: readObjectByReflection

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
/**
 * Read object by reflection.
 *
 * @param <T>   the type parameter
 * @param kryo  the kryo
 * @param input the input
 * @param type  the type
 * @return the t
 */
private static <T> T readObjectByReflection(final Kryo kryo, final Input input, final Class<? extends T> type) {
    try {
        final String className = kryo.readObject(input, String.class);
        final Class<T> clazz = (Class<T>) Class.forName(className);
        return kryo.readObject(input, clazz);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:RegisteredServiceSerializer.java

示例6: read

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public T read(final Kryo kryo, final Input input, final Class<T> type) {
  final boolean isKnown = kryo.readObject(input, Boolean.class);
  final T result;
  if (isKnown) {
    final DistributionTrait.DistributionType kind = kryo.readObject(input, DistributionTrait.DistributionType.class);
    result = (T)distributionMap.get(kind);
  } else {
    result = super.read(kryo, input, type);
  }

  final T normalized = (T) result.getTraitDef().canonize(result);
  kryo.reference(normalized);
  return normalized;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:16,代码来源:RelTraitSerializers.java

示例7: read

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public URL read(final Kryo kryo, final Input input, final  Class<URL> type) {
    final String url = kryo.readObject(input, String.class);
    try {
        return new URL(url);
    } catch (final MalformedURLException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:URLSerializer.java

示例8: read

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public T read(final Kryo kryo, final Input input, final Class<T> type) {
  final boolean isKnown = kryo.readObject(input, Boolean.class);
  if (isKnown) {
    final Integer ordinal = kryo.readObject(input, Integer.class);
    final SqlOperator operator = OperatorPopulator.BACKWARD.get(ordinal);
    if (operator != null) {
      kryo.reference(operator);
      return (T)operator;
    }
    throw new IllegalStateException(String.format("Unable to locate operator with ordinal [%s]", ordinal));
  }

  return super.read(kryo, input, type);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:16,代码来源:SqlOperatorSerializer.java

示例9: createService

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
protected SamlService createService(final Kryo kryo, final Input input, final String id,
        final String originalUrl, final String artifactId) {

    final String requestId = kryo.readObject(input, String.class);
    try {
        return (SamlService) CONSTRUCTOR.newInstance(id, originalUrl, artifactId, new SimpleHttpClientFactoryBean().getObject(),
                requestId);
    } catch (final Exception e) {
        throw new IllegalStateException("Error creating SamlService", e);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:13,代码来源:SamlServiceSerializer.java

示例10: read

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

    Class keyClass = null;

    Serializer keySerializer = null;
    if (keyGenericType != null) {
        keyClass = keyGenericType;
        if (keySerializer == null) keySerializer = kryo.getSerializer(keyClass);
        keyGenericType = 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);
        float value = input.readFloat();
        map.put(key, value);
    }
    return map;
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:28,代码来源:ObjectFloatMapSerializer.java

示例11: serialize

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Test
    public void serialize() throws Exception {
        String testFilePath = getClass().getClassLoader().getResource("lstm_har-data").getFile();
        String inputFilePath =
                testFilePath + File.separator + "test_data" + File.separator + "sensor";
        final float[][][] inputs;

        final Kryo kryo = new Kryo();
        kryo.register(float[][][].class);
        final File dataBinFile = new File("data-small.bin");
        if (dataBinFile.exists()) {
            Input input = new Input(new FileInputStream(dataBinFile));
            inputs = kryo.readObject(input, float[][][].class);
            input.close();
        } else {
            inputs = DataUtil.parseInputData(inputFilePath);
            Output output = new Output(new FileOutputStream(dataBinFile));

            kryo.writeObject(output, inputs);
            output.close();
        }

//        Gson gson = new Gson();
//        final File dataBinFile = new File("data.json");
//        if (dataBinFile.exists()) {
//            inputs = gson.fromJson(FileUtils.readFileToString(dataBinFile), float[][][].class);
//        } else {
//            inputs = DataUtil.parseInputData(inputFilePath);
//            String result = gson.toJson(inputs);
//            FileUtils.writeStringToFile(new File("data.json"), result);
//        }


    }
 
开发者ID:csarron,项目名称:MobiRNN-EMDL17,代码行数:35,代码来源:DataUtilTest.java

示例12: deserialise

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
public static KnowledgeBase deserialise(File location) throws FileNotFoundException {
	System.out.println("Deserialising Knowledge Base");
	
       Kryo kryo = KryoFactory.createKryoInstance();
       
       Input input = new Input(new FileInputStream(location));
       KnowledgeBase kb = kryo.readObject(input, KnowledgeBase.class);
       input.close();
       
       return kb;
}
 
开发者ID:olehmberg,项目名称:T2KMatch,代码行数:12,代码来源:KnowledgeBase.java

示例13: read

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public ImmutableMap<Object, Object> read(Kryo kryo, Input input, Class<ImmutableMap<Object, ? extends Object>> type) {
  Map map = kryo.readObject(input, HashMap.class);
  final ImmutableMap<Object, Object> result = ImmutableMap.copyOf(map);
  kryo.reference(result);
  return result;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:8,代码来源:ImmutableCollectionSerializers.java

示例14: read

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public DefaultPort read(Kryo kryo, Input input, Class<DefaultPort> aClass) {
    Element element = (Element) kryo.readClassAndObject(input);
    PortNumber number = kryo.readObject(input, PortNumber.class);
    boolean isEnabled = input.readBoolean();
    Port.Type type = kryo.readObject(input, Port.Type.class);
    long portSpeed = input.readLong();
    Annotations annotations = (Annotations) kryo.readClassAndObject(input);

    return new DefaultPort(element, number, isEnabled, type, portSpeed, annotations);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:DefaultPortSerializer.java

示例15: read

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public SimpleWebApplicationServiceImpl read(final Kryo kryo, final Input input, final Class<SimpleWebApplicationServiceImpl> type) {
    return new SimpleWebApplicationServiceImpl(kryo.readObject(input, String.class));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:5,代码来源:SimpleWebApplicationServiceSerializer.java


注:本文中的com.esotericsoftware.kryo.Kryo.readObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。