You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2001/10/22 23:22:37 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes AbstractNumericValidator.java AbstractStringValidator.java BooleanDatatypeValidator.java DateTimeValidator.java DecimalDatatypeValidator.java DoubleDatatypeValidator.java FloatDatatypeValidator.java IDDatatypeValidator.java IDREFDatatypeValidator.java NOTATIONDatatypeValidator.java UnionDatatypeValidator.java
sandygao 01/10/22 14:22:37
Modified: java/src/org/apache/xerces/impl/v2/datatypes
AbstractNumericValidator.java
AbstractStringValidator.java
BooleanDatatypeValidator.java
DateTimeValidator.java
DecimalDatatypeValidator.java
DoubleDatatypeValidator.java
FloatDatatypeValidator.java
IDDatatypeValidator.java
IDREFDatatypeValidator.java
NOTATIONDatatypeValidator.java
UnionDatatypeValidator.java
Log:
The method signatures are not consistent.
For the current design, all "checkContent" method should return nothing, and
take ValidationContext as a parameter (instead of Object).
Revision Changes Path
1.6 +10 -10 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AbstractNumericValidator.java
Index: AbstractNumericValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AbstractNumericValidator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractNumericValidator.java 2001/10/16 17:21:39 1.5
+++ AbstractNumericValidator.java 2001/10/22 21:22:37 1.6
@@ -70,11 +70,11 @@
import org.apache.xerces.impl.v2.XSMessageFormatter;
import org.apache.xerces.impl.validation.ValidationContext;
/**
- * AbstractNumericValidator is a base class of decimal, double, and float
+ * AbstractNumericValidator is a base class of decimal, double, and float
* schema datatypes
- *
+ *
* @author Elena Litani
- * @version $Id: AbstractNumericValidator.java,v 1.5 2001/10/16 17:21:39 elena Exp $
+ * @version $Id: AbstractNumericValidator.java,v 1.6 2001/10/22 21:22:37 sandygao Exp $
*/
public abstract class AbstractNumericValidator extends AbstractNumericFacetValidator {
@@ -83,8 +83,8 @@
super( null, null, false , null); // Native, No Facets defined, Restriction
}
- public AbstractNumericValidator ( DatatypeValidator base,
- Hashtable facets,
+ public AbstractNumericValidator ( DatatypeValidator base,
+ Hashtable facets,
boolean derivedByList, XMLErrorReporter reporter) {
super (base, facets, derivedByList, reporter);
}
@@ -92,10 +92,10 @@
/**
* Validate string against lexical space of datatype
- *
+ *
* @param content A string containing the content to be validated
* @param state
- * @return
+ * @return
* @exception throws InvalidDatatypeException if the content is
* is not a W3C decimal type
* @exception InvalidDatatypeValueException
@@ -120,7 +120,7 @@
* is not a W3C decimal type;
* @exception throws InvalidDatatypeFacetException if enumeration is not BigDecimal
*/
- protected void checkContentEnum(String content, Object state, Vector enumeration)
+ protected void checkContentEnum(String content, ValidationContext state, Vector enumeration)
throws InvalidDatatypeValueException {
checkContent(content, state, enumeration, false);
}
@@ -129,7 +129,7 @@
//
// content - string value to be evaluated
//
- abstract protected void checkContent( String content, Object State, Vector enum, boolean asBase)
+ abstract protected void checkContent( String content, ValidationContext State, Vector enum, boolean asBase)
throws InvalidDatatypeValueException;
@@ -193,7 +193,7 @@
}
if ( !(minOk && maxOk) ){
-
+
String msg = getErrorString(
DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.OUT_OF_BOUNDS],
new Object [] { d.toString(), lowerBound, upperBound, lowerBoundIndicator, upperBoundIndicator});
1.10 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AbstractStringValidator.java
Index: AbstractStringValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AbstractStringValidator.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AbstractStringValidator.java 2001/10/16 17:21:39 1.9
+++ AbstractStringValidator.java 2001/10/22 21:22:37 1.10
@@ -76,7 +76,7 @@
* hexBinary, base64Binary, QName and Notation datatypes.
*
* @author Elena Litani
- * @version $Id: AbstractStringValidator.java,v 1.9 2001/10/16 17:21:39 elena Exp $
+ * @version $Id: AbstractStringValidator.java,v 1.10 2001/10/22 21:22:37 sandygao Exp $
*/
public abstract class AbstractStringValidator extends AbstractDatatypeValidator {
@@ -344,7 +344,7 @@
}
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"DatatypeFacetError", new Object [] { ((Exception)e).getMessage()},
- XMLErrorReporter.SEVERITY_ERROR);
+ XMLErrorReporter.SEVERITY_ERROR);
}
}
@@ -387,7 +387,7 @@
}
- private void checkContent( String content, Object state, boolean asBase )
+ protected void checkContent( String content, ValidationContext state, boolean asBase )
throws InvalidDatatypeValueException {
// validate against parent type if any
if (fBaseValidator instanceof AbstractStringValidator) {
1.7 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/BooleanDatatypeValidator.java
Index: BooleanDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/BooleanDatatypeValidator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- BooleanDatatypeValidator.java 2001/10/16 17:21:39 1.6
+++ BooleanDatatypeValidator.java 2001/10/22 21:22:37 1.7
@@ -73,7 +73,7 @@
* @author Ted Leung
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: BooleanDatatypeValidator.java,v 1.6 2001/10/16 17:21:39 elena Exp $
+ * @version $Id: BooleanDatatypeValidator.java,v 1.7 2001/10/22 21:22:37 sandygao Exp $
*/
public class BooleanDatatypeValidator extends AbstractDatatypeValidator {
@@ -114,7 +114,7 @@
}
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"DatatypeFacetError", new Object [] { msg},
- XMLErrorReporter.SEVERITY_ERROR);
+ XMLErrorReporter.SEVERITY_ERROR);
}
}
}// End of facet setting
@@ -177,7 +177,7 @@
* @param content
* @exception InvalidDatatypeValueException
*/
- private void checkContent( String content, boolean asBase )
+ protected void checkContent( String content, boolean asBase )
throws InvalidDatatypeValueException {
// validate against parent type if any
// REVISIT: fast fix to avoid class cast exception
1.9 +2 -2 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DateTimeValidator.java
Index: DateTimeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DateTimeValidator.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DateTimeValidator.java 2001/10/19 18:22:00 1.8
+++ DateTimeValidator.java 2001/10/22 21:22:37 1.9
@@ -75,7 +75,7 @@
* @author Elena Litani
* @author Len Berman
*
- * @version $Id: DateTimeValidator.java,v 1.8 2001/10/19 18:22:00 sandygao Exp $
+ * @version $Id: DateTimeValidator.java,v 1.9 2001/10/22 21:22:37 sandygao Exp $
*/
public abstract class DateTimeValidator extends AbstractNumericFacetValidator {
@@ -219,7 +219,7 @@
:dateToString((int[])fMinExclusive);
}
- protected void checkContent( String content, Object State, Vector enum, boolean asBase)
+ protected void checkContent( String content, ValidationContext State, Vector enum, boolean asBase)
throws InvalidDatatypeValueException{
}
1.8 +2 -2 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DecimalDatatypeValidator.java
Index: DecimalDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DecimalDatatypeValidator.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DecimalDatatypeValidator.java 2001/10/19 18:22:00 1.7
+++ DecimalDatatypeValidator.java 2001/10/22 21:22:37 1.8
@@ -76,7 +76,7 @@
* @author Ted Leung
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: DecimalDatatypeValidator.java,v 1.7 2001/10/19 18:22:00 sandygao Exp $
+ * @version $Id: DecimalDatatypeValidator.java,v 1.8 2001/10/22 21:22:37 sandygao Exp $
*/
public class DecimalDatatypeValidator extends AbstractNumericValidator {
@@ -257,7 +257,7 @@
- protected void checkContent(String content, Object state, Vector enumeration, boolean asBase)
+ protected void checkContent(String content, ValidationContext state, Vector enumeration, boolean asBase)
throws InvalidDatatypeValueException {
// validate against parent type if any
if (fBaseValidator instanceof DecimalDatatypeValidator) {
1.7 +5 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DoubleDatatypeValidator.java
Index: DoubleDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/DoubleDatatypeValidator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DoubleDatatypeValidator.java 2001/10/16 17:21:39 1.6
+++ DoubleDatatypeValidator.java 2001/10/22 21:22:37 1.7
@@ -71,7 +71,7 @@
* @author Ted Leung
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: DoubleDatatypeValidator.java,v 1.6 2001/10/16 17:21:39 elena Exp $
+ * @version $Id: DoubleDatatypeValidator.java,v 1.7 2001/10/22 21:22:37 sandygao Exp $
*/
public class DoubleDatatypeValidator extends AbstractNumericValidator {
@@ -98,13 +98,13 @@
}
- protected void assignAdditionalFacets(String key, Hashtable facets ) throws InvalidDatatypeFacetException{
+ protected void assignAdditionalFacets(String key, Hashtable facets ) throws InvalidDatatypeFacetException{
String msg = "double datatype, facet "+key+" with value "+(String)facets.get(key);
throw new InvalidDatatypeFacetException(msg);
}
/**
* Compares 2 double values.
- *
+ *
* @param value1 - Double
* @param value2 - Double
* @return value1<value2 return -1
@@ -179,12 +179,12 @@
* @exception throws InvalidDatatypeFacetException if enumeration is not double
*/
- protected void checkContentEnum(String content, Object state, Vector enumeration)
+ protected void checkContentEnum(String content, ValidationContext state, Vector enumeration)
throws InvalidDatatypeValueException {
checkContent (content, state, enumeration, false);
}
- protected void checkContent(String content, Object state, Vector enumeration, boolean asBase)
+ protected void checkContent(String content, ValidationContext state, Vector enumeration, boolean asBase)
throws InvalidDatatypeValueException {
// validate against parent type if any
if ( this.fBaseValidator != null && !(fBaseValidator instanceof AnySimpleType)) {
1.7 +6 -6 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/FloatDatatypeValidator.java
Index: FloatDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/FloatDatatypeValidator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FloatDatatypeValidator.java 2001/10/16 17:21:39 1.6
+++ FloatDatatypeValidator.java 2001/10/22 21:22:37 1.7
@@ -75,7 +75,7 @@
* @author Ted Leung
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: FloatDatatypeValidator.java,v 1.6 2001/10/16 17:21:39 elena Exp $
+ * @version $Id: FloatDatatypeValidator.java,v 1.7 2001/10/22 21:22:37 sandygao Exp $
*/
public class FloatDatatypeValidator extends AbstractNumericValidator {
@@ -89,7 +89,7 @@
// Set base type
super (base, facets, derivedByList, reporter);
}
-
+
public int compare( String value1, String value2) {
try {
float f1 = fValueOf(value1).floatValue();
@@ -102,7 +102,7 @@
}
}
- protected void assignAdditionalFacets(String key, Hashtable facets ) throws InvalidDatatypeFacetException{
+ protected void assignAdditionalFacets(String key, Hashtable facets ) throws InvalidDatatypeFacetException{
String msg = "float datatype, facet "+key+" with value "+(String)facets.get(key);
throw new InvalidDatatypeFacetException(msg);
}
@@ -113,7 +113,7 @@
float f2 = ((Float)value2).floatValue();
return compareFloats(f1, f2);
}
-
+
protected void setMaxInclusive (String value) {
fMaxInclusive = fValueOf(value);
}
@@ -169,7 +169,7 @@
* @exception throws InvalidDatatypeFacetException if enumeration is not float
*/
- protected void checkContent(String content, Object state, Vector enumeration, boolean asBase)
+ protected void checkContent(String content, ValidationContext state, Vector enumeration, boolean asBase)
throws InvalidDatatypeValueException {
// validate against parent type if any
if ( this.fBaseValidator != null && !(fBaseValidator instanceof AnySimpleType)) {
@@ -229,7 +229,7 @@
protected int getInvalidFacetMsg (){
return DatatypeMessageProvider.ILLEGAL_FLOAT_FACET;
- }
+ }
private void enumCheck(float v, Float[] enumFloats) throws InvalidDatatypeValueException {
for ( int i = 0; i < enumFloats.length; i++ ) {
1.9 +3 -34 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/IDDatatypeValidator.java
Index: IDDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/IDDatatypeValidator.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- IDDatatypeValidator.java 2001/10/19 18:22:00 1.8
+++ IDDatatypeValidator.java 2001/10/22 21:22:37 1.9
@@ -72,7 +72,7 @@
* standalone code as well as plugins to the validator architecture.
* @author Jeffrey Rodriguez
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: IDDatatypeValidator.java,v 1.8 2001/10/19 18:22:00 sandygao Exp $
+ * @version $Id: IDDatatypeValidator.java,v 1.9 2001/10/22 21:22:37 sandygao Exp $
*/
public class IDDatatypeValidator extends StringDatatypeValidator {
@@ -115,52 +115,21 @@
* invalid according to the rules for the validators
*/
public Object validate(String content, ValidationContext state ) throws InvalidDatatypeValueException{
- return checkContent(content, state, false);
- }
-
-
-
- private Object checkContent( String content, ValidationContext state, boolean asBase )
- throws InvalidDatatypeValueException {
-
-
- // validate against parent type if any
- if (fBaseValidator instanceof IDDatatypeValidator) {
- // validate content as a base type
- ((IDDatatypeValidator)fBaseValidator).checkContent(content, state, true);
- }
-
- // we check pattern first
- if ((fFacetsDefined & DatatypeValidator.FACET_PATTERN ) != 0) {
- if (fRegex == null || fRegex.matches( content) == false)
- throw new InvalidDatatypeValueException("Value '"+content+
- "' does not match regular expression facet '" + fPattern + "'." );
- }
-
-
- // if this is a base validator, we only need to check pattern facet
- // all other facet were inherited by the derived type
- if (asBase)
- return content;
+ Object retVal = super.validate(content, state);
if (state != null) {
if (state.isIdDeclared(content)) {
throw new InvalidDatatypeValueException( "ID '" + content +"' has to be unique" );
}
state.addId(content);
}
-
- return content;
-
-
+ return retVal;
}
-
/**
* Returns a copy of this object.
*/
public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException("clone() is not supported in "+this.getClass().getName());
}
-
}
1.10 +5 -30 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/IDREFDatatypeValidator.java
Index: IDREFDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/IDREFDatatypeValidator.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- IDREFDatatypeValidator.java 2001/10/19 18:22:00 1.9
+++ IDREFDatatypeValidator.java 2001/10/22 21:22:37 1.10
@@ -73,7 +73,7 @@
*
* @author Jeffrey Rodriguez-
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: IDREFDatatypeValidator.java,v 1.9 2001/10/19 18:22:00 sandygao Exp $
+ * @version $Id: IDREFDatatypeValidator.java,v 1.10 2001/10/22 21:22:37 sandygao Exp $
*/
public class IDREFDatatypeValidator extends StringDatatypeValidator {
private static Object fNullValue = new Object();
@@ -127,48 +127,23 @@
* @see org.apache.xerces.validators.datatype.InvalidDatatypeValueException
*/
public Object validate(String content, ValidationContext state ) throws InvalidDatatypeValueException{
+ Object retVal = super.validate(content, state);
- return checkContent (content, state, false);
-
- }
-
-
- private Object checkContent( String content, ValidationContext state, boolean asBase )
- throws InvalidDatatypeValueException {
- // validate against parent type if any
- if (fBaseValidator instanceof IDREFDatatypeValidator) {
- // validate content as a base type
- ((IDREFDatatypeValidator)fBaseValidator).checkContent(content, state, true);
- }
-
- // we check pattern first
- if ((fFacetsDefined & DatatypeValidator.FACET_PATTERN ) != 0) {
- if (fRegex == null || fRegex.matches( content) == false)
- throw new InvalidDatatypeValueException("Value '"+content+
- "' does not match regular expression facet '" + fPattern + "'." );
- }
-
-
- // if this is a base validator, we only need to check pattern facet
- // all other facet were inherited by the derived type
- if (asBase)
- return content;
-
- // state could be null when we validate schema (facet enumeration)
if (state != null) {
state.addIdRef(content);
if (!state.isIdDeclared(content)) {
InvalidDatatypeValueException error = new InvalidDatatypeValueException( content );
}
}
- return content;
+
+ return retVal;
}
+
/**
* Returns a copy of this object.
*/
public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException("clone() is not supported in "+this.getClass().getName());
}
-
}
1.6 +10 -10 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/NOTATIONDatatypeValidator.java
Index: NOTATIONDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/NOTATIONDatatypeValidator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NOTATIONDatatypeValidator.java 2001/10/19 17:21:55 1.5
+++ NOTATIONDatatypeValidator.java 2001/10/22 21:22:37 1.6
@@ -72,11 +72,11 @@
* @author Elena Litani
* @author Jeffrey Rodriguez-
* @author Mark Swinkles - List Validation refactoring
- * @version $Id: NOTATIONDatatypeValidator.java,v 1.5 2001/10/19 17:21:55 elena Exp $
+ * @version $Id: NOTATIONDatatypeValidator.java,v 1.6 2001/10/22 21:22:37 sandygao Exp $
*/
public class NOTATIONDatatypeValidator extends AbstractStringValidator {
-
+
// for the QName validator
/*
private static StringDatatypeValidator fgStrValidator = null;
@@ -103,7 +103,7 @@
fgURIValidator = new AnyURIDatatypeValidator (null, null, false);
}
*/
-
+
}
protected void assignAdditionalFacets(String key, Hashtable facets) throws InvalidDatatypeFacetException{
@@ -119,7 +119,7 @@
return null;
}
- private void checkContent( String content, ValidationContext state, boolean asBase )
+ protected void checkContent( String content, ValidationContext state, boolean asBase )
throws InvalidDatatypeValueException {
// validate against parent type if any
if (fBaseValidator instanceof NOTATIONDatatypeValidator) {
@@ -147,7 +147,7 @@
// REVISIT: see comments in checkValueSpace
// checkValueSpace (content);
int length = getLength(content);
- // REVISIT: XML Schema group does not clearly specify how QNames should be
+ // REVISIT: XML Schema group does not clearly specify how QNames should be
// compared against length, minLength, maxLength we don't do any comparison
//
if (state !=null && (fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0 &&
@@ -161,15 +161,15 @@
}
String uriStr = state.getURI(state.getSymbol(prefix));
- String fullName = (uriStr!=null)?(uriStr+","+localpart):localpart;
+ String fullName = (uriStr!=null)?(uriStr+","+localpart):localpart;
if (fEnumeration.contains( fullName ) == false)
throw new InvalidDatatypeValueException("Value '"+content+"' must be one of "+fEnumeration);
}
}
protected void checkValueSpace (String content) throws InvalidDatatypeValueException {
-
- // REVISIT: do we need to check 3.2.19: "anyURI:NCName"?
+
+ // REVISIT: do we need to check 3.2.19: "anyURI:NCName"?
/*
try {
int posColon = content.lastIndexOf(':');
@@ -180,8 +180,8 @@
throw new InvalidDatatypeValueException("Value '"+content+"' is not a valid NOTATION");
}
*/
-
- }
+
+ }
public int compare( String content1, String content2){
return content1.equals(content2)?0:-1;
1.7 +24 -24 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/UnionDatatypeValidator.java
Index: UnionDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/UnionDatatypeValidator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- UnionDatatypeValidator.java 2001/10/16 17:21:39 1.6
+++ UnionDatatypeValidator.java 2001/10/22 21:22:37 1.7
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights
+ * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -77,11 +77,11 @@
* Implements the September 22 XML Schema datatype Union Datatype type
*/
public class UnionDatatypeValidator extends AbstractDatatypeValidator {
-
+
private Vector fBaseValidators = null; // union collection of validators
private int fValidatorsSize = 0;
private Vector fEnumeration = null;
- private StringBuffer errorMsg = null;
+ private StringBuffer errorMsg = null;
public UnionDatatypeValidator () {
@@ -90,13 +90,13 @@
}
- public UnionDatatypeValidator ( DatatypeValidator base, Hashtable facets,
+ public UnionDatatypeValidator ( DatatypeValidator base, Hashtable facets,
boolean derivedBy, XMLErrorReporter reporter ) {
fErrorReporter = reporter;
- fBaseValidator = base;
+ fBaseValidator = base;
//facets allowed are: pattern & enumeration
try{
-
+
if ( facets != null ) {
for ( Enumeration e = facets.keys(); e.hasMoreElements(); ) {
String key = (String) e.nextElement();
@@ -134,7 +134,7 @@
} catch (Exception e){
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"DatatypeFacetError", new Object [] { ((Exception)e).getMessage()},
- XMLErrorReporter.SEVERITY_ERROR);
+ XMLErrorReporter.SEVERITY_ERROR);
}
}
@@ -154,7 +154,7 @@
/**
* validate that a string is a W3C string type
- *
+ *
* @param content A string containing the content to be validated
* @param list
* @exception throws InvalidDatatypeException if the content is
@@ -175,7 +175,7 @@
/**
- *
+ *
* @return A Hashtable containing the facets
* for this datatype.
*/
@@ -190,7 +190,7 @@
//union datatype
int index=-1;
DatatypeValidator currentDV;
- while ( ++index < fValidatorsSize ) {
+ while ( ++index < fValidatorsSize ) {
currentDV = (DatatypeValidator)this.fBaseValidators.elementAt(index);
if (currentDV.compare(value1, value2) == 0) {
return 0;
@@ -208,11 +208,11 @@
newObj = new UnionDatatypeValidator();
newObj.fLocale = this.fLocale;
newObj.fBaseValidator = this.fBaseValidator;
- newObj.fBaseValidators = (Vector)this.fBaseValidators.clone();
+ newObj.fBaseValidators = (Vector)this.fBaseValidators.clone();
newObj.fPattern = this.fPattern;
newObj.fEnumeration = this.fEnumeration;
newObj.fFacetsDefined = this.fFacetsDefined;
-
+
return(newObj);
}
@@ -237,7 +237,7 @@
if ((fFacetsDefined & DatatypeValidator.FACET_ENUMERATION ) != 0) {
for (Enumeration e = enum.elements() ; e.hasMoreElements() ;) {
if (fEnumeration.contains(e.nextElement()) == false) {
- return false;
+ return false;
}
}
}
@@ -245,21 +245,21 @@
}
/**
- * validate if the content is valid against base datatype and facets (if any)
- *
+ * validate if the content is valid against base datatype and facets (if any)
+ *
* @param content A string containing the content to be validated
* @param pattern: true if pattern facet was applied, false otherwise
* @param enumeration enumeration facet
* @exception throws InvalidDatatypeException if the content is not valid
*/
- private void checkContentEnum( String content, ValidationContext state, boolean pattern, Vector enumeration ) throws InvalidDatatypeValueException
+ protected void checkContentEnum( String content, ValidationContext state, boolean pattern, Vector enumeration ) throws InvalidDatatypeValueException
{
// for UnionDatatype we have to wait till the union baseValidators are known, thus
// if the content is valid "against" ListDatatype, but pattern was applied - report an error. To do so we pass @param pattern;
// pass @param enumeration so that when base Datatype is known, we would validate enumeration/content
// against value space as well
int index = -1; //number of validators
- boolean valid=false;
+ boolean valid=false;
DatatypeValidator currentDV = null;
if (fBaseValidator !=null) { //restriction of union datatype
if ( (fFacetsDefined & DatatypeValidator.FACET_PATTERN ) != 0 ) {
@@ -282,7 +282,7 @@
return;
}
// native union type
- while ( ++index < fValidatorsSize) {
+ while ( ++index < fValidatorsSize) {
// check content against each base validator in Union
// report an error only in case content is not valid against all base datatypes.
currentDV = (DatatypeValidator)this.fBaseValidators.elementAt(index);
@@ -290,7 +290,7 @@
try {
if ( currentDV instanceof ListDatatypeValidator ) {
if ( pattern ) {
- throw new InvalidDatatypeValueException("Facet \"Pattern\" can not be applied to a list datatype" );
+ throw new InvalidDatatypeValueException("Facet \"Pattern\" can not be applied to a list datatype" );
}
((ListDatatypeValidator)currentDV).checkContentEnum( content, state, enumeration );
}
@@ -308,7 +308,7 @@
throw new InvalidDatatypeValueException("Value '"+content+ "' must be one of "+ enumeration);
}
((DatatypeValidator)currentDV).validate( content, state );
- }
+ }
}
else {
((DatatypeValidator)currentDV).validate( content, state );
@@ -321,7 +321,7 @@
}
}
if ( !valid ) {
- throw new InvalidDatatypeValueException( "Content '"+content+"' does not match any union types" );
+ throw new InvalidDatatypeValueException( "Content '"+content+"' does not match any union types" );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org