|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jdom.Document
org.jdom.contrib.ids.IdDocument
public class IdDocument
IdDocument extends the default JDOM document to support looking up elements using their ID attribute.
Instances of this class should not be created directly but through
the IdFactory
. Using this factory ensures that the
document is made of IdElement
instances which update the
look-up table when the element attribute list is updated.
The method getElementById(java.lang.String)
allows looking up an element
in the document given the value of its ID attribute. Instead of
scanning the whole document when searching for an element,
IdDocument
uses a lookup table for fast direct
access to the elements. Hence, applications using this method
should see their performances improved compared to walking the
document tree.
Field Summary |
---|
Fields inherited from class org.jdom.Document |
---|
baseURI |
Constructor Summary | |
---|---|
IdDocument(org.jdom.Element root)
Creates a new Document , with the supplied
as the root element, and no
declaration. |
|
IdDocument(org.jdom.Element root,
org.jdom.DocType docType)
Creates a new IdDocument , with the supplied
as the root element and the
supplied declaration. |
Method Summary | |
---|---|
protected void |
addId(java.lang.String id,
org.jdom.Element elt)
Adds the specified ID to the ID lookup table of this document and make it point to the associated element. |
org.jdom.Element |
getElementById(java.lang.String id)
Retrieves an element using the value of its ID attribute as key. |
protected boolean |
removeId(java.lang.String id)
Removes the specified ID from the ID lookup table of this document. |
Methods inherited from class org.jdom.Document |
---|
addContent, addContent, addContent, addContent, clone, cloneContent, detachRootElement, equals, getBaseURI, getContent, getContent, getContent, getContentSize, getDescendants, getDescendants, getDocType, getDocument, getParent, getProperty, getRootElement, hashCode, hasRootElement, indexOf, removeContent, removeContent, removeContent, removeContent, setBaseURI, setContent, setContent, setContent, setContent, setDocType, setProperty, setRootElement, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public IdDocument(org.jdom.Element root, org.jdom.DocType docType)
Creates a new IdDocument
, with the supplied
as the root element and the
supplied Element
declaration.DocType
rootElement
- Element
for document root.docType
- DocType
declaration.public IdDocument(org.jdom.Element root)
Creates a new Document
, with the supplied
as the root element, and no
Element
declaration.
document type
rootElement
- Element
for document root.Method Detail |
---|
public org.jdom.Element getElementById(java.lang.String id)
Retrieves an element using the value of its ID attribute as key.
id
- the value of the ID attribute of the element to
retrieve.
Element
associated to id
or null
if none was found.protected void addId(java.lang.String id, org.jdom.Element elt)
Adds the specified ID to the ID lookup table of this document and make it point to the associated element.
id
- the ID to add.elt
- the Element
associated to the ID.protected boolean removeId(java.lang.String id)
Removes the specified ID from the ID lookup table of this document.
id
- the ID to remove.
true
if the ID was found and removed;
false
otherwise.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |