edu.uky.rch.ept.xmlSegmentTree.dom
Class XDocument
java.lang.Object
org.dom4j.tree.AbstractNode
org.dom4j.tree.AbstractBranch
org.dom4j.tree.AbstractDocument
edu.uky.rch.ept.xmlSegmentTree.dom.XDocument
- All Implemented Interfaces:
- org.dom4j.Branch, Cloneable, org.dom4j.Document, org.dom4j.Node, Serializable
- public class XDocument
- extends org.dom4j.tree.AbstractDocument
DOM4J document backed by a SegmentTree. Attempting to modify this
document may result in UnsupportedOperationException being
thrown.
TODO: need to be able to add an element. We don't need to support the
dom4j methods, but there should be methods (of XDocument) that support
the operations required by the data source layer:
- deleteXML(String address, String dtdID, String xpath)
- insertXML(String address, String dtdID, String xpath,
org.dom4j.Node newContent)
- query(String xmlResourceAddress, String query, short returnType)
- replaceXML(String address, String dtdID, String xpath,
org.dom4j.Node newContent)
- replaceXMLContent(String xmlResourceAddress, int beginIndex,
int endIndex, String newContent)
The last is the most difficult to implement, as it modifies the underlying
content and can thus change coordinates. There may not be room in the old
coordinate system for all the new content.
These operations, of course, modify the underlying SegmentTree. However,
SegmentTree is immutable; operations that would modify it instead return
a new SegmentTree. We need, then, a SegmentTreeChangeListener class to
notify users of the segment tree that it was modified.
- See Also:
- Serialized Form
| Fields inherited from class org.dom4j.tree.AbstractBranch |
DEFAULT_CONTENT_LIST_SIZE, outputFormat |
| Fields inherited from class org.dom4j.tree.AbstractNode |
NODE_TYPE_NAMES |
| Fields inherited from interface org.dom4j.Node |
ANY_NODE, ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_REFERENCE_NODE, MAX_NODE_TYPE, NAMESPACE_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE, UNKNOWN_NODE |
|
Constructor Summary |
XDocument(SegmentTree st,
org.dom4j.DocumentType dt)
Create a dom4j representation of a segment tree with the specified
document type. |
XDocument(SegmentTree st,
ElementFilter filter)
Create a dom4j representation of the tags stored in a particular
segment tree which match the given filter. |
XDocument(SegmentTree st,
ElementFilter filter,
String rootName)
Create a dom4j representation of the tags stored in a particular
segment tree which match the given filter. |
| Methods inherited from class org.dom4j.tree.AbstractDocument |
accept, add, addComment, addElement, addElement, addElement, addProcessingInstruction, addProcessingInstruction, asXML, asXPathResult, checkAddElementAllowed, childAdded, childRemoved, getDocument, getNodeType, getPath, getStringValue, getUniquePath, normalize, remove, setRootElement, toString, write |
| Methods inherited from class org.dom4j.tree.AbstractBranch |
add, add, add, addElement, appendContent, content, contentRemoved, createContentList, createContentList, createEmptyList, createResultList, createSingleResultList, elementByID, elementID, getContentAsStringValue, getContentAsText, getText, getTextTrim, hasContent, indexOf, invalidNodeTypeAddException, isReadOnly, node, nodeCount, nodeIterator, remove, remove, remove, setProcessingInstructions |
| Methods inherited from class org.dom4j.tree.AbstractNode |
clone, createPattern, createXPath, createXPathFilter, createXPathResult, detach, getDocumentFactory, getName, getNodeTypeName, getParent, getPath, getUniquePath, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setName, setParent, setText, supportsParent, valueOf |
| Methods inherited from interface org.dom4j.Branch |
add, add, add, appendContent, content, elementByID, indexOf, node, nodeCount, nodeIterator, remove, remove, remove, setProcessingInstructions |
| Methods inherited from interface org.dom4j.Node |
clone, createXPath, detach, getName, getNodeTypeName, getParent, getPath, getText, getUniquePath, hasContent, isReadOnly, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setName, setParent, setText, supportsParent, valueOf |
XDocument
public XDocument(SegmentTree st,
ElementFilter filter)
throws HierarchyException
- Create a dom4j representation of the tags stored in a particular
segment tree which match the given filter. If the document does
not have a root element named "document", insert one into
the dom4j tree (but not the underlying segment tree).
- Parameters:
st - the segment tree backing this dom4j tree.filter - an ElementFilter matching those elements to be
included in the segment tree.
XDocument
public XDocument(SegmentTree st,
ElementFilter filter,
String rootName)
throws HierarchyException
- Create a dom4j representation of the tags stored in a particular
segment tree which match the given filter. If the document does
not have a root element named
rootName, insert one
into the dom4j tree (but not the underlying segment tree).
- Parameters:
st - the segment tree backing this dom4j tree.filter - an ElementFilter matching those elements to be
included in the segment tree.rootName - the name of the document's root element.
XDocument
public XDocument(SegmentTree st,
org.dom4j.DocumentType dt)
throws HierarchyException
- Create a dom4j representation of a segment tree with the specified
document type. Only elements mentioned in the document type are
included, and the XML's root element must have the same name as that
specified in the document type.
- Parameters:
st - the segment tree backing this dom4j tree.dt - the document type to apply to the dom4j tree.
addDocType
public org.dom4j.Document addDocType(String name,
String publicId,
String systemId)
getDocType
public org.dom4j.DocumentType getDocType()
getEntityResolver
public EntityResolver getEntityResolver()
getRootElement
public org.dom4j.Element getRootElement()
rootElementAdded
protected void rootElementAdded(org.dom4j.Element rootElement)
setDocType
public void setDocType(org.dom4j.DocumentType docType)
setEntityResolver
public void setEntityResolver(EntityResolver entityResolver)
addNode
protected void addNode(org.dom4j.Node node)
clearContent
public void clearContent()
contentList
protected List contentList()
processingInstruction
public org.dom4j.ProcessingInstruction processingInstruction(String target)
processingInstructions
public List processingInstructions()
processingInstructions
public List processingInstructions(String target)
removeNode
protected boolean removeNode(org.dom4j.Node node)
removeProcessingInstruction
public boolean removeProcessingInstruction(String target)
setContent
public void setContent(List content)
getSegmentTree
protected SegmentTree getSegmentTree()
getFilter
protected ElementFilter getFilter()