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();
  }
 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());
 }
示例#3
0
 static void _testBoolean(Boolean src) throws Exception {
   ByteArrayOutputStream out = new ByteArrayOutputStream();
   new Packer(out).pack(src);
   ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
   Template tmpl = BooleanTemplate.getInstance();
   Boolean dst = (Boolean) tmpl.unpack(new Unpacker(in));
   assertEquals(src, dst);
 }
示例#4
0
 @Test
 public void testNullBoolean() throws Exception {
   Boolean src = null;
   ByteArrayOutputStream out = new ByteArrayOutputStream();
   new Packer(out).pack(src);
   byte[] bytes = out.toByteArray();
   Template tmpl = null;
   Unpacker unpacker = new Unpacker();
   Boolean dst = null;
   try {
     tmpl = BooleanTemplate.getInstance();
     unpacker.wrap(bytes);
     dst = (Boolean) tmpl.unpack(unpacker);
     fail();
   } catch (Exception e) {
     assertTrue(e instanceof MessageTypeException);
   }
   unpacker.wrap(bytes);
   tmpl = new OptionalTemplate(BooleanTemplate.getInstance());
   dst = (Boolean) tmpl.unpack(unpacker);
   assertEquals(src, dst);
 }