You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2007/03/19 19:34:39 UTC
svn commit: r520039 - in /xerces/java/trunk/src/org/apache/xerces/impl/xs:
XMLSchemaValidator.java identity/Field.java identity/FieldActivator.java
identity/ValueStore.java
Author: mrglavas
Date: Mon Mar 19 11:34:38 2007
New Revision: 520039
URL: http://svn.apache.org/viewvc?view=rev&rev=520039
Log:
Fixing the fix made to IDC in Revision 319835. There may be several
instances of the same field that may be active at a time so we
need a mayMatch flag per active XPath. This state is now stored in
the XPathMatcher. Incidentally, this should also improve performance
a bit since we're no longer churning a HashMap.
Modified:
xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/Field.java
xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/FieldActivator.java
xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/ValueStore.java
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java?view=diff&rev=520039&r1=520038&r2=520039
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java Mon Mar 19 11:34:38 2007
@@ -325,12 +325,6 @@
// clear this before we introduce it into the pipeline.
protected final AugmentationsImpl fAugmentations = new AugmentationsImpl();
- /**
- * Map which is used to catch instance documents that try
- * and match a field several times in the same scope.
- */
- protected final HashMap fMayMatchFieldMap = new HashMap();
-
// this is included for the convenience of handleEndElement
protected XMLString fDefaultValue;
@@ -1309,11 +1303,6 @@
fMatcherStack.clear();
- if (!fMayMatchFieldMap.isEmpty()) {
- // should only clear this if the last schema had identity constraints.
- fMayMatchFieldMap.clear();
- }
-
// get error reporter
fXSIErrorReporter.reset((XMLErrorReporter) componentManager.getProperty(ERROR_REPORTER));
@@ -1518,8 +1507,7 @@
public XPathMatcher activateField(Field field, int initialDepth) {
ValueStore valueStore =
fValueStoreCache.getValueStoreFor(field.getIdentityConstraint(), initialDepth);
- setMayMatch(field, Boolean.TRUE);
- XPathMatcher matcher = field.createMatcher(this, valueStore);
+ XPathMatcher matcher = field.createMatcher(valueStore);
fMatcherStack.addMatcher(matcher);
matcher.startDocumentFragment();
return matcher;
@@ -1538,28 +1526,6 @@
} // endValueScopeFor(IdentityConstraint)
- /**
- * Sets whether the given field is permitted to match a value.
- * This should be used to catch instance documents that try
- * and match a field several times in the same scope.
- *
- * @param field The field that may be permitted to be matched.
- * @param state Boolean indiciating whether the field may be matched.
- */
- public void setMayMatch(Field field, Boolean state) {
- fMayMatchFieldMap.put(field, state);
- } // setMayMatch(Field, Boolean)
-
- /**
- * Returns whether the given field is permitted to match a value.
- *
- * @param field The field that may be permitted to be matched.
- * @return Boolean indicating whether the field may be matched.
- */
- public Boolean mayMatch(Field field) {
- return (Boolean) fMayMatchFieldMap.get(field);
- } // mayMatch(Field):Boolean
-
// a utility method for Identity constraints
private void activateSelectorFor(IdentityConstraint ic) {
Selector selector = ic.getSelector();
@@ -3577,9 +3543,12 @@
* @param field The field associated to the value. This reference
* is used to ensure that each field only adds a value
* once within a selection scope.
+ * @param mayMatch a flag indiciating whether the field may be matched.
* @param actualValue The value to add.
+ * @param valueType Type of the value to add.
+ * @param itemValueType If the value is a list, a list of types for each of the values in the list.
*/
- public void addValue(Field field, Object actualValue, short valueType, ShortList itemValueType) {
+ public void addValue(Field field, boolean mayMatch, Object actualValue, short valueType, ShortList itemValueType) {
int i;
for (i = fFieldCount - 1; i > -1; i--) {
if (fFields[i] == field) {
@@ -3594,11 +3563,12 @@
reportSchemaError(code, new Object[] { field.toString(), eName, cName });
return;
}
- if (Boolean.TRUE != mayMatch(field)) {
+ if (!mayMatch) {
String code = "FieldMultipleMatch";
String cName = fIdentityConstraint.getIdentityConstraintName();
reportSchemaError(code, new Object[] { field.toString(), cName });
- } else {
+ }
+ else {
fValuesCount++;
}
fLocalValues[i] = actualValue;
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/Field.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/Field.java?view=diff&rev=520039&r1=520038&r2=520039
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/Field.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/Field.java Mon Mar 19 11:34:38 2007
@@ -76,8 +76,8 @@
// factory method
/** Creates a field matcher. */
- public XPathMatcher createMatcher(FieldActivator activator, ValueStore store) {
- return new Field.Matcher(fXPath, activator, store);
+ public XPathMatcher createMatcher(ValueStore store) {
+ return new Field.Matcher(fXPath, store);
} // createMatcher(ValueStore):XPathMatcher
//
@@ -205,20 +205,19 @@
// Data
//
- /** Field activator. */
- protected FieldActivator fFieldActivator;
-
/** Value store for data values. */
protected ValueStore fStore;
+
+ /** A flag indicating whether the field is allowed to match a value. */
+ protected boolean fMayMatch = true;
//
// Constructors
//
/** Constructs a field matcher. */
- public Matcher(Field.XPath xpath, FieldActivator activator, ValueStore store) {
+ public Matcher(Field.XPath xpath, ValueStore store) {
super(xpath);
- fFieldActivator = activator;
fStore = store;
} // <init>(Field.XPath,ValueStore)
@@ -237,11 +236,11 @@
fStore.reportError(code,
new Object[]{fIdentityConstraint.getElementName(), fIdentityConstraint.getIdentityConstraintName()});
}
- fStore.addValue(Field.this, actualValue, convertToPrimitiveKind(valueType), convertToPrimitiveKind(itemValueType));
+ fStore.addValue(Field.this, fMayMatch, actualValue, convertToPrimitiveKind(valueType), convertToPrimitiveKind(itemValueType));
// once we've stored the value for this field, we set the mayMatch
- // member to false so that, in the same scope, we don't match any more
+ // member to false so that in the same scope, we don't match any more
// values (and throw an error instead).
- fFieldActivator.setMayMatch(Field.this, Boolean.FALSE);
+ fMayMatch = false;
} // matched(String)
private short convertToPrimitiveKind(short valueType) {
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/FieldActivator.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/FieldActivator.java?view=diff&rev=520039&r1=520038&r2=520039
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/FieldActivator.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/FieldActivator.java Mon Mar 19 11:34:38 2007
@@ -49,31 +49,11 @@
/**
* Request to activate the specified field. This method returns the
* matcher for the field.
- * It's also important for the implementor to ensure that it marks whether a Field
- * is permitted to match a value--that is, to call the setMayMatch(Field, Boolean) method.
*
* @param field The field to activate.
* @param initialDepth the 0-indexed depth in the instance document at which the Selector began to match.
*/
public XPathMatcher activateField(Field field, int initialDepth);
-
- /**
- * Sets whether the given field is permitted to match a value.
- * This should be used to catch instance documents that try
- * and match a field several times in the same scope.
- *
- * @param field The field that may be permitted to be matched.
- * @param state Boolean indiciating whether the field may be matched.
- */
- public void setMayMatch(Field field, Boolean state);
-
- /**
- * Returns whether the given field is permitted to match a value.
- *
- * @param field The field that may be permitted to be matched.
- * @return Boolean indicating whether the field may be matched.
- */
- public Boolean mayMatch(Field field);
/**
* Ends the value scope for the specified identity constraint.
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/ValueStore.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/ValueStore.java?view=diff&rev=520039&r1=520038&r2=520039
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/ValueStore.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/ValueStore.java Mon Mar 19 11:34:38 2007
@@ -52,9 +52,12 @@
* @param field The field associated to the value. This reference
* is used to ensure that each field only adds a value
* once within a selection scope.
+ * @param mayMatch a flag indiciating whether the field may be matched.
* @param actualValue The value to add.
+ * @param valueType Type of the value to add.
+ * @param itemValueType If the value is a list, a list of types for each of the values in the list.
*/
- public void addValue(Field field, Object actualValue, short valueType, ShortList itemValueType);
+ public void addValue(Field field, boolean mayMatch, Object actualValue, short valueType, ShortList itemValueType);
/**
* Since the valueStore will have access to an error reporter, this
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org