Package groovy.xml.dom
Class DOMCategory
- java.lang.Object
-
- groovy.xml.dom.DOMCategory
-
public class DOMCategory extends Object
Category class which adds GPath style operations to Java's DOM classes.
-
-
Constructor Summary
Constructors Constructor Description DOMCategory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ElementappendNode(Element self, Object name)static ElementappendNode(Element self, Object name, String value)static ElementappendNode(Element self, Object name, Map attributes)static ElementappendNode(Element self, Object name, Map attributes, String value)static NamedNodeMapattributes(Element element)static NodeListbreadthFirst(Element self)static NodeListchildren(Element self)static NodeListdepthFirst(Element self)static Objectget(Element element, String elementName)static Objectget(NamedNodeMap nodeMap, String elementName)static Objectget(NodeList nodeList, String elementName)static NodegetAt(groovy.xml.dom.DOMCategory.NodeListsHolder o, int i)static NodeListgetAt(groovy.xml.dom.DOMCategory.NodeListsHolder o, IntRange r)static NodegetAt(groovy.xml.dom.DOMCategory.NodesHolder o, int i)static NodeListgetAt(groovy.xml.dom.DOMCategory.NodesHolder o, IntRange r)static NodegetAt(Node o, int i)static NodeListgetAt(Node o, IntRange r)static booleanisEmpty(NodeList self)static booleanisGlobalKeepIgnorableWhitespace()static booleanisGlobalTrimWhitespace()static List<Node>list(NodeList self)static List<String>localText(Element self)Returns the list of any direct String nodes of this node.static Stringname(Node node)static Nodeparent(Node node)static voidplus(Element self, Closure c)static voidplus(NodeList self, Closure c)static voidputAt(Element self, String property, Object value)static NodereplaceNode(groovy.xml.dom.DOMCategory.NodesHolder self, Closure c)static NodereplaceNode(Node self, Closure c)static voidsetGlobalKeepIgnorableWhitespace(boolean keepIgnorableWhitespace)Whether ignorable whitespace (e.g.static voidsetGlobalTrimWhitespace(boolean trimWhitespace)Whether text content is trimmed (removing leading and trailing whitespace); default false.static voidsetValue(Element self, String value)static intsize(NamedNodeMap namedNodeMap)static intsize(NodeList self)static Stringtext(Node node)static Stringtext(NodeList nodeList)static StringtoString(Object o)static Stringxpath(Node self, String expression)static Objectxpath(Node self, String expression, QName returnType)
-
-
-
Method Detail
-
isGlobalTrimWhitespace
public static boolean isGlobalTrimWhitespace()
- Returns:
- true if text elements are trimmed before returning; default false
-
setGlobalTrimWhitespace
public static void setGlobalTrimWhitespace(boolean trimWhitespace)
Whether text content is trimmed (removing leading and trailing whitespace); default false. WARNING: this is a global setting. Altering it will affect all DOMCategory usage within the current Java process. It is not recommended that this is altered; instead call the trim() method on the returned text, but the flag is available to support legacy Groovy behavior.- Parameters:
trimWhitespace- the new value
-
isGlobalKeepIgnorableWhitespace
public static boolean isGlobalKeepIgnorableWhitespace()
- Returns:
- true if ignorable whitespace (e.g. whitespace between elements) is kept; default false
-
setGlobalKeepIgnorableWhitespace
public static void setGlobalKeepIgnorableWhitespace(boolean keepIgnorableWhitespace)
Whether ignorable whitespace (e.g. whitespace between elements) is kept (default false). WARNING: this is a global setting. Altering it will affect all DOMCategory usage within the current Java process.- Parameters:
keepIgnorableWhitespace- the new value
-
get
public static Object get(NamedNodeMap nodeMap, String elementName)
-
attributes
public static NamedNodeMap attributes(Element element)
-
size
public static int size(NamedNodeMap namedNodeMap)
-
getAt
public static Node getAt(groovy.xml.dom.DOMCategory.NodeListsHolder o, int i)
-
getAt
public static Node getAt(groovy.xml.dom.DOMCategory.NodesHolder o, int i)
-
appendNode
public static Element appendNode(Element self, Object name, Map attributes, String value)
-
localText
public static List<String> localText(Element self)
Returns the list of any direct String nodes of this node.- Returns:
- the list of String values from this node
- Since:
- 2.3.0
-
size
public static int size(NodeList self)
-
isEmpty
public static boolean isEmpty(NodeList self)
-
-