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/11/28 18:49:01 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/validation ValidationState.java ValidationContext.java
sandygao 01/11/28 09:49:01
Modified: java/src/org/apache/xerces/impl/validation
ValidationState.java ValidationContext.java
Log:
The DV implementation needs to know whether facet checking
or id/idref/entity checking is necessary when validate() method is called
on a DV/simpleType.
Revision Changes Path
1.5 +44 -11 xml-xerces/java/src/org/apache/xerces/impl/validation/ValidationState.java
Index: ValidationState.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/validation/ValidationState.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ValidationState.java 2001/10/19 17:21:55 1.4
+++ ValidationState.java 2001/11/28 17:49:00 1.5
@@ -63,24 +63,41 @@
import java.util.Hashtable;
import java.util.Enumeration;
+/**
+ * Implementation of ValidationContext inteface. Used to establish an
+ * environment for simple type validation.
+ *
+ * @author Elena Litani, IBM
+ * @version $Id: ValidationState.java,v 1.5 2001/11/28 17:49:00 sandygao Exp $
+ */
+public class ValidationState implements ValidationContext {
-public class ValidationState implements ValidationContext {
-
- //
+ //
// private data
//
+ private boolean fExtraChecking = true;
+ private boolean fFacetChecking = true;
+
private EntityState fEntityState = null;
private NamespaceSupport fNamespaceSupport = null;
private SymbolTable fSymbolTable = null;
+ //REVISIT: Should replace with a lighter structure.
private final Hashtable fIdTable = new Hashtable();
private final Hashtable fIdRefTable = new Hashtable();
-
private final static Object fNullValue = new Object();
//
// public methods
//
+ public void setExtraChecking(boolean newValue) {
+ fExtraChecking = newValue;
+ }
+
+ public void setFacetChecking(boolean newValue) {
+ fFacetChecking = newValue;
+ }
+
public void setEntityState(EntityState state) {
fEntityState = state;
}
@@ -96,9 +113,10 @@
public boolean checkIDRefID () {
Enumeration en = fIdRefTable.keys();
+ String key;
while (en.hasMoreElements()) {
- String key = (String)en.nextElement();
- if (fIdTable == null || !fIdTable.containsKey(key)) {
+ key = (String)en.nextElement();
+ if (!fIdTable.containsKey(key)) {
return false;
}
}
@@ -106,6 +124,8 @@
}
public void reset () {
+ fExtraChecking = true;
+ fFacetChecking = true;
fIdTable.clear();
fIdRefTable.clear();
fEntityState = null;
@@ -116,6 +136,16 @@
// implementation of ValidationContext methods
//
+ // whether to do extra id/idref/entity checking
+ public boolean needExtraChecking() {
+ return fExtraChecking;
+ }
+
+ // whether to validate against facets
+ public boolean needFacetChecking() {
+ return fFacetChecking;
+ }
+
// entity
public boolean isEntityDeclared (String name) {
if (fEntityState !=null) {
@@ -134,21 +164,24 @@
public boolean isIdDeclared(String name) {
return fIdTable.containsKey(name);
}
- public void addId(String name) {
+ public void addId(String name) {
fIdTable.put(name, fNullValue);
}
// idref
public void addIdRef(String name) {
- if (fIdRefTable.containsKey(name)) {
- return;
- }
fIdRefTable.put(name, fNullValue);
}
// get symbols
public String getSymbol (String symbol) {
- return fSymbolTable.addSymbol(symbol);
+ if (fSymbolTable != null)
+ return fSymbolTable.addSymbol(symbol);
+ // if there is no symbol table, we return java-internalized string,
+ // because symbol table strings are also java-internalzied.
+ // this guarantees that the returned string from this method can be
+ // compared by reference with other symbol table string. -SG
+ return symbol.intern();
}
// qname, notation
public String getURI(String prefix) {
1.3 +12 -7 xml-xerces/java/src/org/apache/xerces/impl/validation/ValidationContext.java
Index: ValidationContext.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/validation/ValidationContext.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ValidationContext.java 2001/10/18 21:14:31 1.2
+++ ValidationContext.java 2001/11/28 17:49:01 1.3
@@ -54,28 +54,33 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-
+
package org.apache.xerces.impl.validation;
/**
- * ValidationContext has all the information required for the
+ * ValidationContext has all the information required for the
* validation of: id, idref, entity, notation, qname
- *
+ *
* @author Sandy Gao, IBM
*/
public interface ValidationContext {
-
+ // whether to validate against facets
+ public boolean needFacetChecking();
+
+ // whether to do extra id/idref/entity checking
+ public boolean needExtraChecking();
+
// entity
public boolean isEntityDeclared (String name);
public boolean isEntityUnparsed (String name);
-
+
// id
public boolean isIdDeclared (String name);
public void addId(String name);
-
+
// idref
public void addIdRef(String name);
-
+
// get symbol from symbol table
public String getSymbol (String symbol);
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org