XMLDTDDescriptionpublic class XMLDTDDescription extends XMLResourceIdentifierImpl implements XMLDTDDescriptionAll information specific to DTD grammars. |
Fields Summary |
---|
protected String | fRootName | protected Vector | fPossibleRoots |
Constructors Summary |
---|
public XMLDTDDescription(XMLResourceIdentifier id, String rootName)
// Constructors:
this.setValues(id.getPublicId(), id.getLiteralSystemId(),
id.getBaseSystemId(), id.getExpandedSystemId());
this.fRootName = rootName;
this.fPossibleRoots = null;
| public XMLDTDDescription(String publicId, String literalId, String baseId, String expandedId, String rootName)
this.setValues(publicId, literalId, baseId, expandedId);
this.fRootName = rootName;
this.fPossibleRoots = null;
| public XMLDTDDescription(XMLInputSource source)
this.setValues(source.getPublicId(), null,
source.getBaseSystemId(), source.getSystemId());
this.fRootName = null;
this.fPossibleRoots = null;
|
Methods Summary |
---|
public boolean | equals(java.lang.Object desc)Compares this grammar with the given grammar. Currently, we compare
as follows:
- if grammar type not equal return false immediately
- try and find a common root name:
- if both have roots, use them
- else if one has a root, examine other's possible root's for a match;
- else try all combinations
- test fExpandedSystemId and fPublicId as above
if(!(desc instanceof XMLGrammarDescription)) return false;
if (!getGrammarType().equals(((XMLGrammarDescription)desc).getGrammarType())) {
return false;
}
// assume it's a DTDDescription
XMLDTDDescription dtdDesc = (XMLDTDDescription)desc;
if(fRootName != null) {
if((dtdDesc.fRootName) != null && !dtdDesc.fRootName.equals(fRootName)) {
return false;
} else if(dtdDesc.fPossibleRoots != null && !dtdDesc.fPossibleRoots.contains(fRootName)) {
return false;
}
} else if(fPossibleRoots != null) {
if(dtdDesc.fRootName != null) {
if(!fPossibleRoots.contains(dtdDesc.fRootName)) {
return false;
}
} else if(dtdDesc.fPossibleRoots == null) {
return false;
} else {
boolean found = false;
for(int i = 0; i<fPossibleRoots.size(); i++) {
String root = (String)fPossibleRoots.elementAt(i);
found = dtdDesc.fPossibleRoots.contains(root);
if(found) break;
}
if(!found) return false;
}
}
// if we got this far we've got a root match... try other two fields,
// since so many different DTD's have roots in common:
if(fExpandedSystemId != null) {
if(!fExpandedSystemId.equals(dtdDesc.fExpandedSystemId))
return false;
}
else if(dtdDesc.fExpandedSystemId != null)
return false;
if(fPublicId != null) {
if(!fPublicId.equals(dtdDesc.fPublicId))
return false;
}
else if(dtdDesc.fPublicId != null)
return false;
return true;
| public java.lang.String | getGrammarType()
return XMLGrammarDescription.XML_DTD;
| public java.lang.String | getRootName()
return fRootName;
| public int | hashCode()Returns the hash code of this grammar
Because our .equals method is so complex, we just return a very
simple hash that might avoid calls to the equals method a bit...
if(fExpandedSystemId != null)
return fExpandedSystemId.hashCode();
if(fPublicId != null)
return fPublicId.hashCode();
// give up; hope .equals can handle it:
return 0;
| public void | setPossibleRoots(java.util.Vector possibleRoots)Set possible roots
fPossibleRoots = possibleRoots;
| public void | setRootName(java.lang.String rootName)Set the root name
fRootName = rootName;
fPossibleRoots = null;
|
|