Author: hgomez Date: Mon May 8 01:36:41 2006 New Revision: 404968 URL: http://svn.apache.org/viewcvs?rev=404968&view=rev Log: Add support for BigDecimal and BigInteger in extension mode
Added: webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/parser/BigDecimalParser.java webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/parser/BigIntegerParser.java webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/serializer/BigDecimalSerializer.java webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/serializer/BigIntegerSerializer.java Added: webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/parser/BigDecimalParser.java URL: http://svn.apache.org/viewcvs/webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/parser/BigDecimalParser.java?rev=404968&view=auto ============================================================================== --- webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/parser/BigDecimalParser.java (added) +++ webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/parser/BigDecimalParser.java Mon May 8 01:36:41 2006 @@ -0,0 +1,35 @@ +/* + * Copyright 1999,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.xmlrpc.parser; + +import java.math.BigDecimal; + +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + + +/** Parser for BigDecimal values. + */ +public class BigDecimalParser extends AtomicParser { + protected void setResult(String pResult) throws SAXException { + try { + super.setResult(new BigDecimal(pResult)); + } catch (NumberFormatException e) { + throw new SAXParseException("Failed to parse BigDecimal value: " + pResult, + getDocumentLocator()); + } + } +} Added: webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/parser/BigIntegerParser.java URL: http://svn.apache.org/viewcvs/webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/parser/BigIntegerParser.java?rev=404968&view=auto ============================================================================== --- webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/parser/BigIntegerParser.java (added) +++ webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/parser/BigIntegerParser.java Mon May 8 01:36:41 2006 @@ -0,0 +1,35 @@ +/* + * Copyright 1999,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.xmlrpc.parser; + +import java.math.BigInteger; + +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + + +/** Parser for BigInteger values. + */ +public class BigIntegerParser extends AtomicParser { + protected void setResult(String pResult) throws SAXException { + try { + super.setResult(new BigInteger(pResult)); + } catch (NumberFormatException e) { + throw new SAXParseException("Failed to parse BigInteger value: " + pResult, + getDocumentLocator()); + } + } +} Added: webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/serializer/BigDecimalSerializer.java URL: http://svn.apache.org/viewcvs/webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/serializer/BigDecimalSerializer.java?rev=404968&view=auto ============================================================================== --- webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/serializer/BigDecimalSerializer.java (added) +++ webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/serializer/BigDecimalSerializer.java Mon May 8 01:36:41 2006 @@ -0,0 +1,35 @@ +/* + * Copyright 1999,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.xmlrpc.serializer; + +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; + +/** A [EMAIL PROTECTED] TypeSerializer} for BigDecimal. + */ +public class BigDecimalSerializer extends TypeSerializerImpl { + /** Tag name of a BigDecimal value. + */ + public static final String BIGDECIMAL_TAG = "bigdecimal"; + + private static final String EX_BIGDECIMAL_TAG = "ex:" + BIGDECIMAL_TAG; + + public void write(ContentHandler pHandler, Object pObject) throws SAXException { + write(pHandler, BIGDECIMAL_TAG, EX_BIGDECIMAL_TAG, pObject.toString()); + } + +} + Added: webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/serializer/BigIntegerSerializer.java URL: http://svn.apache.org/viewcvs/webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/serializer/BigIntegerSerializer.java?rev=404968&view=auto ============================================================================== --- webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/serializer/BigIntegerSerializer.java (added) +++ webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/serializer/BigIntegerSerializer.java Mon May 8 01:36:41 2006 @@ -0,0 +1,35 @@ +/* + * Copyright 1999,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.xmlrpc.serializer; + +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; + +/** A [EMAIL PROTECTED] TypeSerializer} for BigInteger. + */ +public class BigIntegerSerializer extends TypeSerializerImpl { + /** Tag name of a BigDecimal value. + */ + public static final String BIGINTEGER_TAG = "biginteger"; + + private static final String EX_BIGINTEGER_TAG = "ex:" + BIGINTEGER_TAG; + + public void write(ContentHandler pHandler, Object pObject) throws SAXException { + write(pHandler, BIGINTEGER_TAG, EX_BIGINTEGER_TAG, pObject.toString()); + } + +} +