| java.lang.Object org.sakaiproject.tool.assessment.qti.util.XmlMapper
XmlMapper | public class XmlMapper (Code) | | Utility class. Maps XML elements and attribute under a given node
to a Map, or populates bean.
Note this now supports deep copy.
author: @author Ed Smiley version: $Id: XmlMapper.java 9274 2006-05-10 22:50:48Z daisyf@stanford.edu $ |
Method Summary | |
public static Map | map(Document doc) Maps each element node and attribute under a given node to a Map.
It associates each element's text value with its name, and
each attribute value with a key of "attribute_" + the attribute name.
If node is a document it processes it as if it were the root node.
If there are multiple nodes with the same element name they will be stored
in a List.
NOTE:
This was DESIGNED to ignore elements at more depth than root +1.
It has now been modified to deep copy under the nodes, but it
WILL NOT recurse and assign key value pairs below,
this is by design. | public static void | populateBeanFromDoc(Serializable bean, Document doc) Maps each element node to a bean property.
Supports only simple types such as String, int and long, plus Lists.
If node is a document it processes it as if it were the root node.
If there are multiple nodes with the same element name they will be stored
in a List.
NOTE:
This is DESIGNED to ignore elements at more depth so that simple
String key value pairs are used. |
ATTRIBUTE_PREFIX | final public static String ATTRIBUTE_PREFIX(Code) | | |
map | public static Map map(Document doc)(Code) | | Maps each element node and attribute under a given node to a Map.
It associates each element's text value with its name, and
each attribute value with a key of "attribute_" + the attribute name.
If node is a document it processes it as if it were the root node.
If there are multiple nodes with the same element name they will be stored
in a List.
NOTE:
This was DESIGNED to ignore elements at more depth than root +1.
It has now been modified to deep copy under the nodes, but it
WILL NOT recurse and assign key value pairs below,
this is by design. The elements below (e.g. XML snippets, XHTML text)
are all put into the value.
Parameters: node - Node Parameters: indent - String HashMap |
populateBeanFromDoc | public static void populateBeanFromDoc(Serializable bean, Document doc)(Code) | | Maps each element node to a bean property.
Supports only simple types such as String, int and long, plus Lists.
If node is a document it processes it as if it were the root node.
If there are multiple nodes with the same element name they will be stored
in a List.
NOTE:
This is DESIGNED to ignore elements at more depth so that simple
String key value pairs are used. This WILL NOT recurse to more depth,
by design. If it did so, you would have to use maps of maps.
Parameters: bean - Serializable object which has the appropriate setters/getters Parameters: doc - the document |
|
|