public SimpleXMLSchema(Grammar grammar, String xsdVersion) { super(xsdVersion); fGrammar = grammar; fGrammars = new Grammar[] {grammar}; fGrammarDescription = grammar.getGrammarDescription(); }
public void putGrammar(Grammar grammar) { if (grammar == null) return; // we overide this method to perform 'selective' caching of schemas XMLGrammarDescription description = grammar.getGrammarDescription(); if (!fPoolIsLocked && !containsGrammar(grammar.getGrammarDescription())) { // in order to avoid caching the inline schemas // we ensure the literal system id does not end with wsdl // before we attempt to 'put' the grammar String litSysId = description.getLiteralSystemId(); String basSysId = description.getBaseSystemId(); if (litSysId != null && litSysId.endsWith("xsd") && basSysId != null && basSysId.endsWith("wsdl")) { /* * System.out.println("putGramamr : " + * schemaDescription.getNamespace() + ", " + * schemaDescription.getExpandedSystemId() + ", " + * schemaDescription.getBaseSystemId()); */ super.putGrammar(grammar); } } } }
private void initGrammarPool(ASModelImpl currModel, XMLGrammarPool grammarPool) { // put all the grammars in fAbstractSchema into the grammar pool. // grammarPool must never be null! Grammar[] grammars = new Grammar[1]; if ((grammars[0] = (Grammar)currModel.getGrammar()) != null) { grammarPool.cacheGrammars(grammars[0].getGrammarDescription().getGrammarType(), grammars); } Vector modelStore = currModel.getInternalASModels(); for (int i = 0; i < modelStore.size(); i++) { initGrammarPool((ASModelImpl)modelStore.elementAt(i), grammarPool); } } } // class DOMASBuilderImpl
/** * Puts the specified grammar into the grammar pool and associates it to * its root element name or its target namespace. * * @param grammar The Grammar. */ public void putGrammar(Grammar grammar) { if(!fPoolIsLocked) { synchronized (fGrammars) { XMLGrammarDescription desc = grammar.getGrammarDescription(); int hash = hashCode(desc); int index = (hash & 0x7FFFFFFF) % fGrammars.length; for (Entry entry = fGrammars[index]; entry != null; entry = entry.next) { if (entry.hash == hash && equals(entry.desc, desc)) { entry.grammar = grammar; return; } } // create a new entry Entry entry = new Entry(hash, desc, grammar, fGrammars[index]); fGrammars[index] = entry; fGrammarCount++; } } } // putGrammar(Grammar)
public void putGrammar(Grammar grammar) { SchemaGrammar cachedGrammar = toSchemaGrammar(super.getGrammar(grammar.getGrammarDescription())); if (cachedGrammar != null) { SchemaGrammar newGrammar = toSchemaGrammar(grammar); if (newGrammar != null) { mergeSchemaGrammars(cachedGrammar, newGrammar); } } else { super.putGrammar(grammar); } }
/** * Puts the specified grammar into the grammar pool and associates it to * its root element name or its target namespace. * * @param grammar The Grammar. */ public void putGrammar(Grammar grammar) { if (!fPoolIsLocked) { synchronized (fGrammars) { clean(); XMLGrammarDescription desc = grammar.getGrammarDescription(); int hash = hashCode(desc); int index = (hash & 0x7FFFFFFF) % fGrammars.length; for (Entry entry = fGrammars[index]; entry != null; entry = entry.next) { if (entry.hash == hash && equals(entry.desc, desc)) { if (entry.grammar.get() != grammar) { entry.grammar = new SoftGrammarReference(entry, grammar, fReferenceQueue); } return; } } // create a new entry Entry entry = new Entry(hash, index, desc, grammar, fGrammars[index], fReferenceQueue); fGrammars[index] = entry; fGrammarCount++; } } } // putGrammar(Grammar)
for(int i = 0; i < numGrammars; i++) XMLGrammarDescription desc = grammars[i].getGrammarDescription(); if(targetNamespace.equals(desc.getNamespace()))