Package com.itextpdf.tool.xml
Class Tag
java.lang.Object
com.itextpdf.tool.xml.Tag
Represents an encountered tag.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new tag object.Construct a tag.Create a new tag object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a child tag to this tag.boolean
compareTag
(Tag t) Compare this tag with t for namespace and name equality.Finds the first child that matches the given name and namespace.Finds the first child that matches the given name and ns.Returns all children of this tag.getChildren
(String name) Returns all children of this tag with the given name.getCSS()
Returns a Map of css property, value.getName()
Returns the name of the tag.
(Actually the same as getTag method, but after using XMLWorker for a while we caught ourself always trying to call Tag#getName() instead of Tag#getTag())Returns the parent tag for this tag.getTag()
Deprecated.marked as deprecated in favor for getName, we won't remove it yet.boolean
Check if this tag has a child with the given name and namespace.boolean
Check if this tag has a child with the given name and namespace.boolean
Whether or not this tag has children.boolean
Whether or not this tag has a parent.iterator()
private Tag
recursiveGetChild
(Tag tag, String name, String ns, boolean recursive) private boolean
recursiveHasChild
(Tag tag, String name, String ns, boolean recursive) void
Set the css map.void
setLastMarginBottom
(Object lastMarginBottom) void
Set the tags parent tag.toString()
Print the tagMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
parent
-
tag
-
attributes
-
css
-
children
-
ns
-
lastMarginBottom
-
-
Constructor Details
-
Tag
Construct a tag.- Parameters:
tag
- the tag nameattr
- the attributes in the tag
-
Tag
- Parameters:
tag
- the tag name
-
Tag
- Parameters:
tag
- the tag nameattr
- the attributescss
- a map with CSSns
- the namespace
-
Tag
Create a new tag object.- Parameters:
tag
- the tag nameattr
- the attributesns
- the namespace
-
Tag
Create a new tag object.- Parameters:
tag
- the name of the tagns
- the namespace of the tag (do not set null, set an empty String)
-
-
Method Details
-
setParent
Set the tags parent tag.- Parameters:
parent
- the parent tag of this tag
-
getParent
Returns the parent tag for this tag.- Returns:
- the parent tag or null if none
-
getTag
Deprecated.marked as deprecated in favor for getName, we won't remove it yet.The tags name.- Returns:
- the tag name
-
getCSS
Returns a Map of css property, value.- Returns:
- the css, never null but can be an empty map.
-
setCSS
Set the css map. Ifnull
is given the css is cleared.- Parameters:
css
- set css properties
-
getAttributes
- Returns:
- the attributes of the tag
-
addChild
Add a child tag to this tag. The given tags parent is set to this tag.- Parameters:
t
- the tag
-
getChildren
Returns all children of this tag.- Returns:
- the children tags of this tag.
-
getChildren
Returns all children of this tag with the given name.- Parameters:
name
- the name of the tags to look for- Returns:
- the children tags of this tag with the given name.
-
getNameSpace
- Returns:
- the ns
-
toString
Print the tag -
compareTag
Compare this tag with t for namespace and name equality.- Parameters:
t
- the tag to compare with- Returns:
- true if the namespace and tag are the same.
-
iterator
-
getChild
Finds the first child that matches the given name and namespace.- Parameters:
name
- the name of the tagns
- the namespace- Returns:
- the child
-
getChild
Finds the first child that matches the given name and ns. Optionally look in the whole tree (in children of children of children ...)- Parameters:
name
- name of the tagns
- the namespacerecursive
- true if the tree should be fully inwards inspected.- Returns:
- the child if found
-
hasChildren
public boolean hasChildren()Whether or not this tag has children.- Returns:
- true if there are children
-
hasParent
public boolean hasParent()Whether or not this tag has a parent.- Returns:
- true if parent is not
null
-
hasChild
Check if this tag has a child with the given name and namespace.- Parameters:
name
- the name of the tag to look forns
- the namespace (if no namespace, set an empty String)- Returns:
- true if a child with given name and ns is found
-
hasChild
Check if this tag has a child with the given name and namespace.- Parameters:
name
- the name of the tag to look forns
- the namespace (if no namespace, set an empty String)recursive
- true if children's children children children ... should be inspected too.- Returns:
- true if a child with the given name and ns is found.
-
recursiveHasChild
- Parameters:
tag
-name
-ns
-recursive
-- Returns:
- true if the child is found in the child tree
-
recursiveGetChild
- Parameters:
tag
-name
-ns
-recursive
-- Returns:
- the child tag
-
getName
Returns the name of the tag.
(Actually the same as getTag method, but after using XMLWorker for a while we caught ourself always trying to call Tag#getName() instead of Tag#getTag())- Returns:
- the name of the tag.
-
getLastMarginBottom
-
setLastMarginBottom
-