public void endElement(QName element, XSTypeDefinition type, boolean nillable, Object actualValue, short valueType, ShortList itemValueType) { super.endElement(element, type, nillable, actualValue, valueType, itemValueType); if (fElementDepth-- == fMatchedDepth) { fMatchedDepth = -1; fFieldActivator.endValueScopeFor(fIdentityConstraint, fInitialDepth); } }
/** * {selector} A restricted XPath ([XPath]) expression */ public String getSelectorStr() { return (fSelector != null) ? fSelector.toString() : null; }
/** * This method is called when the XPath handler matches the * XPath expression. */ protected void matched(Object actualValue, short valueType, ShortList itemValueType, boolean isNil) { super.matched(actualValue, valueType, itemValueType, isNil); if(isNil && (fIdentityConstraint.getCategory() == IdentityConstraint.IC_KEY)) { String code = "KeyMatchesNillable"; fStore.reportError(code, new Object[]{fStore.getElementName(), fIdentityConstraint.getIdentityConstraintName()}); } 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 // values (and throw an error instead). fMayMatch = false; } // matched(String)
private void activateSelectorFor(IdentityConstraint ic) { Selector selector = ic.getSelector(); FieldActivator activator = this; if (selector == null) return; XPathMatcher matcher = selector.createMatcher(activator, fElementDepth); if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) { matcher.setXPathDefaultNamespace(selector.getXPathDefaultNamespace()); } fMatcherStack.addMatcher(matcher); matcher.startDocumentFragment(); }
/** * Request to activate the specified field. This method returns the * matcher for the field. * * @param field The field to activate. */ public XPathMatcher activateField(Field field, int initialDepth) { ValueStore valueStore = fValueStoreCache.getValueStoreFor(field.getIdentityConstraint(), initialDepth); XPathMatcher matcher = field.createMatcher(valueStore); if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) { matcher.setXPathDefaultNamespace(field.getXPathDefaultNamespace()); } fMatcherStack.addMatcher(matcher); matcher.startDocumentFragment(); return matcher; } // activateField(Field):XPathMatcher
/** * The start of an element. If the document specifies the start element * by using an empty tag, then the startElement method will immediately * be followed by the endElement method, with no intervening methods. * * @param element The name of the element. * @param attributes The element attributes. * */ public void startElement(QName element, XMLAttributes attributes) { super.startElement(element, attributes); fElementDepth++; // activate the fields, if selector is matched //int matched = isMatched(); if (isMatched()) { /* (fMatchedDepth == -1 && ((matched & MATCHED) == MATCHED)) || ((matched & MATCHED_DESCENDANT) == MATCHED_DESCENDANT)) { */ fMatchedDepth = fElementDepth; fFieldActivator.startValueScopeFor(fIdentityConstraint, fInitialDepth); int count = fIdentityConstraint.getFieldCount(); for (int i = 0; i < count; i++) { Field field = fIdentityConstraint.getFieldAt(i); XPathMatcher matcher = fFieldActivator.activateField(field, fInitialDepth); matcher.startElement(element, attributes); } } } // startElement(QName,XMLAttrList,int)
public boolean equals(IdentityConstraint id) { boolean areEqual = fIdentityConstraintName.equals(id.fIdentityConstraintName); if(!areEqual) return false; areEqual = fSelector.toString().equals(id.fSelector.toString()); if(!areEqual) return false; areEqual = (fFieldCount == id.fFieldCount); if(!areEqual) return false; for(int i=0; i<fFieldCount; i++) if(!fFields[i].toString().equals(id.fFields[i].toString())) return false; return true; } // equals
void addIDConstraintDecl(IdentityConstraint decl) { final String namespace = decl.getNamespace(); final String declKey = (namespace == null || namespace.length() == 0) ? "," + decl.getIdentityConstraintName() : namespace + "," + decl.getIdentityConstraintName(); if (fGlobalIDConstraintDecls.get(declKey) == null) { fGlobalIDConstraintDecls.put(declKey, decl); } }
/** Constructs a value store for the specified identity constraint. */ protected ValueStoreBase(IdentityConstraint identityConstraint, String elementName) { fElementName = elementName; fIdentityConstraint = identityConstraint; fFieldCount = fIdentityConstraint.getFieldCount(); fFields = new Field[fFieldCount]; fLocalValues = new Object[fFieldCount]; fLocalValueTypes = new short[fFieldCount]; fLocalItemValueTypes = new ShortList[fFieldCount]; for (int i = 0; i < fFieldCount; i++) { fFields[i] = fIdentityConstraint.getFieldAt(i); } } // <init>(IdentityConstraint)
public final void addIDConstraintDecl(XSElementDecl elmDecl, IdentityConstraint decl, String location) { fGlobalIDConstraintDeclsExt.put(((location != null) ? location : "") + "," + decl.getIdentityConstraintName(), decl); }
/** Adds a field. */ public void addField(Field field) { if (fFields == null) fFields = new Field[4]; else if (fFieldCount == fFields.length) fFields = resize(fFields, fFieldCount*2); fFields[fFieldCount++] = field; } // addField(Field)
/** Creates a selector matcher. * @param activator The activator for this selector's fields. * @param initialDepth The depth in the document at which this matcher began its life; * used in correctly handling recursive elements. */ public XPathMatcher createMatcher(FieldActivator activator, int initialDepth) { return new Selector.Matcher(fXPath, activator, initialDepth); } // createMatcher(FieldActivator):XPathMatcher
public void startDocumentFragment(){ super.startDocumentFragment(); fElementDepth = 0; fMatchedDepth = -1; } // startDocumentFragment()
/** Creates a field matcher. */ public XPathMatcher createMatcher(ValueStore store) { return new Field.Matcher(fXPath, store); } // createMatcher(ValueStore):XPathMatcher
/** * {fields} A non-empty list of restricted XPath ([XPath]) expressions. */ public StringList getFieldStrs() { String[] strs = new String[fFieldCount]; for (int i = 0; i < fFieldCount; i++) strs[i] = fFields[i].toString(); return new StringListImpl(strs, fFieldCount); }
protected void handleContent(XSTypeDefinition type, boolean nillable, Object actualValue, short valueType, ShortList itemValueType) { if (type == null || type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE && ((XSComplexTypeDefinition) type).getContentType() != XSComplexTypeDefinition.CONTENTTYPE_SIMPLE) { // the content must be simpleType content fStore.reportError( "cvc-id.3", new Object[] { fIdentityConstraint.getName(), fStore.getElementName()}); } fMatchedString = actualValue; matched(fMatchedString, valueType, itemValueType, nillable); } // handleContent(XSElementDecl, String)
/** Returns a string representation of this object. */ public String toString() { return fXPath.toString(); } // toString():String
/** Returns a string representation of this object. */ public String toString() { return fXPath.toString(); } // toString():String
/** Constructs a selector XPath expression. */ public XPath(String xpath, SymbolTable symbolTable, NamespaceContext context) throws XPathException { super(normalize(xpath), symbolTable, context); // verify that an attribute is not selected for (int i=0;i<fLocationPaths.length;i++) { org.apache.xerces.impl.xpath.XPath.Axis axis = fLocationPaths[i].steps[fLocationPaths[i].steps.length-1].axis; if (axis.type == XPath.Axis.ATTRIBUTE) { throw new XPathException("c-selector-xpath"); } } } // <init>(String,SymbolTable,NamespacesScope)
/** * register one identity constraint */ public final void addIDConstraintDecl(XSElementDecl elmDecl, IdentityConstraint decl) { elmDecl.addIDConstraint(decl); fGlobalIDConstraintDecls.put(decl.getIdentityConstraintName(), decl); }