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/05/13 02:11:56 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/validators/datatype BinaryValidator.java BooleanValidator.java DatatypeValidator.java DatatypeValidatorRegistry.java DecimalValidator.java DoubleValidator.java ENTITYValidator.java FloatValidator.java IDREFValidator.java IDValidator.java NOTATIONValidator.java QNameValidator.java RecurringDurationValidator.java StringValidator.java TimeDurationValidator.java URIReferenceValidator.java
jeffreyr 00/05/12 17:11:56
Modified: java/src/org/apache/xerces/validators/datatype Tag:
schemawork BinaryValidator.java
BooleanValidator.java DatatypeValidator.java
DatatypeValidatorRegistry.java
DecimalValidator.java DoubleValidator.java
ENTITYValidator.java FloatValidator.java
IDREFValidator.java IDValidator.java
NOTATIONValidator.java QNameValidator.java
RecurringDurationValidator.java
StringValidator.java TimeDurationValidator.java
URIReferenceValidator.java
Log:
Changes to validate to support derived by list
Revision Changes Path
No revision
No revision
1.2.2.6 +88 -18 xml-xerces/java/src/org/apache/xerces/validators/datatype/BinaryValidator.java
Index: BinaryValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/BinaryValidator.java,v
retrieving revision 1.2.2.5
retrieving revision 1.2.2.6
diff -u -r1.2.2.5 -r1.2.2.6
--- BinaryValidator.java 2000/05/11 02:30:35 1.2.2.5
+++ BinaryValidator.java 2000/05/13 00:11:53 1.2.2.6
@@ -60,7 +60,10 @@
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Locale;
+import java.util.Vector;
import org.apache.xerces.validators.schema.SchemaSymbols;
+import org.apache.xerces.utils.regex.RegularExpression;
+import org.apache.xerces.utils.Base64;
/**
@@ -72,9 +75,20 @@
*/
public class BinaryValidator implements DatatypeValidator {
+ private Locale fLocale = null;
+ private String fBaseValidator = "native";
- private Locale fLocale;
-
+ private int _length = 0;
+ private int _maxLength = 0;
+ private int _minLength = 0;
+ private String _pattern = null;
+ private Vector _enumeration = null;
+ private int _facetsDefined = 0;
+ private String _encoding = SchemaSymbols.ATTVAL_BASE64;//default
+
+ private int _derivedBy = DatatypeValidator.DERIVED_BY_RESTRICTION;//default
+
+
/**
* validate that a string is a W3C binary type
*
@@ -86,28 +100,84 @@
* @exception throws InvalidDatatypeException if the content is
* not a W3C binary type
*/
- public void validate(String content, boolean list) throws InvalidDatatypeValueException {
- // just say yes
+ public void validate(String content ) throws InvalidDatatypeValueException {
+ if( _derivedBy == DatatypeValidator.DERIVED_BY_RESTRICTION ){
+ if( Base64.isBase64( content ) == false ){
+ throw new InvalidDatatypeValueException( "Value '"+content+ "' must be" +
+ "is not encoded in Base64" );
+ }
+ }else {
+ }
}
- public void validate(int contentIndex) throws InvalidDatatypeValueException {
- // just say yes
- }
- public void setFacets(Hashtable facets) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException, ConstrainException {
- for (Enumeration e = facets.keys(); e.hasMoreElements();) {
- String key = (String) e.nextElement();
- if (key.equals( SchemaSymbols.ELT_LENGTH)) {
- } else if (key.equals(SchemaSymbols.ELT_MINLENGTH)) {
- } else if (key.equals(SchemaSymbols.ELT_MAXLENGTH)) {
- } else if (key.equals(SchemaSymbols.ELT_ENCODING)) {
- } else {
- throw new IllegalFacetException();
+ public void setFacets(Hashtable facets, String derivationBy ) throws UnknownFacetException,
+ IllegalFacetException,IllegalFacetValueException, ConstrainException {
+ if ( derivationBy.equals( SchemaSymbols.ATTVAL_RESTRICTION ) ) {
+ _derivedBy = DatatypeValidator.DERIVED_BY_RESTRICTION;
+ for (Enumeration e = facets.keys(); e.hasMoreElements();) {
+ String key = (String) e.nextElement();
+ if ( key.equals(SchemaSymbols.ELT_LENGTH) ) {
+ _facetsDefined += DatatypeValidator.FACET_LENGTH;
+ String lengthValue = (String)facets.get(key);
+ try {
+ _length = Integer.parseInt( lengthValue );
+ } catch (NumberFormatException nfe) {
+ throw new IllegalFacetValueException("Length value '"+lengthValue+"' is invalid.");
+ }
+ if ( _length < 0 )
+ throw new IllegalFacetValueException("Length value '"+lengthValue+"' must be a nonNegativeInteger.");
+
+ } else if (key.equals(SchemaSymbols.ELT_MINLENGTH) ) {
+ _facetsDefined += DatatypeValidator.FACET_MINLENGTH;
+ String minLengthValue = (String)facets.get(key);
+ try {
+ _minLength = Integer.parseInt( minLengthValue );
+ } catch (NumberFormatException nfe) {
+ throw new IllegalFacetValueException("maxLength value '"+minLengthValue+"' is invalid.");
+ }
+ } else if (key.equals(SchemaSymbols.ELT_MAXLENGTH) ) {
+ _facetsDefined += DatatypeValidator.FACET_MAXLENGTH;
+ String maxLengthValue = (String)facets.get(key);
+ try {
+ _maxLength = Integer.parseInt( maxLengthValue );
+ } catch (NumberFormatException nfe) {
+ throw new IllegalFacetValueException("maxLength value '"+maxLengthValue+"' is invalid.");
+ }
+ } else if (key.equals(SchemaSymbols.ELT_PATTERN)) {
+ _facetsDefined += DatatypeValidator.FACET_PATTERN;
+ _pattern = (String)facets.get(key);
+ } else if (key.equals(SchemaSymbols.ELT_ENUMERATION)) {
+ _facetsDefined += DatatypeValidator.FACET_ENUMERATION;
+ _enumeration = (Vector)facets.get(key);
+ } else if (key.equals(SchemaSymbols.ELT_ENCODING )) {
+ _facetsDefined += DatatypeValidator.FACET_MAXINCLUSIVE;
+ _encoding = (String)facets.get(key);
+ } else {
+ throw new IllegalFacetException();
+ }
}
+ if (((_facetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 ) ) {
+ if (((_facetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 ) ) {
+ throw new ConstrainException(
+ "It is an error for both length and maxLength to be members of facets." );
+ } else if (((_facetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 ) ) {
+ throw new ConstrainException(
+ "It is an error for both length and minLength to be members of facets." );
+ }
+ }
+
+ if ( ( (_facetsDefined & ( DatatypeValidator.FACET_MINLENGTH |
+ DatatypeValidator.FACET_MAXLENGTH) ) != 0 ) ) {
+ if ( _minLength < _maxLength ) {
+ throw new ConstrainException( "Value of minLength = " + _minLength +
+ "must be greater that the value of maxLength" + _maxLength );
+ }
+ }
+ } else { //Derivation by List
+
}
- }
- public void setFacets(int facets[]) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException {
}
public void setBasetype(String base) {
1.2.2.7 +19 -10 xml-xerces/java/src/org/apache/xerces/validators/datatype/BooleanValidator.java
Index: BooleanValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/BooleanValidator.java,v
retrieving revision 1.2.2.6
retrieving revision 1.2.2.7
diff -u -r1.2.2.6 -r1.2.2.7
--- BooleanValidator.java 2000/05/11 23:23:04 1.2.2.6
+++ BooleanValidator.java 2000/05/13 00:11:53 1.2.2.7
@@ -79,6 +79,7 @@
private int _facetsDefined = 0;
private DatatypeMessageProvider fMessageProvider = new DatatypeMessageProvider();
private static final String _valueSpace[] = { "false", "true", "0", "1" };
+ private int _derivedBy = DatatypeValidator.DERIVED_BY_RESTRICTION;//default
/**
* validate that a string matches the boolean datatype
@@ -88,11 +89,13 @@
* is not valid.
*/
- public void validate(String content, boolean derivedByList) throws InvalidDatatypeValueException {
+ public void validate(String content) throws InvalidDatatypeValueException {
if ( _facetsDefined == 0 )// No Facets to validate against
return;
- if ( derivedByList == true ) {
+
+ if( _derivedBy == DatatypeValidator.DERIVED_BY_RESTRICTION ){
+
;// What does it mean?
} else {
checkContent( content );
@@ -115,18 +118,24 @@
* @exception IllegalFacetValueException
* @exception ConstrainException
*/
- public void setFacets(Hashtable facets) throws UnknownFacetException,
+ public void setFacets(Hashtable facets, String derivationBy) throws UnknownFacetException,
IllegalFacetException, IllegalFacetValueException, ConstrainException {
- for (Enumeration e = facets.keys(); e.hasMoreElements();) {
- String key = (String) e.nextElement();
+ if ( derivationBy.equals( SchemaSymbols.ATTVAL_RESTRICTION ) ) {
+ _derivedBy = DatatypeValidator.DERIVED_BY_RESTRICTION;
- if (key.equals(SchemaSymbols.ELT_PATTERN)) {
- _facetsDefined += DatatypeValidator.FACET_PATTERN;
- _pattern = (String)facets.get(key);
- } else {
- throw new IllegalFacetException();
+ for (Enumeration e = facets.keys(); e.hasMoreElements();) {
+ String key = (String) e.nextElement();
+
+ if (key.equals(SchemaSymbols.ELT_PATTERN)) {
+ _facetsDefined += DatatypeValidator.FACET_PATTERN;
+ _pattern = (String)facets.get(key);
+ } else {
+ throw new IllegalFacetException();
+ }
}
+ }else { // By List
+
}
}
1.3.2.9 +9 -5 xml-xerces/java/src/org/apache/xerces/validators/datatype/DatatypeValidator.java
Index: DatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/DatatypeValidator.java,v
retrieving revision 1.3.2.8
retrieving revision 1.3.2.9
diff -u -r1.3.2.8 -r1.3.2.9
--- DatatypeValidator.java 2000/05/11 02:30:36 1.3.2.8
+++ DatatypeValidator.java 2000/05/13 00:11:53 1.3.2.9
@@ -84,6 +84,8 @@
public static final int FACET_ENCODING = 1<<11;
public static final int FACET_DURATION = 1<<12;
public static final int FACET_PERIOD = 1<<13;
+ public static final int DERIVED_BY_RESTRICTION = 1;
+ public static final int DERIVED_BY_LIST = 1<<1;
@@ -103,7 +105,7 @@
* @exception InvalidDatatypeValueException
* @see org.apache.xerces.validators.datatype.InvalidDatatypeValueException
*/
- public void validate(String content, boolean derivedByList ) throws InvalidDatatypeValueException;
+ public void validate(String content ) throws InvalidDatatypeValueException;
/**
* set the facets for this datatype
@@ -121,11 +123,13 @@
* @exception UnknownFacetException
* @exception IllegalFacetException
* @exception IllegalFacetValueException
- * @see org.apache.xerces.validators.schema.SchemaSymbols
- * @see org.apache.xerces.validators.datatype.IllegalFacetException
- * @see org.apache.xerces.validators.datatype.IllegalFacetValueException
+ * @exception ConstrainException
+ * @see org.apache.xerces.validators.schema.SchemaSymbols
+ * @see org.apache.xerces.validators.datatype.IllegalFacetException
+ * @see org.apache.xerces.validators.datatype.IllegalFacetValueException
+ * @see org.apache.xerces.validators.datatype.ConstrainException
*/
- public void setFacets(Hashtable facets) throws UnknownFacetException,
+ public void setFacets(Hashtable facets,String derivationType ) throws UnknownFacetException,
IllegalFacetException, IllegalFacetValueException, ConstrainException;
/**
1.1.2.6 +56 -29 xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/DatatypeValidatorRegistry.java
Index: DatatypeValidatorRegistry.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/DatatypeValidatorRegistry.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- DatatypeValidatorRegistry.java 2000/05/11 02:30:36 1.1.2.5
+++ DatatypeValidatorRegistry.java 2000/05/13 00:11:53 1.1.2.6
@@ -104,128 +104,155 @@
Hashtable facets = new Hashtable();
facets.put(SchemaSymbols.ELT_PATTERN , "([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]+)(-[a-zA-Z]+)*" );
- addValidator("language", createDatatypeValidator("string", facets ));
+ addValidator("language", createDatatypeValidator("string", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION));
- addValidator("IDREFS", createDatatypeValidator( "IDREF", null ) );
+ addValidator("IDREFS", createDatatypeValidator( "IDREF", null ,
+ SchemaSymbols.ATTVAL_RESTRICTION) );
- addValidator("ENTITIES", createDatatypeValidator( "ENTITY", null ) );
+ addValidator("ENTITIES", createDatatypeValidator( "ENTITY", null ,
+ SchemaSymbols.ATTVAL_RESTRICTION) );
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_PATTERN , "\\c+" );
- addValidator("NMTOKEN", createDatatypeValidator("string", facets ));
+ addValidator("NMTOKEN", createDatatypeValidator("string", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
- addValidator("NMTOKENS", createDatatypeValidator("NMTOKEN", facets ));
+ addValidator("NMTOKENS", createDatatypeValidator("NMTOKEN", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_PATTERN , "\\i\\c*" );
- addValidator("Name", createDatatypeValidator("string", facets ));
+ addValidator("Name", createDatatypeValidator("string", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_PATTERN , "[\\i-[:]][\\c-[:]]*" );
- addValidator("NCName", createDatatypeValidator("string", facets ));
+ addValidator("NCName", createDatatypeValidator("string", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_SCALE, "0");
- addValidator("integer", createDatatypeValidator("decimal", facets ));
+ addValidator("integer", createDatatypeValidator("decimal", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "0" );
- addValidator("nonPositiveInteger", createDatatypeValidator("integer", facets ));
+ addValidator("nonPositiveInteger", createDatatypeValidator("integer", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "-1" );
- addValidator("negativeInteger", createDatatypeValidator("nonPositiveInteger", facets ));
+ addValidator("negativeInteger", createDatatypeValidator("nonPositiveInteger", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "9223372036854775807");
facets.put(SchemaSymbols.ELT_MININCLUSIVE, "-9223372036854775808");
- addValidator("long", createDatatypeValidator("integer", facets ));
+ addValidator("long", createDatatypeValidator("integer", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "2147483647");
facets.put(SchemaSymbols.ELT_MININCLUSIVE, "-2147483648");
- addValidator("int", createDatatypeValidator("long", facets ));
+ addValidator("int", createDatatypeValidator("long", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "32767");
facets.put(SchemaSymbols.ELT_MININCLUSIVE, "-32768");
- addValidator("short", createDatatypeValidator("int", facets ));
+ addValidator("short", createDatatypeValidator("int", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_MAXINCLUSIVE , "127");
facets.put(SchemaSymbols.ELT_MININCLUSIVE, "-128");
- addValidator("byte", createDatatypeValidator("short", facets ));
+ addValidator("byte", createDatatypeValidator("short", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_MININCLUSIVE, "0" );
- addValidator("nonNegativeInteger", createDatatypeValidator("integer", facets ));
+ addValidator("nonNegativeInteger", createDatatypeValidator("integer", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_MAXINCLUSIVE, "18446744073709551615" );
- addValidator("unsignedLong", createDatatypeValidator("nonNegativeInteger", facets ));
+ addValidator("unsignedLong", createDatatypeValidator("nonNegativeInteger", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_MAXINCLUSIVE, "4294967295" );
- addValidator("unsignedInt", createDatatypeValidator("unsignedLong", facets ));
+ addValidator("unsignedInt", createDatatypeValidator("unsignedLong", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_MAXINCLUSIVE, "65535" );
- addValidator("unsignedShort", createDatatypeValidator("unsignedInt", facets ));
+ addValidator("unsignedShort", createDatatypeValidator("unsignedInt", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_MAXINCLUSIVE, "255" );
- addValidator("unsignedByte", createDatatypeValidator("unsignedShort", facets ));
+ addValidator("unsignedByte", createDatatypeValidator("unsignedShort", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_DURATION, "P0Y" );
facets.put(SchemaSymbols.ELT_PERIOD, "P0Y" );
- addValidator("timeInstant", createDatatypeValidator("recurringDuration", facets ));
+ addValidator("timeInstant", createDatatypeValidator("recurringDuration", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_DURATION, "P0Y" );
facets.put(SchemaSymbols.ELT_PERIOD, "PY24H" );
- addValidator("time", createDatatypeValidator("recurringDuration", facets ));
+ addValidator("time", createDatatypeValidator("recurringDuration", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_PERIOD, "P0Y" );
- addValidator("timePeriod", createDatatypeValidator("recurringDuration", facets ));
+ addValidator("timePeriod", createDatatypeValidator("recurringDuration", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_DURATION, "PT24H" );
- addValidator("date", createDatatypeValidator("timePeriod", facets ));
+ addValidator("date", createDatatypeValidator("timePeriod", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_DURATION, "P1M" );
- addValidator("month", createDatatypeValidator("timePeriod", facets ));
+ addValidator("month", createDatatypeValidator("timePeriod", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_DURATION, "P1Y" );
- addValidator("year", createDatatypeValidator("timePeriod", facets ));
+ addValidator("year", createDatatypeValidator("timePeriod", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_DURATION, "P100Y" );
- addValidator("century", createDatatypeValidator("timePeriod", facets ));
+ addValidator("century", createDatatypeValidator("timePeriod", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
facets = new Hashtable();
facets.put(SchemaSymbols.ELT_PERIOD, "P1Y" );
facets.put(SchemaSymbols.ELT_DURATION, "PT24H" );
- addValidator("recurringDate", createDatatypeValidator("recurringDuration", facets ));
+ addValidator("recurringDate", createDatatypeValidator("recurringDuration", facets,
+ SchemaSymbols.ATTVAL_RESTRICTION ));
}
- public DatatypeValidator createDatatypeValidator(String baseTypeName, Hashtable facets ){
+ public DatatypeValidator createDatatypeValidator(String baseTypeName, Hashtable facets, String derivedBy ){
DatatypeValidator baseDatatype = getDatatypeValidator( baseTypeName );
try {
if( baseDatatype != null ) {
if( facets != null )
- baseDatatype.setFacets(facets);
+ baseDatatype.setFacets(facets, derivedBy );
baseDatatype.setBasetype( baseTypeName );
}
} catch (IllegalFacetException ex) {
1.4.2.6 +2 -2 xml-xerces/java/src/org/apache/xerces/validators/datatype/DecimalValidator.java
Index: DecimalValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/DecimalValidator.java,v
retrieving revision 1.4.2.5
retrieving revision 1.4.2.6
diff -u -r1.4.2.5 -r1.4.2.6
--- DecimalValidator.java 2000/05/11 02:30:36 1.4.2.5
+++ DecimalValidator.java 2000/05/13 00:11:53 1.4.2.6
@@ -105,7 +105,7 @@
* is not a W3C decimal type
*/
- public void validate(String content, boolean list) throws InvalidDatatypeValueException {
+ public void validate(String content) throws InvalidDatatypeValueException {
BigDecimal d = null;
try {
d = new BigDecimal(content);
@@ -168,7 +168,7 @@
return facetsAreConsistent;
}
- public void setFacets(Hashtable facets) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException {
+ public void setFacets(Hashtable facets, String derivationBy) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException {
if (fBaseValidator != null)
if (!fBaseValidator.ensureFacetsAreConsistent(facets))
throw new IllegalFacetValueException(
1.1.2.9 +13 -13 xml-xerces/java/src/org/apache/xerces/validators/datatype/DoubleValidator.java
Index: DoubleValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/DoubleValidator.java,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- DoubleValidator.java 2000/05/12 15:55:15 1.1.2.8
+++ DoubleValidator.java 2000/05/13 00:11:53 1.1.2.9
@@ -71,18 +71,18 @@
*/
public class DoubleValidator implements DatatypeValidator {
-
- private Locale fLocale = null;
- private String fBaseValidator = "native";
- private double[] _enumDoubles = null;
- private String _pattern = null;
+ private Locale fLocale = null;
+ private String fBaseValidator = "native";
+ private int _derivationBy = DatatypeValidator.DERIVED_BY_RESTRICTION;
+ private double[] _enumDoubles = null;
+ private String _pattern = null;
- private double _maxInclusive = Double.MAX_VALUE;
- private double _maxExclusive = Double.MAX_VALUE;
- private double _minInclusive = Double.MIN_VALUE;
- private double _minExclusive = Double.MIN_VALUE;
+ private double _maxInclusive = Double.MAX_VALUE;
+ private double _maxExclusive = Double.MAX_VALUE;
+ private double _minInclusive = Double.MIN_VALUE;
+ private double _minExclusive = Double.MIN_VALUE;
- private int _facetsDefined = 0;
+ private int _facetsDefined = 0;
private boolean isMaxExclusiveDefined = false;
private boolean isMaxInclusiveDefined = false;
@@ -98,9 +98,9 @@
* is not a W3C real type
*/
- public void validate(String content, boolean derivedBylist)
+ public void validate(String content)
throws InvalidDatatypeValueException {
- if( ! derivedBylist ){
+ if( _derivationBy == DatatypeValidator.DERIVED_BY_RESTRICTION ){
double d = 0.0;
try {
d = Double.valueOf(content).doubleValue();
@@ -121,7 +121,7 @@
}
}
- public void setFacets(Hashtable facets) throws UnknownFacetException,
+ public void setFacets(Hashtable facets, String derivationBy) throws UnknownFacetException,
IllegalFacetException, IllegalFacetValueException, ConstrainException {
for (Enumeration e = facets.keys(); e.hasMoreElements();) {
1.1.2.2 +2 -2 xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/ENTITYValidator.java
Index: ENTITYValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/ENTITYValidator.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- ENTITYValidator.java 2000/05/10 19:49:30 1.1.2.1
+++ ENTITYValidator.java 2000/05/13 00:11:53 1.1.2.2
@@ -85,7 +85,7 @@
* @exception InvalidDatatypeValueException
* @see org.apache.xerces.validators.datatype.InvalidDatatypeValueException
*/
- public void validate(String content, boolean derivedByList ) throws InvalidDatatypeValueException{
+ public void validate(String content ) throws InvalidDatatypeValueException{
}
/**
@@ -108,7 +108,7 @@
* @see org.apache.xerces.validators.datatype.IllegalFacetException
* @see org.apache.xerces.validators.datatype.IllegalFacetValueException
*/
- public void setFacets(Hashtable facets) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException {
+ public void setFacets(Hashtable facets, String derivedBy) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException {
}
/**
1.1.2.10 +5 -3 xml-xerces/java/src/org/apache/xerces/validators/datatype/FloatValidator.java
Index: FloatValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/FloatValidator.java,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- FloatValidator.java 2000/05/12 02:49:54 1.1.2.9
+++ FloatValidator.java 2000/05/13 00:11:53 1.1.2.10
@@ -75,6 +75,8 @@
private String fBaseValidator = "native";
private float[] _enumFloats = null;
private String _pattern = null;
+ private int _derivationBy = DatatypeValidator.DERIVED_BY_RESTRICTION;
+
private float _maxInclusive = Float.MAX_VALUE;
private float _maxExclusive = Float.MAX_VALUE;
@@ -97,9 +99,9 @@
* is not a W3C real type
*/
- public void validate(String content, boolean derivedBylist)
+ public void validate(String content)
throws InvalidDatatypeValueException {
- if( ! derivedBylist ){
+ if( _derivationBy == DatatypeValidator.DERIVED_BY_RESTRICTION ){
float f = 0;
try {
f = Float.valueOf(content).floatValue();
@@ -120,7 +122,7 @@
}
}
- public void setFacets(Hashtable facets) throws UnknownFacetException,
+ public void setFacets(Hashtable facets, String derivationBy) throws UnknownFacetException,
IllegalFacetException, IllegalFacetValueException, ConstrainException {
for (Enumeration e = facets.keys(); e.hasMoreElements();) {
1.1.2.2 +2 -2 xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/IDREFValidator.java
Index: IDREFValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/IDREFValidator.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- IDREFValidator.java 2000/05/10 19:49:31 1.1.2.1
+++ IDREFValidator.java 2000/05/13 00:11:53 1.1.2.2
@@ -85,7 +85,7 @@
* @exception InvalidDatatypeValueException
* @see org.apache.xerces.validators.datatype.InvalidDatatypeValueException
*/
- public void validate(String content, boolean derivedByList ) throws InvalidDatatypeValueException{
+ public void validate(String content ) throws InvalidDatatypeValueException{
}
/**
@@ -108,7 +108,7 @@
* @see org.apache.xerces.validators.datatype.IllegalFacetException
* @see org.apache.xerces.validators.datatype.IllegalFacetValueException
*/
- public void setFacets(Hashtable facets) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException {
+ public void setFacets(Hashtable facets, String derivedBy) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException {
}
/**
1.1.2.2 +2 -2 xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/IDValidator.java
Index: IDValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/IDValidator.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- IDValidator.java 2000/05/10 19:49:31 1.1.2.1
+++ IDValidator.java 2000/05/13 00:11:54 1.1.2.2
@@ -85,7 +85,7 @@
* @exception InvalidDatatypeValueException
* @see org.apache.xerces.validators.datatype.InvalidDatatypeValueException
*/
- public void validate(String content, boolean derivedByList ) throws InvalidDatatypeValueException{
+ public void validate(String content ) throws InvalidDatatypeValueException{
}
/**
@@ -108,7 +108,7 @@
* @see org.apache.xerces.validators.datatype.IllegalFacetException
* @see org.apache.xerces.validators.datatype.IllegalFacetValueException
*/
- public void setFacets(Hashtable facets) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException{
+ public void setFacets(Hashtable facets, String derivedBy ) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException{
}
/**
1.1.2.2 +2 -2 xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/NOTATIONValidator.java
Index: NOTATIONValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/NOTATIONValidator.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- NOTATIONValidator.java 2000/05/10 19:49:32 1.1.2.1
+++ NOTATIONValidator.java 2000/05/13 00:11:54 1.1.2.2
@@ -85,7 +85,7 @@
* @exception InvalidDatatypeValueException
* @see org.apache.xerces.validators.datatype.InvalidDatatypeValueException
*/
- public void validate(String content, boolean derivedByList ) throws InvalidDatatypeValueException{
+ public void validate(String content ) throws InvalidDatatypeValueException{
}
/**
@@ -108,7 +108,7 @@
* @see org.apache.xerces.validators.datatype.IllegalFacetException
* @see org.apache.xerces.validators.datatype.IllegalFacetValueException
*/
- public void setFacets(Hashtable facets) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException {
+ public void setFacets(Hashtable facets, String derivedBy) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException {
}
/**
1.1.2.3 +233 -49 xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/QNameValidator.java
Index: QNameValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/QNameValidator.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- QNameValidator.java 2000/05/11 02:30:36 1.1.2.2
+++ QNameValidator.java 2000/05/13 00:11:54 1.1.2.3
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -60,66 +60,250 @@
import java.util.Vector;
import java.util.Enumeration;
import java.util.Locale;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
import java.text.ParseException;
+import java.util.StringTokenizer;
+import java.util.NoSuchElementException;
import org.apache.xerces.validators.schema.SchemaSymbols;
+import org.apache.xerces.utils.regex.RegularExpression;
+/**
+ * QName Validator validates a QName type.
+ * QName represents XML qualified names. The value
+ * space of QName is the set of tuples
+ * {namespace name, local part}, where namespace
+ * name is a uriReference and local part is an NCName.
+ * The lexical space of QName is the set of strings
+ * that match the QName production of [Namespaces in
+ * XML].
+ *
+ * @author Jeffrey Rodriguez
+ * @version $Id: QNameValidator.java,v 1.1.2.3 2000/05/13 00:11:54 jeffreyr Exp $
+ */
public class QNameValidator implements DatatypeValidator {
+ private Locale fLocale = null;
+ private String fBaseValidator = "native";
+
+ private int _length = 0;
+ private int _maxLength = 0;
+ private int _minLength = 0;
+ private String _pattern = null;
+ private Vector _enumeration = null;
+ private String _maxInclusive = null;
+ private String _maxExclusive = null;
+ private String _minInclusive = null;
+ private String _minExclusive = null;
+ private int _facetsDefined = 0;
+
+ private int _derivedBy = DatatypeValidator.DERIVED_BY_RESTRICTION;//default
+
+ private boolean isMaxExclusiveDefined = false;
+ private boolean isMaxInclusiveDefined = false;
+ private boolean isMinExclusiveDefined = false;
+ private boolean isMinInclusiveDefined = false;
- /**
- *
- * validate that a string matches a datatype
- *
- * validate returns true or false depending on whether the string content is an
- * instance of the data type represented by this validator.
- *
- * @param content A string containing the content to be validated
- * @exception throws InvalidDatatypeException if the content is
- * invalid according to the rules for the validators
- * @exception InvalidDatatypeValueException
- */
- public void validate(String content, boolean list) throws InvalidDatatypeValueException{
- }
-
- /**
- * set the facets for this datatype
- *
- * setFacets is responsible for ensuring that the supplied facets do not contradict each
- * other
- *
- * @param facets A hashtable where facet names are keys and facet values are stored
- * in the hashtable. Usually facet values are strings, except for the
- * enumeration facet. The value for this facet is a Vector of strings, one
- * per enumeration value
- *
- * @exception throws UnknownFacetException
- * @exception throws IllegalFacetException
- * @exception throws IllegalFacetValueException
- */
- public void setFacets(Hashtable facets) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException, ConstrainException {
- }
-
- /**
- * set the base type for this datatype
- *
- * @param base the validator for this type's base type
- *
- */
- public void setBasetype(String base) {
+/**
+* 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
+* not a W3C string type
+* @exception InvalidDatatypeValueException
+*/
+ public void validate(String content) throws InvalidDatatypeValueException
+ {
+ if ( _facetsDefined == 0 )// No Facets to validate against
+ return;
+
+ StringTokenizer parsedList = null;
+
+ if( _derivedBy == DatatypeValidator.DERIVED_BY_LIST ){
+ parsedList = new StringTokenizer( content );
+ try {
+ while ( parsedList.hasMoreTokens() ) {
+ checkContentList( parsedList.nextToken() );
+ }
+ } catch ( NoSuchElementException e ) {
+ e.printStackTrace();
+ }
+ } else {
+ checkContent( content );
+ }
}
+
+ public void setFacets(Hashtable facets, String derivationBy) throws UnknownFacetException,
+ IllegalFacetException, IllegalFacetValueException, ConstrainException
+ {
+ if( derivationBy.equals( SchemaSymbols.ATTVAL_EXTENSION) == true){
+ for (Enumeration e = facets.keys(); e.hasMoreElements();) {
+ String key = (String) e.nextElement();
+
+ if ( key.equals(SchemaSymbols.ELT_LENGTH) ) {
+ _facetsDefined += DatatypeValidator.FACET_LENGTH;
+ String lengthValue = (String)facets.get(key);
+ try {
+ _length = Integer.parseInt( lengthValue );
+ } catch (NumberFormatException nfe) {
+ throw new IllegalFacetValueException("Length value '"+lengthValue+"' is invalid.");
+ }
+ if ( _length < 0 )
+ throw new IllegalFacetValueException("Length value '"+lengthValue+"' must be a nonNegativeInteger.");
+
+ } else if (key.equals(SchemaSymbols.ELT_MINLENGTH) ) {
+ _facetsDefined += DatatypeValidator.FACET_MINLENGTH;
+ String minLengthValue = (String)facets.get(key);
+ try {
+ _minLength = Integer.parseInt( minLengthValue );
+ } catch (NumberFormatException nfe) {
+ throw new IllegalFacetValueException("maxLength value '"+minLengthValue+"' is invalid.");
+ }
+ } else if (key.equals(SchemaSymbols.ELT_MAXLENGTH) ) {
+ _facetsDefined += DatatypeValidator.FACET_MAXLENGTH;
+ String maxLengthValue = (String)facets.get(key);
+ try {
+ _maxLength = Integer.parseInt( maxLengthValue );
+ } catch (NumberFormatException nfe) {
+ throw new IllegalFacetValueException("maxLength value '"+maxLengthValue+"' is invalid.");
+ }
+ } else if (key.equals(SchemaSymbols.ELT_PATTERN)) {
+ _facetsDefined += DatatypeValidator.FACET_PATTERN;
+ _pattern = (String)facets.get(key);
+ } else if (key.equals(SchemaSymbols.ELT_ENUMERATION)) {
+ _facetsDefined += DatatypeValidator.FACET_ENUMERATION;
+ _enumeration = (Vector)facets.get(key);
+ } else if (key.equals(SchemaSymbols.ELT_MAXINCLUSIVE)) {
+ _facetsDefined += DatatypeValidator.FACET_MAXINCLUSIVE;
+ _maxInclusive = (String)facets.get(key);
+ } else if (key.equals(SchemaSymbols.ELT_MAXEXCLUSIVE)) {
+ _facetsDefined += DatatypeValidator.FACET_MAXEXCLUSIVE;
+ _maxExclusive = (String)facets.get(key);
+ } else if (key.equals(SchemaSymbols.ELT_MININCLUSIVE)) {
+ _facetsDefined += DatatypeValidator.FACET_MININCLUSIVE;
+ _minInclusive = (String)facets.get(key);
+ } else if (key.equals(SchemaSymbols.ELT_MINEXCLUSIVE)) {
+ _facetsDefined += DatatypeValidator.FACET_MININCLUSIVE;
+ _minExclusive = (String)facets.get(key);
+ } else {
+ throw new IllegalFacetException();
+ }
+ }
+
+ if (((_facetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 ) ) {
+ if (((_facetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 ) ) {
+ throw new ConstrainException(
+ "It is an error for both length and maxLength to be members of facets." );
+ } else if (((_facetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 ) ) {
+ throw new ConstrainException(
+ "It is an error for both length and minLength to be members of facets." );
+ }
+ }
+
+ if ( ( (_facetsDefined & ( DatatypeValidator.FACET_MINLENGTH |
+ DatatypeValidator.FACET_MAXLENGTH) ) != 0 ) ) {
+ if ( _minLength < _maxLength ) {
+ throw new ConstrainException( "Value of minLength = " + _minLength +
+ "must be greater that the value of maxLength" + _maxLength );
+ }
+ }
+
+ isMaxExclusiveDefined = ((_facetsDefined &
+ DatatypeValidator.FACET_MAXEXCLUSIVE ) != 0 )?true:false;
+ isMaxInclusiveDefined = ((_facetsDefined &
+ DatatypeValidator.FACET_MAXINCLUSIVE ) != 0 )?true:false;
+ isMinExclusiveDefined = ((_facetsDefined &
+ DatatypeValidator.FACET_MINEXCLUSIVE ) != 0 )?true:false;
+ isMinInclusiveDefined = ((_facetsDefined &
+ DatatypeValidator.FACET_MININCLUSIVE ) != 0 )?true:false;
+
+ if ( isMaxExclusiveDefined && isMaxInclusiveDefined ) {
+ throw new ConstrainException(
+ "It is an error for both maxInclusive and maxExclusive to be specified for the same datatype." );
+ }
+ if ( isMinExclusiveDefined && isMinInclusiveDefined ) {
+ throw new ConstrainException(
+ "It is an error for both minInclusive and minExclusive to be specified for the same datatype." );
+ }
+ } else { //DerivationByList
- /**
- * set the locate to be used for error messages
- */
+ }
+ }
+
+ public void setBasetype( String base) {
+ fBaseValidator = base;
+ }
+
+/**
+* set the locate to be used for error messages
+*/
public void setLocale(Locale locale) {
+ fLocale = locale;
+ }
+
+ public int compare( DatatypeValidator o1, DatatypeValidator o2){
+ return 0;
}
- // REVISIT
+ private void checkContent( String content )throws InvalidDatatypeValueException
+ {
+ if ( (_facetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0 ) {
+ if ( content.length() > _maxLength ) {
+ throw new InvalidDatatypeValueException("Value '"+content+
+ "' with length '"+content.length()+
+ "' exceeds maximum length of "+_maxLength+".");
+ }
+ }
+ if ( (_facetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0 ) {
+ if ( _enumeration.contains( content ) == false )
+ throw new InvalidDatatypeValueException("Value '"+content+"' must be one of "+_enumeration);
+ }
- public int compare( DatatypeValidator o1, DatatypeValidator o2) {
- return -1;
+ if ( isMaxExclusiveDefined == true ) {
+ int comparisonResult;
+ comparisonResult = compare( content, _maxExclusive );
+ if ( comparisonResult > 0 ) {
+ throw new InvalidDatatypeValueException( "Value '"+content+ "' must be" +
+ "lexicographically less than" + _maxExclusive );
+
+ }
+
+ }
+ if ( isMaxInclusiveDefined == true ) {
+ int comparisonResult;
+ comparisonResult = compare( content, _maxInclusive );
+ if ( comparisonResult >= 0 )
+ throw new InvalidDatatypeValueException( "Value '"+content+ "' must be" +
+ "lexicographically less or equal than" + _maxInclusive );
+ }
+
+ if ( isMinExclusiveDefined == true ) {
+ int comparisonResult;
+ comparisonResult = compare( content, _minExclusive );
+ if ( comparisonResult < 0 )
+ throw new InvalidDatatypeValueException( "Value '"+content+ "' must be" +
+ "lexicographically greater than" + _minExclusive );
+ }
+ if ( isMinInclusiveDefined == true ) {
+ int comparisonResult;
+ comparisonResult = compare( content, _minInclusive );
+ if ( comparisonResult <= 0 )
+ throw new InvalidDatatypeValueException( "Value '"+content+ "' must be" +
+ "lexicographically greater or equal than" + _minInclusive );
+ }
+
+ if ( (_facetsDefined & DatatypeValidator.FACET_PATTERN ) != 0 ) {
+ RegularExpression regex = new RegularExpression(_pattern, "X" );
+ if ( regex.matches( content) == false )
+ throw new InvalidDatatypeValueException("Value'"+content+
+ "does not match regular expression facet" + _pattern );
+ }
+ }
+ private void checkContentList( String content )throws InvalidDatatypeValueException
+ {
+//Revisit
+ }
+ private int compare( String content, String facetValue ){
+ return -1;
}
}
1.1.2.3 +2 -2 xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/RecurringDurationValidator.java
Index: RecurringDurationValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/RecurringDurationValidator.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- RecurringDurationValidator.java 2000/05/11 02:30:36 1.1.2.2
+++ RecurringDurationValidator.java 2000/05/13 00:11:54 1.1.2.3
@@ -79,7 +79,7 @@
* invalid according to the rules for the validators
* @exception InvalidDatatypeValueException
*/
- public void validate(String content, boolean list) throws InvalidDatatypeValueException{
+ public void validate(String content) throws InvalidDatatypeValueException{
}
/**
@@ -97,7 +97,7 @@
* @exception throws IllegalFacetException
* @exception throws IllegalFacetValueException
*/
- public void setFacets(Hashtable facets) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException, ConstrainException {
+ public void setFacets(Hashtable facets, String derivedBy ) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException, ConstrainException {
}
/**
1.5.2.13 +120 -114 xml-xerces/java/src/org/apache/xerces/validators/datatype/StringValidator.java
Index: StringValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/StringValidator.java,v
retrieving revision 1.5.2.12
retrieving revision 1.5.2.13
diff -u -r1.5.2.12 -r1.5.2.13
--- StringValidator.java 2000/05/11 23:23:04 1.5.2.12
+++ StringValidator.java 2000/05/13 00:11:54 1.5.2.13
@@ -88,6 +88,7 @@
private String _minInclusive = null;
private String _minExclusive = null;
private int _facetsDefined = 0;
+ private int _derivedBy = DatatypeValidator.DERIVED_BY_RESTRICTION;//default
private boolean isMaxExclusiveDefined = false;
private boolean isMaxInclusiveDefined = false;
@@ -103,13 +104,14 @@
* not a W3C string type
* @exception InvalidDatatypeValueException
*/
- public void validate(String content, boolean derivedByList) throws InvalidDatatypeValueException
+ public void validate(String content) throws InvalidDatatypeValueException
{
if ( _facetsDefined == 0 )// No Facets to validate against
return;
StringTokenizer parsedList = null;
- if ( derivedByList == true ) {
+
+ if( _derivedBy == DatatypeValidator.DERIVED_BY_RESTRICTION ){
parsedList = new StringTokenizer( content );
try {
while ( parsedList.hasMoreTokens() ) {
@@ -124,99 +126,103 @@
}
- public void setFacets(Hashtable facets) throws UnknownFacetException,
+ public void setFacets(Hashtable facets, String derivationBy) throws UnknownFacetException,
IllegalFacetException, IllegalFacetValueException, ConstrainException
{
- for (Enumeration e = facets.keys(); e.hasMoreElements();) {
- String key = (String) e.nextElement();
-
- if ( key.equals(SchemaSymbols.ELT_LENGTH) ) {
- _facetsDefined += DatatypeValidator.FACET_LENGTH;
- String lengthValue = (String)facets.get(key);
- try {
- _length = Integer.parseInt( lengthValue );
- } catch (NumberFormatException nfe) {
- throw new IllegalFacetValueException("Length value '"+lengthValue+"' is invalid.");
+ if( derivationBy.equals( SchemaSymbols.ATTVAL_RESTRICTION )){
+ for (Enumeration e = facets.keys(); e.hasMoreElements();) {
+ String key = (String) e.nextElement();
+
+ if ( key.equals(SchemaSymbols.ELT_LENGTH) ) {
+ _facetsDefined += DatatypeValidator.FACET_LENGTH;
+ String lengthValue = (String)facets.get(key);
+ try {
+ _length = Integer.parseInt( lengthValue );
+ } catch (NumberFormatException nfe) {
+ throw new IllegalFacetValueException("Length value '"+lengthValue+"' is invalid.");
+ }
+ if ( _length < 0 )
+ throw new IllegalFacetValueException("Length value '"+lengthValue+"' must be a nonNegativeInteger.");
+
+ } else if (key.equals(SchemaSymbols.ELT_MINLENGTH) ) {
+ _facetsDefined += DatatypeValidator.FACET_MINLENGTH;
+ String minLengthValue = (String)facets.get(key);
+ try {
+ _minLength = Integer.parseInt( minLengthValue );
+ } catch (NumberFormatException nfe) {
+ throw new IllegalFacetValueException("maxLength value '"+minLengthValue+"' is invalid.");
+ }
+ } else if (key.equals(SchemaSymbols.ELT_MAXLENGTH) ) {
+ _facetsDefined += DatatypeValidator.FACET_MAXLENGTH;
+ String maxLengthValue = (String)facets.get(key);
+ try {
+ _maxLength = Integer.parseInt( maxLengthValue );
+ } catch (NumberFormatException nfe) {
+ throw new IllegalFacetValueException("maxLength value '"+maxLengthValue+"' is invalid.");
+ }
+ } else if (key.equals(SchemaSymbols.ELT_PATTERN)) {
+ _facetsDefined += DatatypeValidator.FACET_PATTERN;
+ _pattern = (String)facets.get(key);
+ } else if (key.equals(SchemaSymbols.ELT_ENUMERATION)) {
+ _facetsDefined += DatatypeValidator.FACET_ENUMERATION;
+ _enumeration = (Vector)facets.get(key);
+ } else if (key.equals(SchemaSymbols.ELT_MAXINCLUSIVE)) {
+ _facetsDefined += DatatypeValidator.FACET_MAXINCLUSIVE;
+ _maxInclusive = (String)facets.get(key);
+ } else if (key.equals(SchemaSymbols.ELT_MAXEXCLUSIVE)) {
+ _facetsDefined += DatatypeValidator.FACET_MAXEXCLUSIVE;
+ _maxExclusive = (String)facets.get(key);
+ } else if (key.equals(SchemaSymbols.ELT_MININCLUSIVE)) {
+ _facetsDefined += DatatypeValidator.FACET_MININCLUSIVE;
+ _minInclusive = (String)facets.get(key);
+ } else if (key.equals(SchemaSymbols.ELT_MINEXCLUSIVE)) {
+ _facetsDefined += DatatypeValidator.FACET_MININCLUSIVE;
+ _minExclusive = (String)facets.get(key);
+ } else {
+ throw new IllegalFacetException();
}
- if( _length < 0 )
- throw new IllegalFacetValueException("Length value '"+lengthValue+"' must be a nonNegativeInteger.");
+ }
- } else if (key.equals(SchemaSymbols.ELT_MINLENGTH) ) {
- _facetsDefined += DatatypeValidator.FACET_MINLENGTH;
- String minLengthValue = (String)facets.get(key);
- try {
- _minLength = Integer.parseInt( minLengthValue );
- } catch (NumberFormatException nfe) {
- throw new IllegalFacetValueException("maxLength value '"+minLengthValue+"' is invalid.");
+ if (((_facetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 ) ) {
+ if (((_facetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 ) ) {
+ throw new ConstrainException(
+ "It is an error for both length and maxLength to be members of facets." );
+ } else if (((_facetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 ) ) {
+ throw new ConstrainException(
+ "It is an error for both length and minLength to be members of facets." );
}
- } else if (key.equals(SchemaSymbols.ELT_MAXLENGTH) ) {
- _facetsDefined += DatatypeValidator.FACET_MAXLENGTH;
- String maxLengthValue = (String)facets.get(key);
- try {
- _maxLength = Integer.parseInt( maxLengthValue );
- } catch (NumberFormatException nfe) {
- throw new IllegalFacetValueException("maxLength value '"+maxLengthValue+"' is invalid.");
+ }
+
+ if ( ( (_facetsDefined & ( DatatypeValidator.FACET_MINLENGTH |
+ DatatypeValidator.FACET_MAXLENGTH) ) != 0 ) ) {
+ if ( _minLength < _maxLength ) {
+ throw new ConstrainException( "Value of minLength = " + _minLength +
+ "must be greater that the value of maxLength" + _maxLength );
}
- } else if (key.equals(SchemaSymbols.ELT_PATTERN)) {
- _facetsDefined += DatatypeValidator.FACET_PATTERN;
- _pattern = (String)facets.get(key);
- } else if (key.equals(SchemaSymbols.ELT_ENUMERATION)) {
- _facetsDefined += DatatypeValidator.FACET_ENUMERATION;
- _enumeration = (Vector)facets.get(key);
- } else if (key.equals(SchemaSymbols.ELT_MAXINCLUSIVE)) {
- _facetsDefined += DatatypeValidator.FACET_MAXINCLUSIVE;
- _maxInclusive = (String)facets.get(key);
- } else if (key.equals(SchemaSymbols.ELT_MAXEXCLUSIVE)) {
- _facetsDefined += DatatypeValidator.FACET_MAXEXCLUSIVE;
- _maxExclusive = (String)facets.get(key);
- } else if (key.equals(SchemaSymbols.ELT_MININCLUSIVE)) {
- _facetsDefined += DatatypeValidator.FACET_MININCLUSIVE;
- _minInclusive = (String)facets.get(key);
- } else if (key.equals(SchemaSymbols.ELT_MINEXCLUSIVE)) {
- _facetsDefined += DatatypeValidator.FACET_MININCLUSIVE;
- _minExclusive = (String)facets.get(key);
- } else {
- throw new IllegalFacetException();
}
- }
- if(((_facetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 ) ) {
- if(((_facetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 ) ){
- throw new ConstrainException(
- "It is an error for both length and maxLength to be members of facets." );
- }else if(((_facetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 ) ){
- throw new ConstrainException(
- "It is an error for both length and minLength to be members of facets." );
- }
- }
-
- if( ( (_facetsDefined & ( DatatypeValidator.FACET_MINLENGTH |
- DatatypeValidator.FACET_MAXLENGTH) ) != 0 ) )
- {
- if( _minLength < _maxLength )
- {
- throw new ConstrainException( "Value of minLength = " + _minLength +
- "must be greater that the value of maxLength" + _maxLength );
+ isMaxExclusiveDefined = ((_facetsDefined &
+ DatatypeValidator.FACET_MAXEXCLUSIVE ) != 0 )?true:false;
+ isMaxInclusiveDefined = ((_facetsDefined &
+ DatatypeValidator.FACET_MAXINCLUSIVE ) != 0 )?true:false;
+ isMinExclusiveDefined = ((_facetsDefined &
+ DatatypeValidator.FACET_MINEXCLUSIVE ) != 0 )?true:false;
+ isMinInclusiveDefined = ((_facetsDefined &
+ DatatypeValidator.FACET_MININCLUSIVE ) != 0 )?true:false;
+
+ if ( isMaxExclusiveDefined && isMaxInclusiveDefined ) {
+ throw new ConstrainException(
+ "It is an error for both maxInclusive and maxExclusive to be specified for the same datatype." );
}
- }
+ if ( isMinExclusiveDefined && isMinInclusiveDefined ) {
+ throw new ConstrainException(
+ "It is an error for both minInclusive and minExclusive to be specified for the same datatype." );
+ }
+ } else { //derived by list
- isMaxExclusiveDefined = ((_facetsDefined &
- DatatypeValidator.FACET_MAXEXCLUSIVE ) != 0 )?true:false;
- isMaxInclusiveDefined = ((_facetsDefined &
- DatatypeValidator.FACET_MAXINCLUSIVE ) != 0 )?true:false;
- isMinExclusiveDefined = ((_facetsDefined &
- DatatypeValidator.FACET_MINEXCLUSIVE ) != 0 )?true:false;
- isMinInclusiveDefined = ((_facetsDefined &
- DatatypeValidator.FACET_MININCLUSIVE ) != 0 )?true:false;
-
- if( isMaxExclusiveDefined && isMaxInclusiveDefined ) {
- throw new ConstrainException(
- "It is an error for both maxInclusive and maxExclusive to be specified for the same datatype." );
- }
- if( isMinExclusiveDefined && isMinInclusiveDefined ) {
- throw new ConstrainException(
- "It is an error for both minInclusive and minExclusive to be specified for the same datatype." );
- }
+
+
+ }
}
public void setBasetype( String base) {
@@ -248,50 +254,50 @@
throw new InvalidDatatypeValueException("Value '"+content+"' must be one of "+_enumeration);
}
- if( isMaxExclusiveDefined == true ){
+ if ( isMaxExclusiveDefined == true ) {
int comparisonResult;
comparisonResult = compare( content, _maxExclusive );
- if( comparisonResult > 0 ){
+ if ( comparisonResult > 0 ) {
throw new InvalidDatatypeValueException( "Value '"+content+ "' must be" +
- "lexicographically less than" + _maxExclusive );
-
+ "lexicographically less than" + _maxExclusive );
+
}
-
+
}
- if( isMaxInclusiveDefined == true ){
- int comparisonResult;
- comparisonResult = compare( content, _maxInclusive );
- if( comparisonResult >= 0 )
- throw new InvalidDatatypeValueException( "Value '"+content+ "' must be" +
- "lexicographically less or equal than" + _maxInclusive );
- }
-
- if( isMinExclusiveDefined == true ){
- int comparisonResult;
- comparisonResult = compare( content, _minExclusive );
- if( comparisonResult < 0 )
- throw new InvalidDatatypeValueException( "Value '"+content+ "' must be" +
- "lexicographically greater than" + _minExclusive );
- }
- if( isMinInclusiveDefined == true ){
+ if ( isMaxInclusiveDefined == true ) {
int comparisonResult;
+ comparisonResult = compare( content, _maxInclusive );
+ if ( comparisonResult >= 0 )
+ throw new InvalidDatatypeValueException( "Value '"+content+ "' must be" +
+ "lexicographically less or equal than" + _maxInclusive );
+ }
+
+ if ( isMinExclusiveDefined == true ) {
+ int comparisonResult;
+ comparisonResult = compare( content, _minExclusive );
+ if ( comparisonResult < 0 )
+ throw new InvalidDatatypeValueException( "Value '"+content+ "' must be" +
+ "lexicographically greater than" + _minExclusive );
+ }
+ if ( isMinInclusiveDefined == true ) {
+ int comparisonResult;
comparisonResult = compare( content, _minInclusive );
- if( comparisonResult <= 0 )
- throw new InvalidDatatypeValueException( "Value '"+content+ "' must be" +
- "lexicographically greater or equal than" + _minInclusive );
- }
+ if ( comparisonResult <= 0 )
+ throw new InvalidDatatypeValueException( "Value '"+content+ "' must be" +
+ "lexicographically greater or equal than" + _minInclusive );
+ }
- if( (_facetsDefined & DatatypeValidator.FACET_PATTERN ) != 0 ) {
+ if ( (_facetsDefined & DatatypeValidator.FACET_PATTERN ) != 0 ) {
RegularExpression regex = new RegularExpression(_pattern, "X" );
- if( regex.matches( content) == false )
+ if ( regex.matches( content) == false )
throw new InvalidDatatypeValueException("Value'"+content+
- "does not match regular expression facet" + _pattern );
+ "does not match regular expression facet" + _pattern );
}
}
private void checkContentList( String content )throws InvalidDatatypeValueException
{
- //Revisit
+ //Revisit
}
private int compare( String content, String facetValue ){
Locale loc = Locale.getDefault();
1.1.2.7 +2 -2 xml-xerces/java/src/org/apache/xerces/validators/datatype/TimeDurationValidator.java
Index: TimeDurationValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/TimeDurationValidator.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- TimeDurationValidator.java 2000/05/11 02:30:38 1.1.2.6
+++ TimeDurationValidator.java 2000/05/13 00:11:54 1.1.2.7
@@ -89,7 +89,7 @@
* invalid according to the rules for the validators
* @exception InvalidDatatypeValueException
*/
- public void validate(String content, boolean list) throws InvalidDatatypeValueException{
+ public void validate(String content) throws InvalidDatatypeValueException{
}
/**
@@ -107,7 +107,7 @@
* @exception throws IllegalFacetException
* @exception throws IllegalFacetValueException
*/
- public void setFacets(Hashtable facets) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException, ConstrainException {
+ public void setFacets(Hashtable facets,String derivationBy ) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException, ConstrainException {
}
/**
1.1.2.3 +4 -18 xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/URIReferenceValidator.java
Index: URIReferenceValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/URIReferenceValidator.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- URIReferenceValidator.java 2000/05/11 02:30:38 1.1.2.2
+++ URIReferenceValidator.java 2000/05/13 00:11:54 1.1.2.3
@@ -67,6 +67,7 @@
* according to RFC 2396
*
* @author Ted Leung
+ * @author Jeffrey Rodriguez
* @version Revision: %M% %I% %W% %Q%
*/
@@ -75,28 +76,13 @@
private Locale fLocale = null;
/**
- * validate that a string is a W3C uri type
- *
- * validate returns true or false depending on whether the string content is an
- * instance of the W3C uri datatype
- *
- * @param content A string containing the content to be validated
- *
- * @exception throws InvalidDatatypeException if the content is
- * not a W3C uri type
- */
+ */
- public void validate(String content, boolean list) throws InvalidDatatypeValueException {
+ public void validate(String content) throws InvalidDatatypeValueException {
// just say yes
}
- public void validate(int contentIndex) throws InvalidDatatypeValueException {
- }
-
- public void setFacets(Hashtable facets) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException {
- }
-
- public void setFacets(int facets[]) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException, ConstrainException {
+ public void setFacets(Hashtable facets, String derivationBy) throws UnknownFacetException, IllegalFacetException, IllegalFacetValueException {
}
public void setBasetype(String base) {