Package org.opencms.xml.xml2json
Class CmsXmlContentTree
- java.lang.Object
-
- org.opencms.xml.xml2json.CmsXmlContentTree
-
public class CmsXmlContentTree extends java.lang.Object
Tree representation of CmsXmlContent which is suitable for XML-to-JSON transformations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classCmsXmlContentTree.FieldField of a complex type.classCmsXmlContentTree.NodeRepresents a sequence in the XML content.static classCmsXmlContentTree.NodeTypeEnum representing the type of the tree node.
-
Constructor Summary
Constructors Constructor Description CmsXmlContentTree(CmsXmlContent content, java.util.Locale locale)Creates a new instance and initializes the full tree for the given locale.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CmsXmlContentTree.NodecreateNode(org.dom4j.Element elem, CmsXmlContentDefinition contentDef)Creates a node for the given content definition and DOM element.CmsXmlContentTree.NodegetNodeForValue(I_CmsXmlContentValue value)Gets the node corresponding to the given value.CmsXmlContentTree.NodegetRoot()Returns the root node.java.lang.StringtoString()static voidvisitNodes(CmsXmlContentTree.Node node, java.util.function.Consumer<CmsXmlContentTree.Node> handler)Visits all Node instances that are descendants of a given node (including that node itself).
-
-
-
Constructor Detail
-
CmsXmlContentTree
public CmsXmlContentTree(CmsXmlContent content, java.util.Locale locale)
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 Detail
-
visitNodes
public static void visitNodes(CmsXmlContentTree.Node node, java.util.function.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
public CmsXmlContentTree.Node getNodeForValue(I_CmsXmlContentValue value)
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
public CmsXmlContentTree.Node getRoot()
Returns the root node.- Returns:
- the root node
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
-