public class DocMap
extends java.lang.Object
Constructor and Description |
---|
DocMap(org.dom4j.Document doc)
Constructor for the DocMap object
|
DocMap(org.dom4j.Document doc,
SchemaHelper schemaHelper)
Constructor for the DocMap object
|
Modifier and Type | Method and Description |
---|---|
boolean |
addElement(org.dom4j.Element e,
java.lang.String encodedReferencePath)
Called from metadata controller to add an element at a specific place in
the document.
|
org.dom4j.Node |
createNewNode(java.lang.String xpath)
Creates a new node at the location specified by the xpath, creating all the
necessary nodes along the path in the process.
|
org.dom4j.Node |
createNewSiblingNode(java.lang.String xpath)
Creates new node that is a sibling of the node at provided xpath
|
java.lang.Object |
get(java.lang.String key)
Given an encoded xpath, return the value of the referred to node
|
org.dom4j.Document |
getDocument()
Gets the document attribute of the DocMap object
|
int |
getSiblingCount(java.lang.String xpath)
finds the like-named siblings of the node specified by xpath.
|
boolean |
hasChildren(java.lang.String xpath)
Return true if the specified node is an Element and has either a
sub-element, or an attribute (even if they are empty), OR content.
|
void |
insertElement(org.dom4j.Element element,
org.dom4j.Element parent,
java.lang.String targetPath)
Insert the given element into parent using targetPath for placement
information (insertion point is immediatlely following the node identified
by targetPath).
|
boolean |
isEmpty(java.lang.String xpath)
Returns true if an element (recursively) has no textual content, no
children, and no attributes with values.
|
boolean |
nodeExists(java.lang.String xpath)
Returns true if there is a node at specified xpath
|
void |
orderSequenceElements(org.dom4j.Element parent)
Put sequence elements in the order specified by the sequence compositor.
|
protected void |
prtln(java.lang.String s)
Description of the Method
|
protected void |
prtlnErr(java.lang.String s)
NOT YET DOCUMENTED
|
void |
put(java.lang.Object key,
java.lang.Object val)
Updates the Document by setting the Text of the Node at the specified
xpath.
|
void |
remove(java.lang.String xpath)
removes a node from the dom4j Document.
|
void |
removeElement(java.lang.String encodedXPath)
Removes the element at specified path
|
boolean |
removeSiblings(java.lang.String xpath)
Remove a node and all it's siblings (having the same element name) from the
parent node.
|
java.util.List |
selectNodes(java.lang.String xpath)
Get list of all nodes selected by provided xpath
|
org.dom4j.Node |
selectSingleNode(java.lang.String xpath)
Gets first node at proviced xpath
|
void |
smartPut(java.lang.String xpath,
java.lang.String value)
Tests xpath against provided schema (via SchemaHelper) before putting
value, creating a new Node if one is not found at xpath.
|
public DocMap(org.dom4j.Document doc)
doc
- Description of the Parameterpublic DocMap(org.dom4j.Document doc, SchemaHelper schemaHelper)
doc
- NOT YET DOCUMENTEDschemaHelper
- NOT YET DOCUMENTEDpublic org.dom4j.Document getDocument()
public java.util.List selectNodes(java.lang.String xpath)
xpath
- the xpathpublic org.dom4j.Node selectSingleNode(java.lang.String xpath)
xpath
- Description of the Parameterpublic boolean nodeExists(java.lang.String xpath)
xpath
- xpath to nodepublic java.lang.Object get(java.lang.String key)
key
- xpath encoded as necessary for use in jsppublic void put(java.lang.Object key, java.lang.Object val)
ISSUE: what if there is no value (one way this happens is when there is a field in the form but no value is supplied by user. In this case we shouldn't bother creating a new node because there is no value to insert. But what if there was formerly a value and the user has deleted it? if the node is an Element, then should that element be deleted? (The user should be warned first!) if the node is an attribute, then should that attribute be deleted? (the user won't be warned, since this does not have the "ripple" effect that deleting an element can have. (maybe the user should be warned only if the element has children with values).
key
- unencoded xpathval
- value to assign to node at xpathpublic void smartPut(java.lang.String xpath, java.lang.String value) throws java.lang.Exception
xpath
- NOT YET DOCUMENTEDvalue
- NOT YET DOCUMENTEDjava.lang.Exception
- NOT YET DOCUMENTEDpublic boolean hasChildren(java.lang.String xpath)
xpath
- xpath to the node to be evaluated for childrenpublic boolean isEmpty(java.lang.String xpath)
Note: returns FALSE if no node exists at the given path.
xpath
- Description of the Parameterpublic void remove(java.lang.String xpath)
xpath
- Description of the Parameterpublic boolean removeSiblings(java.lang.String xpath) throws java.lang.Exception
xpath
- xpath to an enumeration nodejava.lang.Exception
- if unable to remove siblingspublic int getSiblingCount(java.lang.String xpath)
xpath
- an xpath to a specific nodepublic boolean addElement(org.dom4j.Element e, java.lang.String encodedReferencePath)
e
- The feature to be added to the Element
attributeencodedReferencePath
- The feature to be added to the Element
attributepublic void insertElement(org.dom4j.Element element, org.dom4j.Element parent, java.lang.String targetPath) throws java.lang.Exception
element
- element to be insertedparent
- parent in which to insert elementtargetPath
- specifies insertion pointjava.lang.Exception
- NOT YET DOCUMENTEDpublic void orderSequenceElements(org.dom4j.Element parent)
parent
- NOT YET DOCUMENTEDpublic void removeElement(java.lang.String encodedXPath)
encodedXPath
- xpath encoded by jsppublic org.dom4j.Node createNewSiblingNode(java.lang.String xpath) throws java.lang.Exception
xpath
- xpath to existing nodejava.lang.Exception
- if a new node cannot be createdpublic org.dom4j.Node createNewNode(java.lang.String xpath) throws java.lang.Exception
When schemaHelper is present and the path specifies an Element, then a new element is created by SchemaHelper.getNewElement. Otherwise, the newly created Element (or Attribute) is empty.
xpath
- location of new node to be createdjava.lang.Exception
- if unable to create a new node at xpathprotected final void prtlnErr(java.lang.String s)
s
- NOT YET DOCUMENTEDprotected final void prtln(java.lang.String s)
s
- Description of the Parameter