/** * Returns the hash code value for the given grammar description. * * @param desc The grammar description * @return The hash code value */ public int hashCode(XMLGrammarDescription desc) { if (desc instanceof XMLSchemaDescription) { final XMLSchemaDescription sd = (XMLSchemaDescription) desc; final String targetNamespace = sd.getTargetNamespace(); final String expandedSystemId = sd.getExpandedSystemId(); int hash = (targetNamespace != null) ? targetNamespace.hashCode() : 0; hash ^= (expandedSystemId != null) ? expandedSystemId.hashCode() : 0; return hash; } return desc.hashCode(); }
/** * Compares this grammar with the given grammar. Currently, we compare * the target namespaces. * * @param descObj The description of the grammar to be compared with * @return True if they are equal, else false */ public boolean equals(Object descObj) { if(!(descObj instanceof XMLSchemaDescription)) return false; XMLSchemaDescription desc = (XMLSchemaDescription)descObj; if (fNamespace != null) return fNamespace.equals(desc.getTargetNamespace()); else // fNamespace == null return desc.getTargetNamespace() == null; }
public Grammar retrieveGrammar(XMLGrammarDescription desc) { if (desc.getGrammarType() == XMLGrammarDescription.XML_SCHEMA) { final String tns = ((XMLSchemaDescription) desc).getTargetNamespace(); if (fGrammarBucket != null) { Grammar grammar = fGrammarBucket.getGrammar(tns); if (grammar != null) { return grammar; } } if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(tns)) { return SchemaGrammar.Schema4Annotations.getSchema4Annotations(fSchemaVersion); } } return null; }
final String targetNamespace = sd1.getTargetNamespace(); if (targetNamespace != null) { if (!targetNamespace.equals(sd2.getTargetNamespace())) { return false; else if (sd2.getTargetNamespace() != null) { return false; final String expandedSystemId = sd1.getExpandedSystemId(); if (expandedSystemId != null) { if (!expandedSystemId.equals(sd2.getExpandedSystemId())) { return false; else if (sd2.getExpandedSystemId() != null) { return false;