Esempio n. 1
0
 static void loadDefaultTemplates(TemplateRegistry reg) {
   reg.register(boolean.class, BooleanTemplate.getInstance());
   reg.register(Boolean.class, BooleanTemplate.getInstance());
   reg.register(byte.class, ByteTemplate.getInstance());
   reg.register(Byte.class, ByteTemplate.getInstance());
   reg.register(short.class, ShortTemplate.getInstance());
   reg.register(Short.class, ShortTemplate.getInstance());
   reg.register(int.class, IntegerTemplate.getInstance());
   reg.register(Integer.class, IntegerTemplate.getInstance());
   reg.register(long.class, LongTemplate.getInstance());
   reg.register(Long.class, LongTemplate.getInstance());
   reg.register(float.class, FloatTemplate.getInstance());
   reg.register(Float.class, FloatTemplate.getInstance());
   reg.register(double.class, DoubleTemplate.getInstance());
   reg.register(Double.class, DoubleTemplate.getInstance());
   reg.register(BigInteger.class, BigIntegerTemplate.getInstance());
   reg.register(boolean[].class, ByteArrayTemplate.getInstance());
   reg.register(short[].class, ShortArrayTemplate.getInstance());
   reg.register(int[].class, IntegerArrayTemplate.getInstance());
   reg.register(long[].class, LongArrayTemplate.getInstance());
   reg.register(float[].class, FloatArrayTemplate.getInstance());
   reg.register(double[].class, DoubleArrayTemplate.getInstance());
   reg.register(String.class, StringTemplate.getInstance());
   reg.register(byte[].class, ByteArrayTemplate.getInstance());
   reg.register(Value.class, ValueTemplate.getInstance());
 }
  private void registerTemplates() {
    register(boolean.class, BooleanTemplate.getInstance());
    register(Boolean.class, BooleanTemplate.getInstance());
    register(byte.class, ByteTemplate.getInstance());
    register(Byte.class, ByteTemplate.getInstance());
    register(short.class, ShortTemplate.getInstance());
    register(Short.class, ShortTemplate.getInstance());
    register(int.class, IntegerTemplate.getInstance());
    register(Integer.class, IntegerTemplate.getInstance());
    register(long.class, LongTemplate.getInstance());
    register(Long.class, LongTemplate.getInstance());
    register(float.class, FloatTemplate.getInstance());
    register(Float.class, FloatTemplate.getInstance());
    register(double.class, DoubleTemplate.getInstance());
    register(Double.class, DoubleTemplate.getInstance());
    register(BigInteger.class, BigIntegerTemplate.getInstance());
    register(char.class, CharacterTemplate.getInstance());
    register(Character.class, CharacterTemplate.getInstance());
    register(boolean[].class, BooleanArrayTemplate.getInstance());
    register(short[].class, ShortArrayTemplate.getInstance());
    register(int[].class, IntegerArrayTemplate.getInstance());
    register(long[].class, LongArrayTemplate.getInstance());
    register(float[].class, FloatArrayTemplate.getInstance());
    register(double[].class, DoubleArrayTemplate.getInstance());
    register(String.class, StringTemplate.getInstance());
    register(byte[].class, ByteArrayTemplate.getInstance());
    register(ByteBuffer.class, ByteBufferTemplate.getInstance());
    register(Value.class, ValueTemplate.getInstance());
    register(BigDecimal.class, BigDecimalTemplate.getInstance());
    register(Date.class, DateTemplate.getInstance());

    registerTemplatesWhichRefersRegistry();
  }
Esempio n. 3
0
 static void _testFloat(Float src) throws Exception {
   ByteArrayOutputStream out = new ByteArrayOutputStream();
   new Packer(out).pack(src);
   ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
   Template tmpl = FloatTemplate.getInstance();
   Float dst = (Float) tmpl.unpack(new Unpacker(in));
   assertEquals(src, dst, 10e-10);
 }