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


Java ShortSerializer类代码示例

本文整理汇总了Java中com.esotericsoftware.kryo.serializers.DefaultSerializers.ShortSerializer的典型用法代码示例。如果您正苦于以下问题:Java ShortSerializer类的具体用法?Java ShortSerializer怎么用?Java ShortSerializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ShortSerializer类属于com.esotericsoftware.kryo.serializers.DefaultSerializers包,在下文中一共展示了ShortSerializer类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Kryo

import com.esotericsoftware.kryo.serializers.DefaultSerializers.ShortSerializer; //导入依赖的package包/类
/** @param referenceResolver May be null to disable references. */
public Kryo (ClassResolver classResolver, ReferenceResolver referenceResolver, StreamFactory streamFactory) {
	if (classResolver == null) throw new IllegalArgumentException("classResolver cannot be null.");

	this.classResolver = classResolver;
	classResolver.setKryo(this);

	this.streamFactory = streamFactory;
	streamFactory.setKryo(this);

	this.referenceResolver = referenceResolver;
	if (referenceResolver != null) {
		referenceResolver.setKryo(this);
		references = true;
	}

	addDefaultSerializer(byte[].class, ByteArraySerializer.class);
	addDefaultSerializer(char[].class, CharArraySerializer.class);
	addDefaultSerializer(short[].class, ShortArraySerializer.class);
	addDefaultSerializer(int[].class, IntArraySerializer.class);
	addDefaultSerializer(long[].class, LongArraySerializer.class);
	addDefaultSerializer(float[].class, FloatArraySerializer.class);
	addDefaultSerializer(double[].class, DoubleArraySerializer.class);
	addDefaultSerializer(boolean[].class, BooleanArraySerializer.class);
	addDefaultSerializer(String[].class, StringArraySerializer.class);
	addDefaultSerializer(Object[].class, ObjectArraySerializer.class);
	addDefaultSerializer(KryoSerializable.class, KryoSerializableSerializer.class);
	addDefaultSerializer(BigInteger.class, BigIntegerSerializer.class);
	addDefaultSerializer(BigDecimal.class, BigDecimalSerializer.class);
	addDefaultSerializer(Class.class, ClassSerializer.class);
	addDefaultSerializer(Date.class, DateSerializer.class);
	addDefaultSerializer(Enum.class, EnumSerializer.class);
	addDefaultSerializer(EnumSet.class, EnumSetSerializer.class);
	addDefaultSerializer(Currency.class, CurrencySerializer.class);
	addDefaultSerializer(StringBuffer.class, StringBufferSerializer.class);
	addDefaultSerializer(StringBuilder.class, StringBuilderSerializer.class);
	addDefaultSerializer(Collections.EMPTY_LIST.getClass(), CollectionsEmptyListSerializer.class);
	addDefaultSerializer(Collections.EMPTY_MAP.getClass(), CollectionsEmptyMapSerializer.class);
	addDefaultSerializer(Collections.EMPTY_SET.getClass(), CollectionsEmptySetSerializer.class);
	addDefaultSerializer(Collections.singletonList(null).getClass(), CollectionsSingletonListSerializer.class);
	addDefaultSerializer(Collections.singletonMap(null, null).getClass(), CollectionsSingletonMapSerializer.class);
	addDefaultSerializer(Collections.singleton(null).getClass(), CollectionsSingletonSetSerializer.class);
	addDefaultSerializer(TreeSet.class, TreeSetSerializer.class);
	addDefaultSerializer(Collection.class, CollectionSerializer.class);
	addDefaultSerializer(TreeMap.class, TreeMapSerializer.class);
	addDefaultSerializer(Map.class, MapSerializer.class);
	addDefaultSerializer(TimeZone.class, TimeZoneSerializer.class);
	addDefaultSerializer(Calendar.class, CalendarSerializer.class);
	addDefaultSerializer(Locale.class, LocaleSerializer.class);
	lowPriorityDefaultSerializerCount = defaultSerializers.size();

	// Primitives and string. Primitive wrappers automatically use the same registration as primitives.
	register(int.class, new IntSerializer());
	register(String.class, new StringSerializer());
	register(float.class, new FloatSerializer());
	register(boolean.class, new BooleanSerializer());
	register(byte.class, new ByteSerializer());
	register(char.class, new CharSerializer());
	register(short.class, new ShortSerializer());
	register(long.class, new LongSerializer());
	register(double.class, new DoubleSerializer());
	register(void.class, new VoidSerializer());
	
	// Lambdas support
	// Enable only if JVM supports it
	try {
		String version = System.getProperty("java.version");
		char minor = version.charAt(2);
		if (minor >= '8') {
			register(Class.forName("java.lang.invoke.SerializedLambda"));
			register(Closure.class, (Serializer)Class.forName("com.esotericsoftware.kryo.serializers.ClosureSerializer")
				.newInstance());
		}
	} catch (Exception e) {
		Log.trace("Serialization of Java8 lambdas is not available on this system.");
	}
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:78,代码来源:Kryo.java

示例2: Kryo

import com.esotericsoftware.kryo.serializers.DefaultSerializers.ShortSerializer; //导入依赖的package包/类
/** @param referenceResolver May be null to disable references. */
public Kryo (ClassResolver classResolver, ReferenceResolver referenceResolver, StreamFactory streamFactory) {
	if (classResolver == null) throw new IllegalArgumentException("classResolver cannot be null.");

	this.classResolver = classResolver;
	classResolver.setKryo(this);

	this.streamFactory = streamFactory;
	streamFactory.setKryo(this);

	this.referenceResolver = referenceResolver;
	if (referenceResolver != null) {
		referenceResolver.setKryo(this);
		references = true;
	}

	addDefaultSerializer(byte[].class, ByteArraySerializer.class);
	addDefaultSerializer(char[].class, CharArraySerializer.class);
	addDefaultSerializer(short[].class, ShortArraySerializer.class);
	addDefaultSerializer(int[].class, IntArraySerializer.class);
	addDefaultSerializer(long[].class, LongArraySerializer.class);
	addDefaultSerializer(float[].class, FloatArraySerializer.class);
	addDefaultSerializer(double[].class, DoubleArraySerializer.class);
	addDefaultSerializer(boolean[].class, BooleanArraySerializer.class);
	addDefaultSerializer(String[].class, StringArraySerializer.class);
	addDefaultSerializer(Object[].class, ObjectArraySerializer.class);
	addDefaultSerializer(KryoSerializable.class, KryoSerializableSerializer.class);
	addDefaultSerializer(BigInteger.class, BigIntegerSerializer.class);
	addDefaultSerializer(BigDecimal.class, BigDecimalSerializer.class);
	addDefaultSerializer(Class.class, ClassSerializer.class);
	addDefaultSerializer(Date.class, DateSerializer.class);
	addDefaultSerializer(Enum.class, EnumSerializer.class);
	addDefaultSerializer(EnumSet.class, EnumSetSerializer.class);
	addDefaultSerializer(Currency.class, CurrencySerializer.class);
	addDefaultSerializer(StringBuffer.class, StringBufferSerializer.class);
	addDefaultSerializer(StringBuilder.class, StringBuilderSerializer.class);
	addDefaultSerializer(Collections.EMPTY_LIST.getClass(), CollectionsEmptyListSerializer.class);
	addDefaultSerializer(Collections.EMPTY_MAP.getClass(), CollectionsEmptyMapSerializer.class);
	addDefaultSerializer(Collections.EMPTY_SET.getClass(), CollectionsEmptySetSerializer.class);
	addDefaultSerializer(Collections.singletonList(null).getClass(), CollectionsSingletonListSerializer.class);
	addDefaultSerializer(Collections.singletonMap(null, null).getClass(), CollectionsSingletonMapSerializer.class);
	addDefaultSerializer(Collections.singleton(null).getClass(), CollectionsSingletonSetSerializer.class);
	addDefaultSerializer(TreeSet.class, TreeSetSerializer.class);
	addDefaultSerializer(Collection.class, CollectionSerializer.class);
	addDefaultSerializer(TreeMap.class, TreeMapSerializer.class);
	addDefaultSerializer(Map.class, MapSerializer.class);
	addDefaultSerializer(TimeZone.class, TimeZoneSerializer.class);
	addDefaultSerializer(Calendar.class, CalendarSerializer.class);
	addDefaultSerializer(Locale.class, LocaleSerializer.class);
	lowPriorityDefaultSerializerCount = defaultSerializers.size();

	// Primitives and string. Primitive wrappers automatically use the same registration as primitives.
	register(int.class, new IntSerializer());
	register(String.class, new StringSerializer());
	register(float.class, new FloatSerializer());
	register(boolean.class, new BooleanSerializer());
	register(byte.class, new ByteSerializer());
	register(char.class, new CharSerializer());
	register(short.class, new ShortSerializer());
	register(long.class, new LongSerializer());
	register(double.class, new DoubleSerializer());
	register(void.class, new VoidSerializer());
}
 
开发者ID:HoratiusTang,项目名称:EsperDist,代码行数:64,代码来源:Kryo.java

示例3: Kryo

import com.esotericsoftware.kryo.serializers.DefaultSerializers.ShortSerializer; //导入依赖的package包/类
/** @param referenceResolver May be null to disable references. */
public Kryo (ClassResolver classResolver, ReferenceResolver referenceResolver, StreamFactory streamFactory) {
	if (classResolver == null) throw new IllegalArgumentException("classResolver cannot be null.");

	this.classResolver = classResolver;
	classResolver.setKryo(this);

	this.streamFactory = streamFactory;
	streamFactory.setKryo(this);

	this.referenceResolver = referenceResolver;
	if (referenceResolver != null) {
		referenceResolver.setKryo(this);
		references = true;
	}

	addDefaultSerializer(byte[].class, ByteArraySerializer.class);
	addDefaultSerializer(char[].class, CharArraySerializer.class);
	addDefaultSerializer(short[].class, ShortArraySerializer.class);
	addDefaultSerializer(int[].class, IntArraySerializer.class);
	addDefaultSerializer(long[].class, LongArraySerializer.class);
	addDefaultSerializer(float[].class, FloatArraySerializer.class);
	addDefaultSerializer(double[].class, DoubleArraySerializer.class);
	addDefaultSerializer(boolean[].class, BooleanArraySerializer.class);
	addDefaultSerializer(String[].class, StringArraySerializer.class);
	addDefaultSerializer(Object[].class, ObjectArraySerializer.class);
	addDefaultSerializer(BigInteger.class, BigIntegerSerializer.class);
	addDefaultSerializer(BigDecimal.class, BigDecimalSerializer.class);
	addDefaultSerializer(Class.class, ClassSerializer.class);
	addDefaultSerializer(Date.class, DateSerializer.class);
	addDefaultSerializer(Enum.class, EnumSerializer.class);
	addDefaultSerializer(EnumSet.class, EnumSetSerializer.class);
	addDefaultSerializer(Currency.class, CurrencySerializer.class);
	addDefaultSerializer(StringBuffer.class, StringBufferSerializer.class);
	addDefaultSerializer(StringBuilder.class, StringBuilderSerializer.class);
	addDefaultSerializer(Collections.EMPTY_LIST.getClass(), CollectionsEmptyListSerializer.class);
	addDefaultSerializer(Collections.EMPTY_MAP.getClass(), CollectionsEmptyMapSerializer.class);
	addDefaultSerializer(Collections.EMPTY_SET.getClass(), CollectionsEmptySetSerializer.class);
	addDefaultSerializer(Collections.singletonList(null).getClass(), CollectionsSingletonListSerializer.class);
	addDefaultSerializer(Collections.singletonMap(null, null).getClass(), CollectionsSingletonMapSerializer.class);
	addDefaultSerializer(Collections.singleton(null).getClass(), CollectionsSingletonSetSerializer.class);
	addDefaultSerializer(Collection.class, CollectionSerializer.class);
	addDefaultSerializer(TreeMap.class, TreeMapSerializer.class);
	addDefaultSerializer(Map.class, MapSerializer.class);
	addDefaultSerializer(KryoSerializable.class, KryoSerializableSerializer.class);
	addDefaultSerializer(TimeZone.class, TimeZoneSerializer.class);
	addDefaultSerializer(Calendar.class, CalendarSerializer.class);
	lowPriorityDefaultSerializerCount = defaultSerializers.size();

	// Primitives and string. Primitive wrappers automatically use the same registration as primitives.
	register(int.class, new IntSerializer());
	register(String.class, new StringSerializer());
	register(float.class, new FloatSerializer());
	register(boolean.class, new BooleanSerializer());
	register(byte.class, new ByteSerializer());
	register(char.class, new CharSerializer());
	register(short.class, new ShortSerializer());
	register(long.class, new LongSerializer());
	register(double.class, new DoubleSerializer());
}
 
开发者ID:esialb,项目名称:kryo-mavenized,代码行数:61,代码来源:Kryo.java


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