schemagrammar.java
来自「JAVA 所有包」· Java 代码 · 共 1,202 行 · 第 1/4 页
JAVA
1,202 行
} /** * register one global type */ public void addGlobalTypeDecl(XSTypeDefinition decl) { fGlobalTypeDecls.put(decl.getName(), decl); } /** * register one identity constraint */ public final void addIDConstraintDecl(XSElementDecl elmDecl, IdentityConstraint decl) { elmDecl.addIDConstraint(decl); fGlobalIDConstraintDecls.put(decl.getIdentityConstraintName(), decl); } /** * get one global attribute */ public final XSAttributeDecl getGlobalAttributeDecl(String declName) { return(XSAttributeDecl)fGlobalAttrDecls.get(declName); } /** * get one global attribute group */ public final XSAttributeGroupDecl getGlobalAttributeGroupDecl(String declName) { return(XSAttributeGroupDecl)fGlobalAttrGrpDecls.get(declName); } /** * get one global element */ public final XSElementDecl getGlobalElementDecl(String declName) { return(XSElementDecl)fGlobalElemDecls.get(declName); } /** * get one global group */ public final XSGroupDecl getGlobalGroupDecl(String declName) { return(XSGroupDecl)fGlobalGroupDecls.get(declName); } /** * get one global notation */ public final XSNotationDecl getGlobalNotationDecl(String declName) { return(XSNotationDecl)fGlobalNotationDecls.get(declName); } /** * get one global type */ public final XSTypeDefinition getGlobalTypeDecl(String declName) { return(XSTypeDefinition)fGlobalTypeDecls.get(declName); } /** * get one identity constraint */ public final IdentityConstraint getIDConstraintDecl(String declName) { return(IdentityConstraint)fGlobalIDConstraintDecls.get(declName); } /** * get one identity constraint */ public final boolean hasIDConstraints() { return fGlobalIDConstraintDecls.getLength() > 0; } // array to store complex type decls private static final int INITIAL_SIZE = 16; private static final int INC_SIZE = 16; private int fCTCount = 0; private XSComplexTypeDecl[] fComplexTypeDecls = new XSComplexTypeDecl[INITIAL_SIZE]; private SimpleLocator[] fCTLocators = new SimpleLocator[INITIAL_SIZE]; // an array to store groups being redefined by restriction // even-numbered elements are the derived groups, odd-numbered ones their bases private static final int REDEFINED_GROUP_INIT_SIZE = 2; private int fRGCount = 0; private XSGroupDecl[] fRedefinedGroupDecls = new XSGroupDecl[REDEFINED_GROUP_INIT_SIZE]; private SimpleLocator[] fRGLocators = new SimpleLocator[REDEFINED_GROUP_INIT_SIZE/2]; // a flag to indicate whether we have checked the 3 constraints on this // grammar. boolean fFullChecked = false; /** * add one complex type decl: for later constraint checking */ public void addComplexTypeDecl(XSComplexTypeDecl decl, SimpleLocator locator) { if (fCTCount == fComplexTypeDecls.length) { fComplexTypeDecls = resize(fComplexTypeDecls, fCTCount+INC_SIZE); fCTLocators = resize(fCTLocators, fCTCount+INC_SIZE); } fCTLocators[fCTCount] = locator; fComplexTypeDecls[fCTCount++] = decl; } /** * add a group redefined by restriction: for later constraint checking */ public void addRedefinedGroupDecl(XSGroupDecl derived, XSGroupDecl base, SimpleLocator locator) { if (fRGCount == fRedefinedGroupDecls.length) { // double array size each time. fRedefinedGroupDecls = resize(fRedefinedGroupDecls, fRGCount << 1); fRGLocators = resize(fRGLocators, fRGCount); } fRGLocators[fRGCount/2] = locator; fRedefinedGroupDecls[fRGCount++] = derived; fRedefinedGroupDecls[fRGCount++] = base; } /** * get all complex type decls: for later constraint checking */ final XSComplexTypeDecl[] getUncheckedComplexTypeDecls() { if (fCTCount < fComplexTypeDecls.length) { fComplexTypeDecls = resize(fComplexTypeDecls, fCTCount); fCTLocators = resize(fCTLocators, fCTCount); } return fComplexTypeDecls; } /** * get the error locator of all complex type decls */ final SimpleLocator[] getUncheckedCTLocators() { if (fCTCount < fCTLocators.length) { fComplexTypeDecls = resize(fComplexTypeDecls, fCTCount); fCTLocators = resize(fCTLocators, fCTCount); } return fCTLocators; } /** * get all redefined groups: for later constraint checking */ final XSGroupDecl[] getRedefinedGroupDecls() { if (fRGCount < fRedefinedGroupDecls.length) { fRedefinedGroupDecls = resize(fRedefinedGroupDecls, fRGCount); fRGLocators = resize(fRGLocators, fRGCount/2); } return fRedefinedGroupDecls; } /** * get the error locator of all redefined groups */ final SimpleLocator[] getRGLocators() { if (fRGCount < fRedefinedGroupDecls.length) { fRedefinedGroupDecls = resize(fRedefinedGroupDecls, fRGCount); fRGLocators = resize(fRGLocators, fRGCount/2); } return fRGLocators; } /** * after the first-round checking, some types don't need to be checked * against UPA again. here we trim the array to the proper size. */ final void setUncheckedTypeNum(int newSize) { fCTCount = newSize; fComplexTypeDecls = resize(fComplexTypeDecls, fCTCount); fCTLocators = resize(fCTLocators, fCTCount); } // used to store all substitution group information declared in // this namespace private int fSubGroupCount = 0; private XSElementDecl[] fSubGroups = new XSElementDecl[INITIAL_SIZE]; /** * get all substitution group information: for the 3 constraint checking */ final XSElementDecl[] getSubstitutionGroups() { if (fSubGroupCount < fSubGroups.length) fSubGroups = resize(fSubGroups, fSubGroupCount); return fSubGroups; } // anyType and anySimpleType: because there are so many places where // we need direct access to these two types public final static XSComplexTypeDecl fAnyType = new XSAnyType(); private static class XSAnyType extends XSComplexTypeDecl { public XSAnyType () { fName = SchemaSymbols.ATTVAL_ANYTYPE; super.fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA; fBaseType = this; fDerivedBy = XSConstants.DERIVATION_RESTRICTION; fContentType = XSComplexTypeDecl.CONTENTTYPE_MIXED; fParticle = null; fAttrGrp = null; } // overridden methods public void setValues(String name, String targetNamespace, XSTypeDefinition baseType, short derivedBy, short schemaFinal, short block, short contentType, boolean isAbstract, XSAttributeGroupDecl attrGrp, XSSimpleType simpleType, XSParticleDecl particle) { // don't allow this. } public void setName(String name){ // don't allow this. } public void setIsAbstractType() { // null implementation } public void setContainsTypeID() { // null implementation } public void setIsAnonymous() { // null implementation } public void reset() { // null implementation } public XSObjectList getAttributeUses() { return new XSObjectListImpl(null, 0); } public XSAttributeGroupDecl getAttrGrp() { XSWildcardDecl wildcard = new XSWildcardDecl(); wildcard.fProcessContents = XSWildcardDecl.PC_LAX; XSAttributeGroupDecl attrGrp = new XSAttributeGroupDecl(); attrGrp.fAttributeWC = wildcard; return attrGrp; } public XSWildcard getAttributeWildcard() { XSWildcardDecl wildcard = new XSWildcardDecl(); wildcard.fProcessContents = XSWildcardDecl.PC_LAX; return wildcard; } public XSParticle getParticle() { // the wildcard used in anyType (content and attribute) // the spec will change strict to skip for anyType XSWildcardDecl wildcard = new XSWildcardDecl(); wildcard.fProcessContents = XSWildcardDecl.PC_LAX; // the particle for the content wildcard XSParticleDecl particleW = new XSParticleDecl(); particleW.fMinOccurs = 0; particleW.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED; particleW.fType = XSParticleDecl.PARTICLE_WILDCARD; particleW.fValue = wildcard; // the model group of a sequence of the above particle XSModelGroupImpl group = new XSModelGroupImpl(); group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE; group.fParticleCount = 1; group.fParticles = new XSParticleDecl[1]; group.fParticles[0] = particleW; // the content of anyType: particle of the above model group XSParticleDecl particleG = new XSParticleDecl(); particleG.fType = XSParticleDecl.PARTICLE_MODELGROUP; particleG.fValue = group; return particleG; } public XSObjectList getAnnotations() { return null; } } private static class BuiltinAttrDecl extends XSAttributeDecl { public BuiltinAttrDecl(String name, String tns, XSSimpleType type, short scope) { fName = name; super.fTargetNamespace = tns; fType = type; fScope = scope; } public void setValues(String name, String targetNamespace, XSSimpleType simpleType, short constraintType, short scope, ValidatedInfo valInfo, XSComplexTypeDecl enclosingCT) { // ignore this call. } public void reset () { // also ignore this call. } public XSAnnotation getAnnotation() { return null; } } // class BuiltinAttrDecl // the grammars to hold components of the schema namespace
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?