You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by je...@locus.apache.org on 2000/06/20 23:29:03 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/validators/datatype DecimalDatatypeValidator.java
jeffreyr 00/06/20 14:29:03
Modified: java/src/org/apache/xerces/validators/datatype
DecimalDatatypeValidator.java
Log:
catch all exception and throw them up as InvalidDatatypexxxx Exceptions
Revision Changes Path
1.5 +15 -16 xml-xerces/java/src/org/apache/xerces/validators/datatype/DecimalDatatypeValidator.java
Index: DecimalDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/DecimalDatatypeValidator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DecimalDatatypeValidator.java 2000/06/07 16:04:00 1.4
+++ DecimalDatatypeValidator.java 2000/06/20 21:29:02 1.5
@@ -71,7 +71,7 @@
*
* @author Ted Leung
* @author Jeffrey Rodriguez
- * @version $Id: DecimalDatatypeValidator.java,v 1.4 2000/06/07 16:04:00 jeffreyr Exp $
+ * @version $Id: DecimalDatatypeValidator.java,v 1.5 2000/06/20 21:29:02 jeffreyr Exp $
*/
public class DecimalDatatypeValidator extends AbstractDatatypeValidator {
@@ -154,7 +154,7 @@
getErrorString( DatatypeMessageProvider.MSG_FORMAT_FAILURE,
DatatypeMessageProvider.MSG_NONE, null));
}
- } catch ( NumberFormatException ex ){
+ } catch ( Exception ex ){
throw new InvalidDatatypeFacetException( getErrorString(
DatatypeMessageProvider.IllegalFacetValue,
DatatypeMessageProvider.MSG_NONE, new Object [] { value, key}));
@@ -182,18 +182,18 @@
if ( (fFacetsDefined & DatatypeValidator.FACET_ENUMERATION ) != 0 ) {
if (enumeration != null) {
fEnumDecimal = new BigDecimal[enumeration.size()];
- for (int i = 0; i < enumeration.size(); i++)
+ int i = 0;
try {
- fEnumDecimal[i] = new BigDecimal( ((String) enumeration.elementAt(i)));
- boundsCheck(fEnumDecimal[i]); // Check against max,min Inclusive, Exclusives
- } catch (InvalidDatatypeValueException idve) {
+ for ( ; i < enumeration.size(); i++) {
+ fEnumDecimal[i] =
+ new BigDecimal( ((String) enumeration.elementAt(i)));
+ boundsCheck(fEnumDecimal[i]); // Check against max,min Inclusive, Exclusives
+ }
+ } catch( Exception idve ){
throw new InvalidDatatypeFacetException(
- getErrorString(DatatypeMessageProvider.InvalidEnumValue,
- DatatypeMessageProvider.MSG_NONE,
- new Object [] { enumeration.elementAt(i)}));
- } catch (NumberFormatException nfe) {
- throw new InvalidDatatypeFacetException(
- "Internal Error parsing enumerated values for Decimal type");
+ getErrorString(DatatypeMessageProvider.InvalidEnumValue,
+ DatatypeMessageProvider.MSG_NONE,
+ new Object [] { enumeration.elementAt(i)}));
}
}
}
@@ -211,23 +211,22 @@
* W3C decimal type.
*
* @param content A string containing the content to be validated
- *
+ * cd
* @exception throws InvalidDatatypeException if the content is
* is not a W3C decimal type
*/
public Object validate(String content, Object state) throws InvalidDatatypeValueException {
-
if ( fDerivationByList == false ) { //derived by restriction
BigDecimal d = null; // Is content a Decimal
try {
d = new BigDecimal(content);
- } catch (NumberFormatException nfe) {
+ } catch (Exception nfe) {
throw new InvalidDatatypeValueException(
getErrorString(DatatypeMessageProvider.NotDecimal,
DatatypeMessageProvider.MSG_NONE,
- new Object[] { content}));
+ new Object[] { "'" + content +"'"}));
}
if( isScaleDefined == true ) {
if (d.scale() > fScale)