Package net.buffalo.protocal.converters

Examples of net.buffalo.protocal.converters.Converter


    this.objects = new ArrayList();
  }
 
  public Object convertAnother() {
    streamReader.moveDown();
    Converter converter = converterLookup.lookupConverterForTagName(streamReader.getNodeName());
    Object object = converter.unmarshal(streamReader, this);
    streamReader.moveUp();
    return object;
  }
View Full Code Here


  public void convertAnother(Object value) {
    if (value == null) {
      converterLookup.getNullConverter().marshal(value, this, streamWriter);
    } else {
      Converter converter = converterLookup.lookupConverterForType(value.getClass());
      converter.marshal(value, this, streamWriter);
    }
  }
View Full Code Here

   
  }
 
  public void testMarshallingBigDecimal() throws Exception {
    BigDecimal number = new BigDecimal("123.456");
    Converter converter = converterLookup.lookupConverterForType(BigDecimal.class);
    assertEquals(BigNumberConverter.class, converter.getClass());
    marshallingContext.convertAnother(number);
    String str = stringWriter.getBuffer().toString();
    assertEquals("<map><type>java.math.BigDecimal</type>" +
        "<string>value</string>" +
        "<string>123.456</string></map>", str);
View Full Code Here

        "<string>123.456</string></map>", str);
  }
 
  public void testMarshallingBigInteger() throws Exception {
    BigInteger number = new BigInteger("123");
    Converter converter = converterLookup.lookupConverterForType(BigInteger.class);
    assertEquals(BigNumberConverter.class, converter.getClass());
    marshallingContext.convertAnother(number);
    String str = stringWriter.getBuffer().toString();
    assertEquals("<map><type>java.math.BigInteger</type>" +
        "<string>value</string>" +
        "<string>123</string></map>", str);
View Full Code Here

    assertTrue(serializer.canConvert(Short.class));
    assertTrue(serializer.canConvert(Byte.class));
  }
 
  public void testShouldOutputBoolean() throws Exception {
    Converter serializer = new BooleanConverter();
    assertEquals("<boolean>1</boolean>", marshal(serializer, Boolean.TRUE));
    assertEquals("<boolean>0</boolean>", marshal(serializer, Boolean.FALSE));
    assertTrue(serializer.canConvert(Boolean.class));
    assertFalse(serializer.canConvert(Long.class));
  }
View Full Code Here

TOP

Related Classes of net.buffalo.protocal.converters.Converter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.