Package org.opencms.xml.xml2json
Class CmsXmlContentTree
java.lang.Object
org.opencms.xml.xml2json.CmsXmlContentTree
Tree representation of CmsXmlContent which is suitable for XML-to-JSON transformations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassField of a complex type.classRepresents a sequence in the XML content.static enumEnum representing the type of the tree node. -
Constructor Summary
ConstructorsConstructorDescriptionCmsXmlContentTree(CmsXmlContent content, Locale locale) Creates a new instance and initializes the full tree for the given locale. -
Method Summary
Modifier and TypeMethodDescriptioncreateNode(org.dom4j.Element elem, CmsXmlContentDefinition contentDef) Creates a node for the given content definition and DOM element.Gets the node corresponding to the given value.getRoot()Returns the root node.toString()static voidvisitNodes(CmsXmlContentTree.Node node, Consumer<CmsXmlContentTree.Node> handler) Visits all Node instances that are descendants of a given node (including that node itself).
-
Constructor Details
-
CmsXmlContentTree
Creates a new instance and initializes the full tree for the given locale.- Parameters:
content- the content from which the tree should be generatedlocale- the locale for which the tree should be generated
-
-
Method Details
-
visitNodes
public static void visitNodes(CmsXmlContentTree.Node node, Consumer<CmsXmlContentTree.Node> handler) Visits all Node instances that are descendants of a given node (including that node itself).- Parameters:
node- the root nodehandler- the handler to be invoked for all descendant nodes
-
createNode
public CmsXmlContentTree.Node createNode(org.dom4j.Element elem, CmsXmlContentDefinition contentDef) Creates a node for the given content definition and DOM element.- Parameters:
elem- the XML DOM elementcontentDef- the content definition (null for non-nested values)- Returns:
- the created node
-
getNodeForValue
Gets the node corresponding to the given value.- Parameters:
value- a content value- Returns:
- the node for the value, or null if no node is found
-
getRoot
Returns the root node.- Returns:
- the root node
-
toString
-