SchemaGrammar.java revision 649:507d4f7efba6
1/* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5/* 6 * Licensed to the Apache Software Foundation (ASF) under one or more 7 * contributor license agreements. See the NOTICE file distributed with 8 * this work for additional information regarding copyright ownership. 9 * The ASF licenses this file to You under the Apache License, Version 2.0 10 * (the "License"); you may not use this file except in compliance with 11 * the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 */ 21 22package com.sun.org.apache.xerces.internal.impl.xs; 23 24import com.sun.org.apache.xerces.internal.impl.Constants; 25import com.sun.org.apache.xerces.internal.impl.dv.SchemaDVFactory; 26import com.sun.org.apache.xerces.internal.impl.dv.ValidatedInfo; 27import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType; 28import com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl; 29import com.sun.org.apache.xerces.internal.impl.xs.identity.IdentityConstraint; 30import com.sun.org.apache.xerces.internal.impl.xs.util.ObjectListImpl; 31import com.sun.org.apache.xerces.internal.impl.xs.util.SimpleLocator; 32import com.sun.org.apache.xerces.internal.impl.xs.util.StringListImpl; 33import com.sun.org.apache.xerces.internal.impl.xs.util.XSNamedMap4Types; 34import com.sun.org.apache.xerces.internal.impl.xs.util.XSNamedMapImpl; 35import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl; 36import com.sun.org.apache.xerces.internal.parsers.DOMParser; 37import com.sun.org.apache.xerces.internal.parsers.SAXParser; 38import com.sun.org.apache.xerces.internal.parsers.XML11Configuration; 39import com.sun.org.apache.xerces.internal.util.SymbolHash; 40import com.sun.org.apache.xerces.internal.util.SymbolTable; 41import com.sun.org.apache.xerces.internal.xni.NamespaceContext; 42import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription; 43import com.sun.org.apache.xerces.internal.xni.grammars.XSGrammar; 44import com.sun.org.apache.xerces.internal.xs.StringList; 45import com.sun.org.apache.xerces.internal.xs.XSAnnotation; 46import com.sun.org.apache.xerces.internal.xs.XSAttributeDeclaration; 47import com.sun.org.apache.xerces.internal.xs.XSAttributeGroupDefinition; 48import com.sun.org.apache.xerces.internal.xs.XSConstants; 49import com.sun.org.apache.xerces.internal.xs.XSElementDeclaration; 50import com.sun.org.apache.xerces.internal.xs.XSIDCDefinition; 51import com.sun.org.apache.xerces.internal.xs.XSModel; 52import com.sun.org.apache.xerces.internal.xs.XSModelGroupDefinition; 53import com.sun.org.apache.xerces.internal.xs.XSNamedMap; 54import com.sun.org.apache.xerces.internal.xs.XSNamespaceItem; 55import com.sun.org.apache.xerces.internal.xs.XSNotationDeclaration; 56import com.sun.org.apache.xerces.internal.xs.XSObjectList; 57import com.sun.org.apache.xerces.internal.xs.XSParticle; 58import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; 59import com.sun.org.apache.xerces.internal.xs.XSWildcard; 60import com.sun.org.apache.xerces.internal.xs.datatypes.ObjectList; 61import java.lang.ref.SoftReference; 62import java.util.Vector; 63import org.xml.sax.SAXException; 64 65/** 66 * This class is to hold all schema component declaration that are declared 67 * within one namespace. 68 * 69 * The Grammar class this class extends contains what little 70 * commonality there is between XML Schema and DTD grammars. It's 71 * useful to distinguish grammar objects from other kinds of object 72 * when they exist in pools or caches. 73 * 74 * @xerces.internal 75 * 76 * @author Sandy Gao, IBM 77 * @author Elena Litani, IBM 78 * 79 */ 80 81public class SchemaGrammar implements XSGrammar, XSNamespaceItem { 82 83 // the target namespace of grammar 84 String fTargetNamespace; 85 86 // global decls: map from decl name to decl object 87 SymbolHash fGlobalAttrDecls; 88 SymbolHash fGlobalAttrGrpDecls; 89 SymbolHash fGlobalElemDecls; 90 SymbolHash fGlobalGroupDecls; 91 SymbolHash fGlobalNotationDecls; 92 SymbolHash fGlobalIDConstraintDecls; 93 SymbolHash fGlobalTypeDecls; 94 95 // extended global decls: map from schema location + decl name to decl object 96 // key is location,name 97 SymbolHash fGlobalAttrDeclsExt; 98 SymbolHash fGlobalAttrGrpDeclsExt; 99 SymbolHash fGlobalElemDeclsExt; 100 SymbolHash fGlobalGroupDeclsExt; 101 SymbolHash fGlobalNotationDeclsExt; 102 SymbolHash fGlobalIDConstraintDeclsExt; 103 SymbolHash fGlobalTypeDeclsExt; 104 105 // A global map of all global element declarations - used for substitution group computation 106 // (handy when sharing components by reference, since we might end up with duplicate components 107 // that are not added to either of the global element declarations above) 108 SymbolHash fAllGlobalElemDecls; 109 110 // the XMLGrammarDescription member 111 XSDDescription fGrammarDescription = null; 112 113 // annotations associated with the "root" schema of this targetNamespace 114 XSAnnotationImpl [] fAnnotations = null; 115 116 // number of annotations declared 117 int fNumAnnotations; 118 119 // symbol table for constructing parsers (annotation support) 120 private SymbolTable fSymbolTable = null; 121 // parsers for annotation support 122 private SoftReference fSAXParser = null; 123 private SoftReference fDOMParser = null; 124 125 // is this grammar immutable? (fully constructed and not changeable) 126 private boolean fIsImmutable = false; 127 128 // 129 // Constructors 130 // 131 132 // needed to make BuiltinSchemaGrammar work. 133 protected SchemaGrammar() {} 134 135 /** 136 * Default constructor. 137 * 138 * @param targetNamespace 139 * @param grammarDesc the XMLGrammarDescription corresponding to this object 140 * at the least a systemId should always be known. 141 * @param symbolTable needed for annotation support 142 */ 143 public SchemaGrammar(String targetNamespace, XSDDescription grammarDesc, 144 SymbolTable symbolTable) { 145 fTargetNamespace = targetNamespace; 146 fGrammarDescription = grammarDesc; 147 fSymbolTable = symbolTable; 148 149 // REVISIT: the initial sizes being chosen for each SymbolHash 150 // may not be ideal and could still be tuned. They were chosen 151 // somewhat arbitrarily to reduce the initial footprint of 152 // SymbolHash buckets from 1,515 to 177 (about 12% of the 153 // default size). 154 fGlobalAttrDecls = new SymbolHash(12); 155 fGlobalAttrGrpDecls = new SymbolHash(5); 156 fGlobalElemDecls = new SymbolHash(25); 157 fGlobalGroupDecls = new SymbolHash(5); 158 fGlobalNotationDecls = new SymbolHash(1); 159 fGlobalIDConstraintDecls = new SymbolHash(3); 160 161 // Extended tables 162 fGlobalAttrDeclsExt = new SymbolHash(12); 163 fGlobalAttrGrpDeclsExt = new SymbolHash(5); 164 fGlobalElemDeclsExt = new SymbolHash(25); 165 fGlobalGroupDeclsExt = new SymbolHash(5); 166 fGlobalNotationDeclsExt = new SymbolHash(1); 167 fGlobalIDConstraintDeclsExt = new SymbolHash(3); 168 fGlobalTypeDeclsExt = new SymbolHash(25); 169 170 // All global elements table 171 fAllGlobalElemDecls = new SymbolHash(25); 172 173 // if we are parsing S4S, put built-in types in first 174 // they might get overwritten by the types from S4S, but that's 175 // considered what the application wants to do. 176 if (fTargetNamespace == SchemaSymbols.URI_SCHEMAFORSCHEMA) { 177 fGlobalTypeDecls = SG_SchemaNS.fGlobalTypeDecls.makeClone(); 178 } 179 else { 180 fGlobalTypeDecls = new SymbolHash(25); 181 } 182 } // <init>(String, XSDDescription) 183 184 // Clone an existing schema grammar 185 public SchemaGrammar(SchemaGrammar grammar) { 186 fTargetNamespace = grammar.fTargetNamespace; 187 fGrammarDescription = grammar.fGrammarDescription.makeClone(); 188 //fGrammarDescription.fContextType |= XSDDescription.CONTEXT_COLLISION; // REVISIT 189 fSymbolTable = grammar.fSymbolTable; // REVISIT 190 191 fGlobalAttrDecls = grammar.fGlobalAttrDecls.makeClone(); 192 fGlobalAttrGrpDecls = grammar.fGlobalAttrGrpDecls.makeClone(); 193 fGlobalElemDecls = grammar.fGlobalElemDecls.makeClone(); 194 fGlobalGroupDecls = grammar.fGlobalGroupDecls.makeClone(); 195 fGlobalNotationDecls = grammar.fGlobalNotationDecls.makeClone(); 196 fGlobalIDConstraintDecls = grammar.fGlobalIDConstraintDecls.makeClone(); 197 fGlobalTypeDecls = grammar.fGlobalTypeDecls.makeClone(); 198 199 // Extended tables 200 fGlobalAttrDeclsExt = grammar.fGlobalAttrDeclsExt.makeClone(); 201 fGlobalAttrGrpDeclsExt = grammar.fGlobalAttrGrpDeclsExt.makeClone(); 202 fGlobalElemDeclsExt = grammar.fGlobalElemDeclsExt.makeClone(); 203 fGlobalGroupDeclsExt = grammar.fGlobalGroupDeclsExt.makeClone(); 204 fGlobalNotationDeclsExt = grammar.fGlobalNotationDeclsExt.makeClone(); 205 fGlobalIDConstraintDeclsExt = grammar.fGlobalIDConstraintDeclsExt.makeClone(); 206 fGlobalTypeDeclsExt = grammar.fGlobalTypeDeclsExt.makeClone(); 207 208 // All global elements table 209 fAllGlobalElemDecls = grammar.fAllGlobalElemDecls.makeClone(); 210 211 // Annotations associated with the "root" schema of this targetNamespace 212 fNumAnnotations = grammar.fNumAnnotations; 213 if (fNumAnnotations > 0) { 214 fAnnotations = new XSAnnotationImpl[grammar.fAnnotations.length]; 215 System.arraycopy(grammar.fAnnotations, 0, fAnnotations, 0, fNumAnnotations); 216 } 217 218 // All substitution group information declared in this namespace 219 fSubGroupCount = grammar.fSubGroupCount; 220 if (fSubGroupCount > 0) { 221 fSubGroups = new XSElementDecl[grammar.fSubGroups.length]; 222 System.arraycopy(grammar.fSubGroups, 0, fSubGroups, 0, fSubGroupCount); 223 } 224 225 // Array to store complex type decls for constraint checking 226 fCTCount = grammar.fCTCount; 227 if (fCTCount > 0) { 228 fComplexTypeDecls = new XSComplexTypeDecl[grammar.fComplexTypeDecls.length]; 229 fCTLocators = new SimpleLocator[grammar.fCTLocators.length]; 230 System.arraycopy(grammar.fComplexTypeDecls, 0, fComplexTypeDecls, 0, fCTCount); 231 System.arraycopy(grammar.fCTLocators, 0, fCTLocators, 0, fCTCount); 232 } 233 234 // Groups being redefined by restriction 235 fRGCount = grammar.fRGCount; 236 if (fRGCount > 0) { 237 fRedefinedGroupDecls = new XSGroupDecl[grammar.fRedefinedGroupDecls.length]; 238 fRGLocators = new SimpleLocator[grammar.fRGLocators.length]; 239 System.arraycopy(grammar.fRedefinedGroupDecls, 0, fRedefinedGroupDecls, 0, fRGCount); 240 System.arraycopy(grammar.fRGLocators, 0, fRGLocators, 0, fRGCount/2); 241 } 242 243 // List of imported grammars 244 if (grammar.fImported != null) { 245 fImported = new Vector(); 246 for (int i=0; i<grammar.fImported.size(); i++) { 247 fImported.add(grammar.fImported.elementAt(i)); 248 } 249 } 250 251 // Locations 252 if (grammar.fLocations != null) { 253 for (int k=0; k<grammar.fLocations.size(); k++) { 254 addDocument(null, (String)grammar.fLocations.elementAt(k)); 255 } 256 } 257 258 } // <init>(String, XSDDescription) 259 260 // number of built-in XSTypes we need to create for base and full 261 // datatype set 262 private static final int BASICSET_COUNT = 29; 263 private static final int FULLSET_COUNT = 46; 264 265 private static final int GRAMMAR_XS = 1; 266 private static final int GRAMMAR_XSI = 2; 267 268 // this class makes sure the static, built-in schema grammars 269 // are immutable. 270 public static class BuiltinSchemaGrammar extends SchemaGrammar { 271 272 private static final String EXTENDED_SCHEMA_FACTORY_CLASS = "com.sun.org.apache.xerces.internal.impl.dv.xs.ExtendedSchemaDVFactoryImpl"; 273 274 /** 275 * Special constructor to create the grammars for the schema namespaces 276 * 277 * @param grammar 278 */ 279 public BuiltinSchemaGrammar(int grammar, short schemaVersion) { 280 SchemaDVFactory schemaFactory; 281 if (schemaVersion == Constants.SCHEMA_VERSION_1_0) { 282 schemaFactory = SchemaDVFactory.getInstance(); 283 } 284 else { 285 schemaFactory = SchemaDVFactory.getInstance(EXTENDED_SCHEMA_FACTORY_CLASS); 286 } 287 288 if (grammar == GRAMMAR_XS) { 289 // target namespace 290 fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA; 291 292 // grammar description 293 fGrammarDescription = new XSDDescription(); 294 fGrammarDescription.fContextType = XSDDescription.CONTEXT_PREPARSE; 295 fGrammarDescription.setNamespace(SchemaSymbols.URI_SCHEMAFORSCHEMA); 296 297 // no global decls other than types 298 fGlobalAttrDecls = new SymbolHash(1); 299 fGlobalAttrGrpDecls = new SymbolHash(1); 300 fGlobalElemDecls = new SymbolHash(1); 301 fGlobalGroupDecls = new SymbolHash(1); 302 fGlobalNotationDecls = new SymbolHash(1); 303 fGlobalIDConstraintDecls = new SymbolHash(1); 304 305 // no extended global decls 306 fGlobalAttrDeclsExt = new SymbolHash(1); 307 fGlobalAttrGrpDeclsExt = new SymbolHash(1); 308 fGlobalElemDeclsExt = new SymbolHash(1); 309 fGlobalGroupDeclsExt = new SymbolHash(1); 310 fGlobalNotationDeclsExt = new SymbolHash(1); 311 fGlobalIDConstraintDeclsExt = new SymbolHash(1); 312 fGlobalTypeDeclsExt = new SymbolHash(1); 313 314 // all global element decls table 315 fAllGlobalElemDecls = new SymbolHash(1); 316 317 // get all built-in types 318 fGlobalTypeDecls = schemaFactory.getBuiltInTypes(); 319 320 // assign the built-in schema grammar as the XSNamespaceItem 321 // for each of the built-in simple type definitions. 322 int length = fGlobalTypeDecls.getLength(); 323 XSTypeDefinition [] typeDefinitions = new XSTypeDefinition[length]; 324 fGlobalTypeDecls.getValues(typeDefinitions, 0); 325 for (int i = 0; i < length; ++i) { 326 XSTypeDefinition xtd = typeDefinitions[i]; 327 if (xtd instanceof XSSimpleTypeDecl) { 328 ((XSSimpleTypeDecl) xtd).setNamespaceItem(this); 329 } 330 } 331 332 // add anyType 333 fGlobalTypeDecls.put(fAnyType.getName(), fAnyType); 334 } 335 else if (grammar == GRAMMAR_XSI) { 336 // target namespace 337 fTargetNamespace = SchemaSymbols.URI_XSI; 338 // grammar description 339 fGrammarDescription = new XSDDescription(); 340 fGrammarDescription.fContextType = XSDDescription.CONTEXT_PREPARSE; 341 fGrammarDescription.setNamespace(SchemaSymbols.URI_XSI); 342 343 // no global decls other than attributes 344 fGlobalAttrGrpDecls = new SymbolHash(1); 345 fGlobalElemDecls = new SymbolHash(1); 346 fGlobalGroupDecls = new SymbolHash(1); 347 fGlobalNotationDecls = new SymbolHash(1); 348 fGlobalIDConstraintDecls = new SymbolHash(1); 349 fGlobalTypeDecls = new SymbolHash(1); 350 351 // no extended global decls 352 fGlobalAttrDeclsExt = new SymbolHash(1); 353 fGlobalAttrGrpDeclsExt = new SymbolHash(1); 354 fGlobalElemDeclsExt = new SymbolHash(1); 355 fGlobalGroupDeclsExt = new SymbolHash(1); 356 fGlobalNotationDeclsExt = new SymbolHash(1); 357 fGlobalIDConstraintDeclsExt = new SymbolHash(1); 358 fGlobalTypeDeclsExt = new SymbolHash(1); 359 360 // no all global element decls 361 fAllGlobalElemDecls = new SymbolHash(1); 362 363 // 4 attributes, so initialize the size as 4*2 = 8 364 fGlobalAttrDecls = new SymbolHash(8); 365 String name = null; 366 String tns = null; 367 XSSimpleType type = null; 368 short scope = XSConstants.SCOPE_GLOBAL; 369 370 // xsi:type 371 name = SchemaSymbols.XSI_TYPE; 372 tns = SchemaSymbols.URI_XSI; 373 type = schemaFactory.getBuiltInType(SchemaSymbols.ATTVAL_QNAME); 374 fGlobalAttrDecls.put(name, new BuiltinAttrDecl(name, tns, type, scope)); 375 376 // xsi:nil 377 name = SchemaSymbols.XSI_NIL; 378 tns = SchemaSymbols.URI_XSI; 379 type = schemaFactory.getBuiltInType(SchemaSymbols.ATTVAL_BOOLEAN); 380 fGlobalAttrDecls.put(name, new BuiltinAttrDecl(name, tns, type, scope)); 381 382 XSSimpleType anyURI = schemaFactory.getBuiltInType(SchemaSymbols.ATTVAL_ANYURI); 383 384 // xsi:schemaLocation 385 name = SchemaSymbols.XSI_SCHEMALOCATION; 386 tns = SchemaSymbols.URI_XSI; 387 type = schemaFactory.createTypeList("#AnonType_schemaLocation", SchemaSymbols.URI_XSI, (short)0, anyURI, null); 388 if (type instanceof XSSimpleTypeDecl) { 389 ((XSSimpleTypeDecl)type).setAnonymous(true); 390 } 391 fGlobalAttrDecls.put(name, new BuiltinAttrDecl(name, tns, type, scope)); 392 393 // xsi:noNamespaceSchemaLocation 394 name = SchemaSymbols.XSI_NONAMESPACESCHEMALOCATION; 395 tns = SchemaSymbols.URI_XSI; 396 type = anyURI; 397 fGlobalAttrDecls.put(name, new BuiltinAttrDecl(name, tns, type, scope)); 398 } 399 } // <init>(int) 400 401 // return the XMLGrammarDescription corresponding to this 402 // object 403 public XMLGrammarDescription getGrammarDescription() { 404 return fGrammarDescription.makeClone(); 405 } // getGrammarDescription(): XMLGrammarDescription 406 407 // override these methods solely so that these 408 // objects cannot be modified once they're created. 409 public void setImportedGrammars(Vector importedGrammars) { 410 // ignore 411 } 412 public void addGlobalAttributeDecl(XSAttributeDecl decl) { 413 // ignore 414 } 415 public void addGlobalAttributeDecl(XSAttributeDecl decl, String location) { 416 // ignore 417 } 418 public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl) { 419 // ignore 420 } 421 public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl, String location) { 422 // ignore 423 } 424 public void addGlobalElementDecl(XSElementDecl decl) { 425 // ignore 426 } 427 public void addGlobalElementDecl(XSElementDecl decl, String location) { 428 // ignore 429 } 430 public void addGlobalElementDeclAll(XSElementDecl decl) { 431 // ignore 432 } 433 public void addGlobalGroupDecl(XSGroupDecl decl) { 434 // ignore 435 } 436 public void addGlobalGroupDecl(XSGroupDecl decl, String location) { 437 // ignore 438 } 439 public void addGlobalNotationDecl(XSNotationDecl decl) { 440 // ignore 441 } 442 public void addGlobalNotationDecl(XSNotationDecl decl, String location) { 443 // ignore 444 } 445 public void addGlobalTypeDecl(XSTypeDefinition decl) { 446 // ignore 447 } 448 public void addGlobalTypeDecl(XSTypeDefinition decl, String location) { 449 // ignore 450 } 451 public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl) { 452 // ignore 453 } 454 public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl, String location) { 455 // ignore 456 } 457 public void addGlobalSimpleTypeDecl(XSSimpleType decl) { 458 // ignore 459 } 460 public void addGlobalSimpleTypeDecl(XSSimpleType decl, String location) { 461 // ignore 462 } 463 public void addComplexTypeDecl(XSComplexTypeDecl decl, SimpleLocator locator) { 464 // ignore 465 } 466 public void addRedefinedGroupDecl(XSGroupDecl derived, XSGroupDecl base, SimpleLocator locator) { 467 // ignore 468 } 469 public synchronized void addDocument(Object document, String location) { 470 // ignore 471 } 472 473 // annotation support 474 synchronized DOMParser getDOMParser() { 475 return null; 476 } 477 synchronized SAXParser getSAXParser() { 478 return null; 479 } 480 } 481 482 /** 483 * <p>A partial schema for schemas for validating annotations.</p> 484 * 485 * @xerces.internal 486 * 487 * @author Michael Glavassevich, IBM 488 */ 489 public static final class Schema4Annotations extends SchemaGrammar { 490 491 /** 492 * Singleton instance. 493 */ 494 public static final Schema4Annotations INSTANCE = new Schema4Annotations(); 495 496 /** 497 * Special constructor to create a schema 498 * capable of validating annotations. 499 */ 500 private Schema4Annotations() { 501 502 // target namespace 503 fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA; 504 505 // grammar description 506 fGrammarDescription = new XSDDescription(); 507 fGrammarDescription.fContextType = XSDDescription.CONTEXT_PREPARSE; 508 fGrammarDescription.setNamespace(SchemaSymbols.URI_SCHEMAFORSCHEMA); 509 510 // no global decls other than types and 511 // element declarations for <annotation>, <documentation> and <appinfo>. 512 fGlobalAttrDecls = new SymbolHash(1); 513 fGlobalAttrGrpDecls = new SymbolHash(1); 514 fGlobalElemDecls = new SymbolHash(6); 515 fGlobalGroupDecls = new SymbolHash(1); 516 fGlobalNotationDecls = new SymbolHash(1); 517 fGlobalIDConstraintDecls = new SymbolHash(1); 518 519 // no extended global decls 520 fGlobalAttrDeclsExt = new SymbolHash(1); 521 fGlobalAttrGrpDeclsExt = new SymbolHash(1); 522 fGlobalElemDeclsExt = new SymbolHash(6); 523 fGlobalGroupDeclsExt = new SymbolHash(1); 524 fGlobalNotationDeclsExt = new SymbolHash(1); 525 fGlobalIDConstraintDeclsExt = new SymbolHash(1); 526 fGlobalTypeDeclsExt = new SymbolHash(1); 527 528 // all global element declarations 529 fAllGlobalElemDecls = new SymbolHash(6); 530 531 // get all built-in types 532 fGlobalTypeDecls = SG_SchemaNS.fGlobalTypeDecls; 533 534 // create element declarations for <annotation>, <documentation> and <appinfo> 535 XSElementDecl annotationDecl = createAnnotationElementDecl(SchemaSymbols.ELT_ANNOTATION); 536 XSElementDecl documentationDecl = createAnnotationElementDecl(SchemaSymbols.ELT_DOCUMENTATION); 537 XSElementDecl appinfoDecl = createAnnotationElementDecl(SchemaSymbols.ELT_APPINFO); 538 539 // add global element declarations 540 fGlobalElemDecls.put(annotationDecl.fName, annotationDecl); 541 fGlobalElemDecls.put(documentationDecl.fName, documentationDecl); 542 fGlobalElemDecls.put(appinfoDecl.fName, appinfoDecl); 543 544 fGlobalElemDeclsExt.put(","+annotationDecl.fName, annotationDecl); 545 fGlobalElemDeclsExt.put(","+documentationDecl.fName, documentationDecl); 546 fGlobalElemDeclsExt.put(","+appinfoDecl.fName, appinfoDecl); 547 548 fAllGlobalElemDecls.put(annotationDecl, annotationDecl); 549 fAllGlobalElemDecls.put(documentationDecl, documentationDecl); 550 fAllGlobalElemDecls.put(appinfoDecl, appinfoDecl); 551 552 // create complex type declarations for <annotation>, <documentation> and <appinfo> 553 XSComplexTypeDecl annotationType = new XSComplexTypeDecl(); 554 XSComplexTypeDecl documentationType = new XSComplexTypeDecl(); 555 XSComplexTypeDecl appinfoType = new XSComplexTypeDecl(); 556 557 // set the types on their element declarations 558 annotationDecl.fType = annotationType; 559 documentationDecl.fType = documentationType; 560 appinfoDecl.fType = appinfoType; 561 562 // create attribute groups for <annotation>, <documentation> and <appinfo> 563 XSAttributeGroupDecl annotationAttrs = new XSAttributeGroupDecl(); 564 XSAttributeGroupDecl documentationAttrs = new XSAttributeGroupDecl(); 565 XSAttributeGroupDecl appinfoAttrs = new XSAttributeGroupDecl(); 566 567 // fill in attribute groups 568 { 569 // create and fill attribute uses for <annotation>, <documentation> and <appinfo> 570 XSAttributeUseImpl annotationIDAttr = new XSAttributeUseImpl(); 571 annotationIDAttr.fAttrDecl = new XSAttributeDecl(); 572 annotationIDAttr.fAttrDecl.setValues(SchemaSymbols.ATT_ID, null, (XSSimpleType) fGlobalTypeDecls.get(SchemaSymbols.ATTVAL_ID), 573 XSConstants.VC_NONE, XSConstants.SCOPE_LOCAL, null, annotationType, null); 574 annotationIDAttr.fUse = SchemaSymbols.USE_OPTIONAL; 575 annotationIDAttr.fConstraintType = XSConstants.VC_NONE; 576 577 XSAttributeUseImpl documentationSourceAttr = new XSAttributeUseImpl(); 578 documentationSourceAttr.fAttrDecl = new XSAttributeDecl(); 579 documentationSourceAttr.fAttrDecl.setValues(SchemaSymbols.ATT_SOURCE, null, (XSSimpleType) fGlobalTypeDecls.get(SchemaSymbols.ATTVAL_ANYURI), 580 XSConstants.VC_NONE, XSConstants.SCOPE_LOCAL, null, documentationType, null); 581 documentationSourceAttr.fUse = SchemaSymbols.USE_OPTIONAL; 582 documentationSourceAttr.fConstraintType = XSConstants.VC_NONE; 583 584 XSAttributeUseImpl documentationLangAttr = new XSAttributeUseImpl(); 585 documentationLangAttr.fAttrDecl = new XSAttributeDecl(); 586 documentationLangAttr.fAttrDecl.setValues("lang".intern(), NamespaceContext.XML_URI, (XSSimpleType) fGlobalTypeDecls.get(SchemaSymbols.ATTVAL_LANGUAGE), 587 XSConstants.VC_NONE, XSConstants.SCOPE_LOCAL, null, documentationType, null); 588 documentationLangAttr.fUse = SchemaSymbols.USE_OPTIONAL; 589 documentationLangAttr.fConstraintType = XSConstants.VC_NONE; 590 591 XSAttributeUseImpl appinfoSourceAttr = new XSAttributeUseImpl(); 592 appinfoSourceAttr.fAttrDecl = new XSAttributeDecl(); 593 appinfoSourceAttr.fAttrDecl.setValues(SchemaSymbols.ATT_SOURCE, null, (XSSimpleType) fGlobalTypeDecls.get(SchemaSymbols.ATTVAL_ANYURI), 594 XSConstants.VC_NONE, XSConstants.SCOPE_LOCAL, null, appinfoType, null); 595 appinfoSourceAttr.fUse = SchemaSymbols.USE_OPTIONAL; 596 appinfoSourceAttr.fConstraintType = XSConstants.VC_NONE; 597 598 // create lax attribute wildcard for <annotation>, <documentation> and <appinfo> 599 XSWildcardDecl otherAttrs = new XSWildcardDecl(); 600 otherAttrs.fNamespaceList = new String [] {fTargetNamespace, null}; 601 otherAttrs.fType = XSWildcard.NSCONSTRAINT_NOT; 602 otherAttrs.fProcessContents = XSWildcard.PC_LAX; 603 604 // add attribute uses and wildcards to attribute groups for <annotation>, <documentation> and <appinfo> 605 annotationAttrs.addAttributeUse(annotationIDAttr); 606 annotationAttrs.fAttributeWC = otherAttrs; 607 608 documentationAttrs.addAttributeUse(documentationSourceAttr); 609 documentationAttrs.addAttributeUse(documentationLangAttr); 610 documentationAttrs.fAttributeWC = otherAttrs; 611 612 appinfoAttrs.addAttributeUse(appinfoSourceAttr); 613 appinfoAttrs.fAttributeWC = otherAttrs; 614 } 615 616 // create particles for <annotation> 617 XSParticleDecl annotationParticle = createUnboundedModelGroupParticle(); 618 { 619 XSModelGroupImpl annotationChoice = new XSModelGroupImpl(); 620 annotationChoice.fCompositor = XSModelGroupImpl.MODELGROUP_CHOICE; 621 annotationChoice.fParticleCount = 2; 622 annotationChoice.fParticles = new XSParticleDecl[2]; 623 annotationChoice.fParticles[0] = createChoiceElementParticle(appinfoDecl); 624 annotationChoice.fParticles[1] = createChoiceElementParticle(documentationDecl); 625 annotationParticle.fValue = annotationChoice; 626 } 627 628 // create wildcard particle for <documentation> and <appinfo> 629 XSParticleDecl anyWCSequenceParticle = createUnboundedAnyWildcardSequenceParticle(); 630 631 // fill complex types 632 annotationType.setValues("#AnonType_" + SchemaSymbols.ELT_ANNOTATION, fTargetNamespace, SchemaGrammar.fAnyType, 633 XSConstants.DERIVATION_RESTRICTION, XSConstants.DERIVATION_NONE, (short) (XSConstants.DERIVATION_EXTENSION | XSConstants.DERIVATION_RESTRICTION), 634 XSComplexTypeDecl.CONTENTTYPE_ELEMENT, false, annotationAttrs, null, annotationParticle, XSObjectListImpl.EMPTY_LIST); 635 annotationType.setName("#AnonType_" + SchemaSymbols.ELT_ANNOTATION); 636 annotationType.setIsAnonymous(); 637 638 documentationType.setValues("#AnonType_" + SchemaSymbols.ELT_DOCUMENTATION, fTargetNamespace, SchemaGrammar.fAnyType, 639 XSConstants.DERIVATION_RESTRICTION, XSConstants.DERIVATION_NONE, (short) (XSConstants.DERIVATION_EXTENSION | XSConstants.DERIVATION_RESTRICTION), 640 XSComplexTypeDecl.CONTENTTYPE_MIXED, false, documentationAttrs, null, anyWCSequenceParticle, XSObjectListImpl.EMPTY_LIST); 641 documentationType.setName("#AnonType_" + SchemaSymbols.ELT_DOCUMENTATION); 642 documentationType.setIsAnonymous(); 643 644 appinfoType.setValues("#AnonType_" + SchemaSymbols.ELT_APPINFO, fTargetNamespace, SchemaGrammar.fAnyType, 645 XSConstants.DERIVATION_RESTRICTION, XSConstants.DERIVATION_NONE, (short) (XSConstants.DERIVATION_EXTENSION | XSConstants.DERIVATION_RESTRICTION), 646 XSComplexTypeDecl.CONTENTTYPE_MIXED, false, appinfoAttrs, null, anyWCSequenceParticle, XSObjectListImpl.EMPTY_LIST); 647 appinfoType.setName("#AnonType_" + SchemaSymbols.ELT_APPINFO); 648 appinfoType.setIsAnonymous(); 649 650 } // <init>(int) 651 652 // return the XMLGrammarDescription corresponding to this 653 // object 654 public XMLGrammarDescription getGrammarDescription() { 655 return fGrammarDescription.makeClone(); 656 } // getGrammarDescription(): XMLGrammarDescription 657 658 // override these methods solely so that these 659 // objects cannot be modified once they're created. 660 public void setImportedGrammars(Vector importedGrammars) { 661 // ignore 662 } 663 public void addGlobalAttributeDecl(XSAttributeDecl decl) { 664 // ignore 665 } 666 public void addGlobalAttributeDecl(XSAttributeGroupDecl decl, String location) { 667 // ignore 668 } 669 public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl) { 670 // ignore 671 } 672 public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl, String location) { 673 // ignore 674 } 675 public void addGlobalElementDecl(XSElementDecl decl) { 676 // ignore 677 } 678 public void addGlobalElementDecl(XSElementDecl decl, String location) { 679 // ignore 680 } 681 public void addGlobalElementDeclAll(XSElementDecl decl) { 682 // ignore 683 } 684 public void addGlobalGroupDecl(XSGroupDecl decl) { 685 // ignore 686 } 687 public void addGlobalGroupDecl(XSGroupDecl decl, String location) { 688 // ignore 689 } 690 public void addGlobalNotationDecl(XSNotationDecl decl) { 691 // ignore 692 } 693 public void addGlobalNotationDecl(XSNotationDecl decl, String location) { 694 // ignore 695 } 696 public void addGlobalTypeDecl(XSTypeDefinition decl) { 697 // ignore 698 } 699 public void addGlobalTypeDecl(XSTypeDefinition decl, String location) { 700 // ignore 701 } 702 public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl) { 703 // ignore 704 } 705 public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl, String location) { 706 // ignore 707 } 708 public void addGlobalSimpleTypeDecl(XSSimpleType decl) { 709 // ignore 710 } 711 public void addGlobalSimpleTypeDecl(XSSimpleType decl, String location) { 712 // ignore 713 } 714 public void addComplexTypeDecl(XSComplexTypeDecl decl, SimpleLocator locator) { 715 // ignore 716 } 717 public void addRedefinedGroupDecl(XSGroupDecl derived, XSGroupDecl base, SimpleLocator locator) { 718 // ignore 719 } 720 public synchronized void addDocument(Object document, String location) { 721 // ignore 722 } 723 724 // annotation support 725 synchronized DOMParser getDOMParser() { 726 return null; 727 } 728 synchronized SAXParser getSAXParser() { 729 return null; 730 } 731 732 // 733 // private helper methods 734 // 735 736 private XSElementDecl createAnnotationElementDecl(String localName) { 737 XSElementDecl eDecl = new XSElementDecl(); 738 eDecl.fName = localName; 739 eDecl.fTargetNamespace = fTargetNamespace; 740 eDecl.setIsGlobal(); 741 eDecl.fBlock = (XSConstants.DERIVATION_EXTENSION | 742 XSConstants.DERIVATION_RESTRICTION | XSConstants.DERIVATION_SUBSTITUTION); 743 eDecl.setConstraintType(XSConstants.VC_NONE); 744 return eDecl; 745 } 746 747 private XSParticleDecl createUnboundedModelGroupParticle() { 748 XSParticleDecl particle = new XSParticleDecl(); 749 particle.fMinOccurs = 0; 750 particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED; 751 particle.fType = XSParticleDecl.PARTICLE_MODELGROUP; 752 return particle; 753 } 754 755 private XSParticleDecl createChoiceElementParticle(XSElementDecl ref) { 756 XSParticleDecl particle = new XSParticleDecl(); 757 particle.fMinOccurs = 1; 758 particle.fMaxOccurs = 1; 759 particle.fType = XSParticleDecl.PARTICLE_ELEMENT; 760 particle.fValue = ref; 761 return particle; 762 } 763 764 private XSParticleDecl createUnboundedAnyWildcardSequenceParticle() { 765 XSParticleDecl particle = createUnboundedModelGroupParticle(); 766 XSModelGroupImpl sequence = new XSModelGroupImpl(); 767 sequence.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE; 768 sequence.fParticleCount = 1; 769 sequence.fParticles = new XSParticleDecl[1]; 770 sequence.fParticles[0] = createAnyLaxWildcardParticle(); 771 particle.fValue = sequence; 772 return particle; 773 } 774 775 private XSParticleDecl createAnyLaxWildcardParticle() { 776 XSParticleDecl particle = new XSParticleDecl(); 777 particle.fMinOccurs = 1; 778 particle.fMaxOccurs = 1; 779 particle.fType = XSParticleDecl.PARTICLE_WILDCARD; 780 781 XSWildcardDecl anyWC = new XSWildcardDecl(); 782 anyWC.fNamespaceList = null; 783 anyWC.fType = XSWildcard.NSCONSTRAINT_ANY; 784 anyWC.fProcessContents = XSWildcard.PC_LAX; 785 786 particle.fValue = anyWC; 787 return particle; 788 } 789 } 790 791 // Grammar methods 792 793 // return the XMLGrammarDescription corresponding to this 794 // object 795 public XMLGrammarDescription getGrammarDescription() { 796 return fGrammarDescription; 797 } // getGrammarDescription(): XMLGrammarDescription 798 799 // DTDGrammar methods 800 public boolean isNamespaceAware () { 801 return true; 802 } // isNamespaceAware():boolean 803 804 Vector fImported = null; 805 806 public void setImportedGrammars(Vector importedGrammars) { 807 fImported = importedGrammars; 808 } 809 810 public Vector getImportedGrammars() { 811 return fImported; 812 } 813 814 /** 815 * Returns this grammar's target namespace. 816 */ 817 public final String getTargetNamespace() { 818 return fTargetNamespace; 819 } // getTargetNamespace():String 820 821 /** 822 * register one global attribute 823 */ 824 public void addGlobalAttributeDecl(XSAttributeDecl decl) { 825 fGlobalAttrDecls.put(decl.fName, decl); 826 decl.setNamespaceItem(this); 827 } 828 829 public void addGlobalAttributeDecl(XSAttributeDecl decl, String location) { 830 fGlobalAttrDeclsExt.put(((location!=null) ? location : "") + "," + decl.fName, decl); 831 if (decl.getNamespaceItem() == null) { 832 decl.setNamespaceItem(this); 833 } 834 } 835 836 /** 837 * register one global attribute group 838 */ 839 public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl) { 840 fGlobalAttrGrpDecls.put(decl.fName, decl); 841 decl.setNamespaceItem(this); 842 } 843 844 public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl, String location) { 845 fGlobalAttrGrpDeclsExt.put(((location!=null) ? location : "") + "," + decl.fName, decl); 846 if (decl.getNamespaceItem() == null) { 847 decl.setNamespaceItem(this); 848 } 849 } 850 851 /** 852 * register one global element 853 */ 854 public void addGlobalElementDeclAll(XSElementDecl decl) { 855 if (fAllGlobalElemDecls.get(decl) == null) { 856 fAllGlobalElemDecls.put(decl, decl); 857 // if there is a substitution group affiliation, store in an array, 858 // for further constraint checking: UPA, PD, EDC 859 if (decl.fSubGroup != null) { 860 if (fSubGroupCount == fSubGroups.length) 861 fSubGroups = resize(fSubGroups, fSubGroupCount+INC_SIZE); 862 fSubGroups[fSubGroupCount++] = decl; 863 } 864 } 865 } 866 867 public void addGlobalElementDecl(XSElementDecl decl) { 868 fGlobalElemDecls.put(decl.fName, decl); 869 decl.setNamespaceItem(this); 870 } 871 872 public void addGlobalElementDecl(XSElementDecl decl, String location) { 873 fGlobalElemDeclsExt.put(((location != null) ? location : "") + "," + decl.fName, decl); 874 if (decl.getNamespaceItem() == null) { 875 decl.setNamespaceItem(this); 876 } 877 } 878 879 /** 880 * register one global group 881 */ 882 public void addGlobalGroupDecl(XSGroupDecl decl) { 883 fGlobalGroupDecls.put(decl.fName, decl); 884 decl.setNamespaceItem(this); 885 } 886 887 public void addGlobalGroupDecl(XSGroupDecl decl, String location) { 888 fGlobalGroupDeclsExt.put(((location!=null) ? location : "") + "," + decl.fName, decl); 889 if (decl.getNamespaceItem() == null) { 890 decl.setNamespaceItem(this); 891 } 892 } 893 894 /** 895 * register one global notation 896 */ 897 public void addGlobalNotationDecl(XSNotationDecl decl) { 898 fGlobalNotationDecls.put(decl.fName, decl); 899 decl.setNamespaceItem(this); 900 } 901 902 public void addGlobalNotationDecl(XSNotationDecl decl, String location) { 903 fGlobalNotationDeclsExt.put(((location!=null) ? location : "") + "," +decl.fName, decl); 904 if (decl.getNamespaceItem() == null) { 905 decl.setNamespaceItem(this); 906 } 907 } 908 909 /** 910 * register one global type 911 */ 912 public void addGlobalTypeDecl(XSTypeDefinition decl) { 913 fGlobalTypeDecls.put(decl.getName(), decl); 914 if (decl instanceof XSComplexTypeDecl) { 915 ((XSComplexTypeDecl) decl).setNamespaceItem(this); 916 } 917 else if (decl instanceof XSSimpleTypeDecl) { 918 ((XSSimpleTypeDecl) decl).setNamespaceItem(this); 919 } 920 } 921 922 public void addGlobalTypeDecl(XSTypeDefinition decl, String location) { 923 fGlobalTypeDeclsExt.put(((location!=null) ? location : "") + "," + decl.getName(), decl); 924 if (decl.getNamespaceItem() == null) { 925 if (decl instanceof XSComplexTypeDecl) { 926 ((XSComplexTypeDecl) decl).setNamespaceItem(this); 927 } 928 else if (decl instanceof XSSimpleTypeDecl) { 929 ((XSSimpleTypeDecl) decl).setNamespaceItem(this); 930 } 931 } 932 } 933 934 /** 935 * register one global complex type 936 */ 937 public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl) { 938 fGlobalTypeDecls.put(decl.getName(), decl); 939 decl.setNamespaceItem(this); 940 } 941 942 public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl, String location) { 943 fGlobalTypeDeclsExt.put(((location!=null) ? location : "") + "," + decl.getName(), decl); 944 if (decl.getNamespaceItem() == null) { 945 decl.setNamespaceItem(this); 946 } 947 } 948 949 /** 950 * register one global simple type 951 */ 952 public void addGlobalSimpleTypeDecl(XSSimpleType decl) { 953 fGlobalTypeDecls.put(decl.getName(), decl); 954 if (decl instanceof XSSimpleTypeDecl) { 955 ((XSSimpleTypeDecl) decl).setNamespaceItem(this); 956 } 957 } 958 959 public void addGlobalSimpleTypeDecl(XSSimpleType decl, String location) { 960 fGlobalTypeDeclsExt.put(((location != null) ? location : "") + "," + decl.getName(), decl); 961 if (decl.getNamespaceItem() == null && decl instanceof XSSimpleTypeDecl) { 962 ((XSSimpleTypeDecl) decl).setNamespaceItem(this); 963 } 964 } 965 966 /** 967 * register one identity constraint 968 */ 969 public final void addIDConstraintDecl(XSElementDecl elmDecl, IdentityConstraint decl) { 970 elmDecl.addIDConstraint(decl); 971 fGlobalIDConstraintDecls.put(decl.getIdentityConstraintName(), decl); 972 } 973 974 public final void addIDConstraintDecl(XSElementDecl elmDecl, IdentityConstraint decl, String location) { 975 fGlobalIDConstraintDeclsExt.put(((location != null) ? location : "") + "," + decl.getIdentityConstraintName(), decl); 976 } 977 978 /** 979 * get one global attribute 980 */ 981 public final XSAttributeDecl getGlobalAttributeDecl(String declName) { 982 return(XSAttributeDecl)fGlobalAttrDecls.get(declName); 983 } 984 985 public final XSAttributeDecl getGlobalAttributeDecl(String declName, String location) { 986 return(XSAttributeDecl)fGlobalAttrDeclsExt.get(((location != null) ? location : "") + "," + declName); 987 } 988 989 /** 990 * get one global attribute group 991 */ 992 public final XSAttributeGroupDecl getGlobalAttributeGroupDecl(String declName) { 993 return(XSAttributeGroupDecl)fGlobalAttrGrpDecls.get(declName); 994 } 995 996 public final XSAttributeGroupDecl getGlobalAttributeGroupDecl(String declName, String location) { 997 return(XSAttributeGroupDecl)fGlobalAttrGrpDeclsExt.get(((location != null) ? location : "") + "," + declName); 998 } 999 1000 /** 1001 * get one global element 1002 */ 1003 public final XSElementDecl getGlobalElementDecl(String declName) { 1004 return(XSElementDecl)fGlobalElemDecls.get(declName); 1005 } 1006 1007 public final XSElementDecl getGlobalElementDecl(String declName, String location) { 1008 return(XSElementDecl)fGlobalElemDeclsExt.get(((location != null) ? location : "") + "," + declName); 1009 } 1010 1011 /** 1012 * get one global group 1013 */ 1014 public final XSGroupDecl getGlobalGroupDecl(String declName) { 1015 return(XSGroupDecl)fGlobalGroupDecls.get(declName); 1016 } 1017 1018 public final XSGroupDecl getGlobalGroupDecl(String declName, String location) { 1019 return(XSGroupDecl)fGlobalGroupDeclsExt.get(((location != null) ? location : "") + "," + declName); 1020 } 1021 1022 /** 1023 * get one global notation 1024 */ 1025 public final XSNotationDecl getGlobalNotationDecl(String declName) { 1026 return(XSNotationDecl)fGlobalNotationDecls.get(declName); 1027 } 1028 1029 public final XSNotationDecl getGlobalNotationDecl(String declName, String location) { 1030 return(XSNotationDecl)fGlobalNotationDeclsExt.get(((location != null) ? location : "") + "," + declName); 1031 } 1032 1033 /** 1034 * get one global type 1035 */ 1036 public final XSTypeDefinition getGlobalTypeDecl(String declName) { 1037 return(XSTypeDefinition)fGlobalTypeDecls.get(declName); 1038 } 1039 1040 public final XSTypeDefinition getGlobalTypeDecl(String declName, String location) { 1041 return(XSTypeDefinition)fGlobalTypeDeclsExt.get(((location != null) ? location : "") + "," + declName); 1042 } 1043 1044 /** 1045 * get one identity constraint 1046 */ 1047 public final IdentityConstraint getIDConstraintDecl(String declName) { 1048 return(IdentityConstraint)fGlobalIDConstraintDecls.get(declName); 1049 } 1050 1051 public final IdentityConstraint getIDConstraintDecl(String declName, String location) { 1052 return(IdentityConstraint)fGlobalIDConstraintDeclsExt.get(((location != null) ? location : "") + "," + declName); 1053 } 1054 1055 /** 1056 * get one identity constraint 1057 */ 1058 public final boolean hasIDConstraints() { 1059 return fGlobalIDConstraintDecls.getLength() > 0; 1060 } 1061 1062 // array to store complex type decls 1063 private static final int INITIAL_SIZE = 16; 1064 private static final int INC_SIZE = 16; 1065 1066 private int fCTCount = 0; 1067 private XSComplexTypeDecl[] fComplexTypeDecls = new XSComplexTypeDecl[INITIAL_SIZE]; 1068 private SimpleLocator[] fCTLocators = new SimpleLocator[INITIAL_SIZE]; 1069 1070 // an array to store groups being redefined by restriction 1071 // even-numbered elements are the derived groups, odd-numbered ones their bases 1072 private static final int REDEFINED_GROUP_INIT_SIZE = 2; 1073 private int fRGCount = 0; 1074 private XSGroupDecl[] fRedefinedGroupDecls = new XSGroupDecl[REDEFINED_GROUP_INIT_SIZE]; 1075 private SimpleLocator[] fRGLocators = new SimpleLocator[REDEFINED_GROUP_INIT_SIZE/2]; 1076 1077 // a flag to indicate whether we have checked the 3 constraints on this 1078 // grammar. 1079 boolean fFullChecked = false; 1080 1081 /** 1082 * add one complex type decl: for later constraint checking 1083 */ 1084 public void addComplexTypeDecl(XSComplexTypeDecl decl, SimpleLocator locator) { 1085 if (fCTCount == fComplexTypeDecls.length) { 1086 fComplexTypeDecls = resize(fComplexTypeDecls, fCTCount+INC_SIZE); 1087 fCTLocators = resize(fCTLocators, fCTCount+INC_SIZE); 1088 } 1089 fCTLocators[fCTCount] = locator; 1090 fComplexTypeDecls[fCTCount++] = decl; 1091 } 1092 1093 /** 1094 * add a group redefined by restriction: for later constraint checking 1095 */ 1096 public void addRedefinedGroupDecl(XSGroupDecl derived, XSGroupDecl base, SimpleLocator locator) { 1097 if (fRGCount == fRedefinedGroupDecls.length) { 1098 // double array size each time. 1099 fRedefinedGroupDecls = resize(fRedefinedGroupDecls, fRGCount << 1); 1100 fRGLocators = resize(fRGLocators, fRGCount); 1101 } 1102 fRGLocators[fRGCount/2] = locator; 1103 fRedefinedGroupDecls[fRGCount++] = derived; 1104 fRedefinedGroupDecls[fRGCount++] = base; 1105 } 1106 1107 /** 1108 * get all complex type decls: for later constraint checking 1109 */ 1110 final XSComplexTypeDecl[] getUncheckedComplexTypeDecls() { 1111 if (fCTCount < fComplexTypeDecls.length) { 1112 fComplexTypeDecls = resize(fComplexTypeDecls, fCTCount); 1113 fCTLocators = resize(fCTLocators, fCTCount); 1114 } 1115 return fComplexTypeDecls; 1116 } 1117 1118 /** 1119 * get the error locator of all complex type decls 1120 */ 1121 final SimpleLocator[] getUncheckedCTLocators() { 1122 if (fCTCount < fCTLocators.length) { 1123 fComplexTypeDecls = resize(fComplexTypeDecls, fCTCount); 1124 fCTLocators = resize(fCTLocators, fCTCount); 1125 } 1126 return fCTLocators; 1127 } 1128 1129 /** 1130 * get all redefined groups: for later constraint checking 1131 */ 1132 final XSGroupDecl[] getRedefinedGroupDecls() { 1133 if (fRGCount < fRedefinedGroupDecls.length) { 1134 fRedefinedGroupDecls = resize(fRedefinedGroupDecls, fRGCount); 1135 fRGLocators = resize(fRGLocators, fRGCount/2); 1136 } 1137 return fRedefinedGroupDecls; 1138 } 1139 1140 /** 1141 * get the error locator of all redefined groups 1142 */ 1143 final SimpleLocator[] getRGLocators() { 1144 if (fRGCount < fRedefinedGroupDecls.length) { 1145 fRedefinedGroupDecls = resize(fRedefinedGroupDecls, fRGCount); 1146 fRGLocators = resize(fRGLocators, fRGCount/2); 1147 } 1148 return fRGLocators; 1149 } 1150 1151 /** 1152 * after the first-round checking, some types don't need to be checked 1153 * against UPA again. here we trim the array to the proper size. 1154 */ 1155 final void setUncheckedTypeNum(int newSize) { 1156 fCTCount = newSize; 1157 fComplexTypeDecls = resize(fComplexTypeDecls, fCTCount); 1158 fCTLocators = resize(fCTLocators, fCTCount); 1159 } 1160 1161 // used to store all substitution group information declared in 1162 // this namespace 1163 private int fSubGroupCount = 0; 1164 private XSElementDecl[] fSubGroups = new XSElementDecl[INITIAL_SIZE]; 1165 1166 /** 1167 * get all substitution group information: for the 3 constraint checking 1168 */ 1169 final XSElementDecl[] getSubstitutionGroups() { 1170 if (fSubGroupCount < fSubGroups.length) 1171 fSubGroups = resize(fSubGroups, fSubGroupCount); 1172 return fSubGroups; 1173 } 1174 1175 // anyType and anySimpleType: because there are so many places where 1176 // we need direct access to these two types 1177 public final static XSComplexTypeDecl fAnyType = new XSAnyType(); 1178 private static class XSAnyType extends XSComplexTypeDecl { 1179 public XSAnyType () { 1180 fName = SchemaSymbols.ATTVAL_ANYTYPE; 1181 super.fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA; 1182 fBaseType = this; 1183 fDerivedBy = XSConstants.DERIVATION_RESTRICTION; 1184 fContentType = XSComplexTypeDecl.CONTENTTYPE_MIXED; 1185 1186 fParticle = createParticle(); 1187 fAttrGrp = createAttrGrp(); 1188 } 1189 1190 // overridden methods 1191 public void setValues(String name, String targetNamespace, 1192 XSTypeDefinition baseType, short derivedBy, short schemaFinal, 1193 short block, short contentType, 1194 boolean isAbstract, XSAttributeGroupDecl attrGrp, 1195 XSSimpleType simpleType, XSParticleDecl particle) { 1196 // don't allow this. 1197 } 1198 1199 public void setName(String name){ 1200 // don't allow this. 1201 } 1202 1203 public void setIsAbstractType() { 1204 // null implementation 1205 } 1206 1207 public void setContainsTypeID() { 1208 // null implementation 1209 } 1210 1211 public void setIsAnonymous() { 1212 // null implementation 1213 } 1214 1215 public void reset() { 1216 // null implementation 1217 } 1218 1219 public XSObjectList getAnnotations() { 1220 return XSObjectListImpl.EMPTY_LIST; 1221 } 1222 1223 public XSNamespaceItem getNamespaceItem() { 1224 return SG_SchemaNS; 1225 } 1226 1227 private XSAttributeGroupDecl createAttrGrp() { 1228 XSWildcardDecl wildcard = new XSWildcardDecl(); 1229 wildcard.fProcessContents = XSWildcardDecl.PC_LAX; 1230 XSAttributeGroupDecl attrGrp = new XSAttributeGroupDecl(); 1231 attrGrp.fAttributeWC = wildcard; 1232 return attrGrp; 1233 } 1234 1235 private XSParticleDecl createParticle() { 1236 // the wildcard used in anyType (content and attribute) 1237 // the spec will change strict to skip for anyType 1238 XSWildcardDecl wildcard = new XSWildcardDecl(); 1239 wildcard.fProcessContents = XSWildcardDecl.PC_LAX; 1240 // the particle for the content wildcard 1241 XSParticleDecl particleW = new XSParticleDecl(); 1242 particleW.fMinOccurs = 0; 1243 particleW.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED; 1244 particleW.fType = XSParticleDecl.PARTICLE_WILDCARD; 1245 particleW.fValue = wildcard; 1246 // the model group of a sequence of the above particle 1247 XSModelGroupImpl group = new XSModelGroupImpl(); 1248 group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE; 1249 group.fParticleCount = 1; 1250 group.fParticles = new XSParticleDecl[1]; 1251 group.fParticles[0] = particleW; 1252 // the content of anyType: particle of the above model group 1253 XSParticleDecl particleG = new XSParticleDecl(); 1254 particleG.fType = XSParticleDecl.PARTICLE_MODELGROUP; 1255 particleG.fValue = group; 1256 1257 return particleG; 1258 } 1259 } 1260 private static class BuiltinAttrDecl extends XSAttributeDecl { 1261 public BuiltinAttrDecl(String name, String tns, 1262 XSSimpleType type, short scope) { 1263 fName = name; 1264 super.fTargetNamespace = tns; 1265 fType = type; 1266 fScope = scope; 1267 } 1268 1269 public void setValues(String name, String targetNamespace, 1270 XSSimpleType simpleType, short constraintType, short scope, 1271 ValidatedInfo valInfo, XSComplexTypeDecl enclosingCT) { 1272 // ignore this call. 1273 } 1274 1275 public void reset () { 1276 // also ignore this call. 1277 } 1278 1279 public XSAnnotation getAnnotation() { 1280 return null; 1281 } 1282 1283 public XSNamespaceItem getNamespaceItem() { 1284 return SG_XSI; 1285 } 1286 1287 } // class BuiltinAttrDecl 1288 1289 // the grammars to hold components of the schema namespace 1290 public final static BuiltinSchemaGrammar SG_SchemaNS = new BuiltinSchemaGrammar(GRAMMAR_XS, Constants.SCHEMA_VERSION_1_0); 1291 private final static BuiltinSchemaGrammar SG_SchemaNSExtended = new BuiltinSchemaGrammar(GRAMMAR_XS, Constants.SCHEMA_VERSION_1_0_EXTENDED); 1292 1293 public final static XSSimpleType fAnySimpleType = (XSSimpleType)SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE); 1294 1295 // the grammars to hold components of the schema-instance namespace 1296 public final static BuiltinSchemaGrammar SG_XSI = new BuiltinSchemaGrammar(GRAMMAR_XSI, Constants.SCHEMA_VERSION_1_0); 1297 1298 public static SchemaGrammar getS4SGrammar(short schemaVersion) { 1299 if (schemaVersion == Constants.SCHEMA_VERSION_1_0) { 1300 return SG_SchemaNS; 1301 } 1302 else { 1303 return SG_SchemaNSExtended; 1304 } 1305 } 1306 1307 static final XSComplexTypeDecl[] resize(XSComplexTypeDecl[] oldArray, int newSize) { 1308 XSComplexTypeDecl[] newArray = new XSComplexTypeDecl[newSize]; 1309 System.arraycopy(oldArray, 0, newArray, 0, Math.min(oldArray.length, newSize)); 1310 return newArray; 1311 } 1312 1313 static final XSGroupDecl[] resize(XSGroupDecl[] oldArray, int newSize) { 1314 XSGroupDecl[] newArray = new XSGroupDecl[newSize]; 1315 System.arraycopy(oldArray, 0, newArray, 0, Math.min(oldArray.length, newSize)); 1316 return newArray; 1317 } 1318 1319 static final XSElementDecl[] resize(XSElementDecl[] oldArray, int newSize) { 1320 XSElementDecl[] newArray = new XSElementDecl[newSize]; 1321 System.arraycopy(oldArray, 0, newArray, 0, Math.min(oldArray.length, newSize)); 1322 return newArray; 1323 } 1324 1325 static final SimpleLocator[] resize(SimpleLocator[] oldArray, int newSize) { 1326 SimpleLocator[] newArray = new SimpleLocator[newSize]; 1327 System.arraycopy(oldArray, 0, newArray, 0, Math.min(oldArray.length, newSize)); 1328 return newArray; 1329 } 1330 1331 // XSNamespaceItem methods 1332 1333 // the max index / the max value of XSObject type 1334 private static final short MAX_COMP_IDX = XSTypeDefinition.SIMPLE_TYPE; 1335 private static final boolean[] GLOBAL_COMP = {false, // null 1336 true, // attribute 1337 true, // element 1338 true, // type 1339 false, // attribute use 1340 true, // attribute group 1341 true, // group 1342 false, // model group 1343 false, // particle 1344 false, // wildcard 1345 true, // idc 1346 true, // notation 1347 false, // annotation 1348 false, // facet 1349 false, // multi value facet 1350 true, // complex type 1351 true // simple type 1352 }; 1353 1354 // store a certain kind of components from all namespaces 1355 private XSNamedMap[] fComponents = null; 1356 private ObjectList[] fComponentsExt = null; 1357 1358 // store the documents and their locations contributing to this namespace 1359 // REVISIT: use StringList and XSObjectList for there fields. 1360 private Vector fDocuments = null; 1361 private Vector fLocations = null; 1362 1363 public synchronized void addDocument(Object document, String location) { 1364 if (fDocuments == null) { 1365 fDocuments = new Vector(); 1366 fLocations = new Vector(); 1367 } 1368 fDocuments.addElement(document); 1369 fLocations.addElement(location); 1370 } 1371 1372 public synchronized void removeDocument(int index) { 1373 if (fDocuments != null && 1374 index >= 0 && 1375 index < fDocuments.size()) { 1376 fDocuments.removeElementAt(index); 1377 fLocations.removeElementAt(index); 1378 } 1379 } 1380 1381 /** 1382 * [schema namespace] 1383 * @see <a href="http://www.w3.org/TR/xmlschema-1/#nsi-schema_namespace">[schema namespace]</a> 1384 * @return The target namespace of this item. 1385 */ 1386 public String getSchemaNamespace() { 1387 return fTargetNamespace; 1388 } 1389 1390 // annotation support 1391 synchronized DOMParser getDOMParser() { 1392 if (fDOMParser != null) { 1393 DOMParser parser = (DOMParser) fDOMParser.get(); 1394 if (parser != null) { 1395 return parser; 1396 } 1397 } 1398 // REVISIT: when schema handles XML 1.1, will need to 1399 // revisit this (and the practice of not prepending an XML decl to the annotation string 1400 XML11Configuration config = new XML11Configuration(fSymbolTable); 1401 // note that this should never produce errors or require 1402 // entity resolution, so just a barebones configuration with 1403 // a couple of feature set will do fine 1404 config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true); 1405 config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE, false); 1406 1407 DOMParser parser = new DOMParser(config); 1408 try { 1409 parser.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.DEFER_NODE_EXPANSION_FEATURE, false); 1410 } 1411 catch (SAXException exc) {} 1412 fDOMParser = new SoftReference(parser); 1413 return parser; 1414 } 1415 1416 synchronized SAXParser getSAXParser() { 1417 if (fSAXParser != null) { 1418 SAXParser parser = (SAXParser) fSAXParser.get(); 1419 if (parser != null) { 1420 return parser; 1421 } 1422 } 1423 // REVISIT: when schema handles XML 1.1, will need to 1424 // revisit this (and the practice of not prepending an XML decl to the annotation string 1425 XML11Configuration config = new XML11Configuration(fSymbolTable); 1426 // note that this should never produce errors or require 1427 // entity resolution, so just a barebones configuration with 1428 // a couple of feature set will do fine 1429 config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true); 1430 config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE, false); 1431 SAXParser parser = new SAXParser(config); 1432 fSAXParser = new SoftReference(parser); 1433 return parser; 1434 } 1435 1436 /** 1437 * [schema components]: a list of top-level components, i.e. element 1438 * declarations, attribute declarations, etc. 1439 * @param objectType The type of the declaration, i.e. 1440 * <code>ELEMENT_DECLARATION</code>. Note that 1441 * <code>XSTypeDefinition.SIMPLE_TYPE</code> and 1442 * <code>XSTypeDefinition.COMPLEX_TYPE</code> can also be used as the 1443 * <code>objectType</code> to retrieve only complex types or simple 1444 * types, instead of all types. 1445 * @return A list of top-level definition of the specified type in 1446 * <code>objectType</code> or an empty <code>XSNamedMap</code> if no 1447 * such definitions exist. 1448 */ 1449 public synchronized XSNamedMap getComponents(short objectType) { 1450 if (objectType <= 0 || objectType > MAX_COMP_IDX || 1451 !GLOBAL_COMP[objectType]) { 1452 return XSNamedMapImpl.EMPTY_MAP; 1453 } 1454 1455 if (fComponents == null) 1456 fComponents = new XSNamedMap[MAX_COMP_IDX+1]; 1457 1458 // get the hashtable for this type of components 1459 if (fComponents[objectType] == null) { 1460 SymbolHash table = null; 1461 switch (objectType) { 1462 case XSConstants.TYPE_DEFINITION: 1463 case XSTypeDefinition.COMPLEX_TYPE: 1464 case XSTypeDefinition.SIMPLE_TYPE: 1465 table = fGlobalTypeDecls; 1466 break; 1467 case XSConstants.ATTRIBUTE_DECLARATION: 1468 table = fGlobalAttrDecls; 1469 break; 1470 case XSConstants.ELEMENT_DECLARATION: 1471 table = fGlobalElemDecls; 1472 break; 1473 case XSConstants.ATTRIBUTE_GROUP: 1474 table = fGlobalAttrGrpDecls; 1475 break; 1476 case XSConstants.MODEL_GROUP_DEFINITION: 1477 table = fGlobalGroupDecls; 1478 break; 1479 case XSConstants.NOTATION_DECLARATION: 1480 table = fGlobalNotationDecls; 1481 break; 1482 case XSConstants.IDENTITY_CONSTRAINT: 1483 table = this.fGlobalIDConstraintDecls; 1484 break; 1485 } 1486 1487 // for complex/simple types, create a special implementation, 1488 // which take specific types out of the hash table 1489 if (objectType == XSTypeDefinition.COMPLEX_TYPE || 1490 objectType == XSTypeDefinition.SIMPLE_TYPE) { 1491 fComponents[objectType] = new XSNamedMap4Types(fTargetNamespace, table, objectType); 1492 } 1493 else { 1494 fComponents[objectType] = new XSNamedMapImpl(fTargetNamespace, table); 1495 } 1496 } 1497 1498 return fComponents[objectType]; 1499 } 1500 1501 public synchronized ObjectList getComponentsExt(short objectType) { 1502 if (objectType <= 0 || objectType > MAX_COMP_IDX || 1503 !GLOBAL_COMP[objectType]) { 1504 return ObjectListImpl.EMPTY_LIST; 1505 } 1506 1507 if (fComponentsExt == null) 1508 fComponentsExt = new ObjectList[MAX_COMP_IDX+1]; 1509 1510 // get the hashtable for this type of components 1511 if (fComponentsExt[objectType] == null) { 1512 SymbolHash table = null; 1513 switch (objectType) { 1514 case XSConstants.TYPE_DEFINITION: 1515 case XSTypeDefinition.COMPLEX_TYPE: 1516 case XSTypeDefinition.SIMPLE_TYPE: 1517 table = fGlobalTypeDeclsExt; 1518 break; 1519 case XSConstants.ATTRIBUTE_DECLARATION: 1520 table = fGlobalAttrDeclsExt; 1521 break; 1522 case XSConstants.ELEMENT_DECLARATION: 1523 table = fGlobalElemDeclsExt; 1524 break; 1525 case XSConstants.ATTRIBUTE_GROUP: 1526 table = fGlobalAttrGrpDeclsExt; 1527 break; 1528 case XSConstants.MODEL_GROUP_DEFINITION: 1529 table = fGlobalGroupDeclsExt; 1530 break; 1531 case XSConstants.NOTATION_DECLARATION: 1532 table = fGlobalNotationDeclsExt; 1533 break; 1534 case XSConstants.IDENTITY_CONSTRAINT: 1535 table = this.fGlobalIDConstraintDeclsExt; 1536 break; 1537 } 1538 1539 Object[] entries = table.getEntries(); 1540 fComponentsExt[objectType] = new ObjectListImpl(entries, entries.length); 1541 } 1542 1543 return fComponentsExt[objectType]; 1544 } 1545 1546 public synchronized void resetComponents() { 1547 fComponents = null; 1548 fComponentsExt = null; 1549 } 1550 1551 /** 1552 * Convenience method. Returns a top-level simple or complex type 1553 * definition. 1554 * @param name The name of the definition. 1555 * @return An <code>XSTypeDefinition</code> or null if such definition 1556 * does not exist. 1557 */ 1558 public XSTypeDefinition getTypeDefinition(String name) { 1559 return getGlobalTypeDecl(name); 1560 } 1561 1562 /** 1563 * Convenience method. Returns a top-level attribute declaration. 1564 * @param name The name of the declaration. 1565 * @return A top-level attribute declaration or null if such declaration 1566 * does not exist. 1567 */ 1568 public XSAttributeDeclaration getAttributeDeclaration(String name) { 1569 return getGlobalAttributeDecl(name); 1570 } 1571 1572 /** 1573 * Convenience method. Returns a top-level element declaration. 1574 * @param name The name of the declaration. 1575 * @return A top-level element declaration or null if such declaration 1576 * does not exist. 1577 */ 1578 public XSElementDeclaration getElementDeclaration(String name) { 1579 return getGlobalElementDecl(name); 1580 } 1581 1582 /** 1583 * Convenience method. Returns a top-level attribute group definition. 1584 * @param name The name of the definition. 1585 * @return A top-level attribute group definition or null if such 1586 * definition does not exist. 1587 */ 1588 public XSAttributeGroupDefinition getAttributeGroup(String name) { 1589 return getGlobalAttributeGroupDecl(name); 1590 } 1591 1592 /** 1593 * Convenience method. Returns a top-level model group definition. 1594 * 1595 * @param name The name of the definition. 1596 * @return A top-level model group definition definition or null if such 1597 * definition does not exist. 1598 */ 1599 public XSModelGroupDefinition getModelGroupDefinition(String name) { 1600 return getGlobalGroupDecl(name); 1601 } 1602 1603 /** 1604 * Convenience method. Returns a top-level notation declaration. 1605 * 1606 * @param name The name of the declaration. 1607 * @return A top-level notation declaration or null if such declaration 1608 * does not exist. 1609 */ 1610 public XSNotationDeclaration getNotationDeclaration(String name) { 1611 return getGlobalNotationDecl(name); 1612 } 1613 1614 public XSIDCDefinition getIDCDefinition(String name) { 1615 return getIDConstraintDecl(name); 1616 } 1617 1618 1619 /** 1620 * [document location] 1621 * @see <a href="http://www.w3.org/TR/xmlschema-1/#sd-document_location">[document location]</a> 1622 * @return a list of document information item 1623 */ 1624 public StringList getDocumentLocations() { 1625 return new StringListImpl(fLocations); 1626 } 1627 1628 /** 1629 * Return an <code>XSModel</code> that represents components in this schema 1630 * grammar. 1631 * 1632 * @return an <code>XSModel</code> representing this schema grammar 1633 */ 1634 public XSModel toXSModel() { 1635 return new XSModelImpl(new SchemaGrammar[]{this}); 1636 } 1637 1638 public XSModel toXSModel(XSGrammar[] grammars) { 1639 if (grammars == null || grammars.length == 0) 1640 return toXSModel(); 1641 1642 int len = grammars.length; 1643 boolean hasSelf = false; 1644 for (int i = 0; i < len; i++) { 1645 if (grammars[i] == this) { 1646 hasSelf = true; 1647 break; 1648 } 1649 } 1650 1651 SchemaGrammar[] gs = new SchemaGrammar[hasSelf ? len : len+1]; 1652 for (int i = 0; i < len; i++) 1653 gs[i] = (SchemaGrammar)grammars[i]; 1654 if (!hasSelf) 1655 gs[len] = this; 1656 return new XSModelImpl(gs); 1657 } 1658 1659 /** 1660 * @see org.apache.xerces.xs.XSNamespaceItem#getAnnotations() 1661 */ 1662 public XSObjectList getAnnotations() { 1663 if (fNumAnnotations == 0) { 1664 return XSObjectListImpl.EMPTY_LIST; 1665 } 1666 return new XSObjectListImpl(fAnnotations, fNumAnnotations); 1667 } 1668 1669 public void addAnnotation(XSAnnotationImpl annotation) { 1670 if (annotation == null) { 1671 return; 1672 } 1673 if (fAnnotations == null) { 1674 fAnnotations = new XSAnnotationImpl[2]; 1675 } 1676 else if (fNumAnnotations == fAnnotations.length) { 1677 XSAnnotationImpl[] newArray = new XSAnnotationImpl[fNumAnnotations << 1]; 1678 System.arraycopy(fAnnotations, 0, newArray, 0, fNumAnnotations); 1679 fAnnotations = newArray; 1680 } 1681 fAnnotations[fNumAnnotations++] = annotation; 1682 } 1683 1684 public void setImmutable(boolean isImmutable) { 1685 fIsImmutable = isImmutable; 1686 } 1687 1688 public boolean isImmutable() { 1689 return fIsImmutable; 1690 } 1691 1692} // class SchemaGrammar 1693