|
DLESE Tools v1.6.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.dlese.dpc.xml.schema.DocMap
public class DocMap
DocMap wraps a dom4j Document providing get and put methods for use with a Map-Backed Action form. Also supports document operations such as creating, inserting and removing nodes.
Constructor Summary | |
---|---|
DocMap(Document doc)
Constructor for the DocMap object |
|
DocMap(Document doc,
SchemaHelper schemaHelper)
Constructor for the DocMap object |
Method Summary | |
---|---|
boolean |
addElement(Element e,
String encodedReferencePath)
Called from metadata controller to add an element at a specific place in the document. |
Node |
createNewNode(String xpath)
Creates a new node at the location specified by the xpath, creating all the necessary nodes along the path in the process. |
Node |
createNewSiblingNode(String xpath)
Creates new node that is a sibling of the node at provided xpath |
Object |
get(String key)
Given an encoded xpath, return the value of the referred to node |
Document |
getDocument()
Gets the document attribute of the DocMap object |
int |
getSiblingCount(String xpath)
finds the like-named siblings of the node specified by xpath. |
boolean |
hasChildren(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(Element element,
Element parent,
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(String xpath)
Returns true if an element (recursively) has no textual content, no children, and no attributes with values. |
boolean |
nodeExists(String xpath)
Returns true if there is a node at specified xpath |
void |
orderSequenceElements(Element parent)
Put sequence elements in the order specified by the sequence compositor. |
protected void |
prtln(String s)
Description of the Method |
protected void |
prtlnErr(String s)
NOT YET DOCUMENTED |
void |
put(Object key,
Object val)
Updates the Document by setting the Text of the Node at the specified xpath. |
void |
remove(String xpath)
removes a node from the dom4j Document. |
void |
removeElement(String encodedXPath)
Removes the element at specified path |
boolean |
removeSiblings(String xpath)
Remove a node and all it's siblings (having the same element name) from the parent node. |
List |
selectNodes(String xpath)
Get list of all nodes selected by provided xpath |
Node |
selectSingleNode(String xpath)
Gets first node at proviced xpath |
void |
smartPut(String xpath,
String value)
Tests xpath against provided schema (via SchemaHelper) before putting value, creating a new Node if one is not found at xpath. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DocMap(Document doc)
doc
- Description of the Parameterpublic DocMap(Document doc, SchemaHelper schemaHelper)
doc
- NOT YET DOCUMENTEDschemaHelper
- NOT YET DOCUMENTEDMethod Detail |
---|
public Document getDocument()
public List selectNodes(String xpath)
xpath
- the xpath
public Node selectSingleNode(String xpath)
xpath
- Description of the Parameter
public boolean nodeExists(String xpath)
xpath
- xpath to node
public Object get(String key)
key
- xpath encoded as necessary for use in jsp
public void put(Object key, 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(String xpath, String value) throws Exception
xpath
- NOT YET DOCUMENTEDvalue
- NOT YET DOCUMENTED
Exception
- NOT YET DOCUMENTEDpublic boolean hasChildren(String xpath)
xpath
- xpath to the node to be evaluated for children
public boolean isEmpty(String xpath)
Note: returns FALSE if no node exists at the given path.
xpath
- Description of the Parameter
public void remove(String xpath)
xpath
- Description of the Parameterpublic boolean removeSiblings(String xpath) throws Exception
xpath
- xpath to an enumeration node
Exception
- if unable to remove siblingspublic int getSiblingCount(String xpath)
xpath
- an xpath to a specific node
public boolean addElement(Element e, String encodedReferencePath)
e
- The feature to be added to the Element
attributeencodedReferencePath
- The feature to be added to the Element
attribute
public void insertElement(Element element, Element parent, String targetPath) throws Exception
element
- element to be insertedparent
- parent in which to insert elementtargetPath
- specifies insertion point
Exception
- NOT YET DOCUMENTEDpublic void orderSequenceElements(Element parent)
parent
- NOT YET DOCUMENTEDpublic void removeElement(String encodedXPath)
encodedXPath
- xpath encoded by jsppublic Node createNewSiblingNode(String xpath) throws Exception
xpath
- xpath to existing node
Exception
- if a new node cannot be createdpublic Node createNewNode(String xpath) throws 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 created
Exception
- if unable to create a new node at xpathprotected final void prtlnErr(String s)
s
- NOT YET DOCUMENTEDprotected final void prtln(String s)
s
- Description of the Parameter
|
DLESE Tools v1.6.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |