本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
// }
}
示例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;
}
示例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;
}
示例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);
}
示例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