View Javadoc

1   /*******************************************************************************
2    *  Copyright (c) 2005, 2006 Imola Informatica.
3    *  All rights reserved. This program and the accompanying materials
4    *  are made available under the terms of the LGPL License v2.1
5    *  which accompanies this distribution, and is available at
6    *  http://www.gnu.org/licenses/lgpl.html
7    *******************************************************************************/
8   package it.imolinfo.jbi4cics.webservices.runtime;
9   
10  import java.math.BigInteger;
11  
12  import javax.xml.namespace.QName;
13  
14  import org.apache.commons.logging.Log;
15  import org.apache.commons.logging.LogFactory;
16  import org.codehaus.xfire.MessageContext;
17  import org.codehaus.xfire.aegis.MessageReader;
18  import org.codehaus.xfire.aegis.MessageWriter;
19  import org.codehaus.xfire.aegis.type.Type;
20  
21  public class BigIntegerType extends Type {
22    
23    private static Log log = LogFactory.getLog(BigIntegerType.class);  
24  
25    public BigIntegerType() {
26      setNillable(true);
27      setSchemaType(new QName("http://www.w3.org/2001/XMLSchema","int"));
28      setTypeClass(BigInteger.class);
29    }
30  
31    public Object readObject(MessageReader reader, MessageContext context) {
32      String value = reader.getValue();
33      log.debug("big integer value: ["+value+"]");
34      if (value==null || "".equals(value)){
35        return null;
36      }
37      return new BigInteger(value);
38    }
39  
40    public void writeObject(Object object, MessageWriter writer, MessageContext context) {
41      writer.writeValue(object.toString());
42    }
43  }