1 17 package org.apache.ws.jaxme.generator.types; 18 19 import org.apache.ws.jaxme.generator.sg.SGFactory; 20 import org.apache.ws.jaxme.generator.sg.SchemaSG; 21 import org.apache.ws.jaxme.generator.sg.SimpleTypeSG; 22 import org.apache.ws.jaxme.impl.DatatypeConverterImpl; 23 import org.apache.ws.jaxme.js.TypedValue; 24 import org.apache.ws.jaxme.js.impl.TypedValueImpl; 25 import org.apache.ws.jaxme.xs.XSType; 26 import org.apache.ws.jaxme.xs.parser.impl.LocSAXException; 27 import org.xml.sax.SAXException ; 28 29 32 public class UnsignedIntSG extends LongSG { 33 35 public UnsignedIntSG(SGFactory pFactory, SchemaSG pSchema, XSType pType) throws SAXException { 36 super(pFactory, pSchema, pType); 37 } 38 39 protected boolean isUnsigned() { return true; } 40 protected String getDatatypeName() { return "UnsignedInt"; } 41 42 public TypedValue getCastFromString(SimpleTypeSG pController, String pValue) throws SAXException { 43 try { 44 return new TypedValueImpl(new Long (new DatatypeConverterImpl().parseUnsignedInt(pValue)) + "l", LONG_TYPE); 45 } catch (NumberFormatException e) { 46 throw new LocSAXException("Failed to convert string value to unsigned integer: " + pValue, getLocator()); 47 } 48 } 49 } 50 | Popular Tags |