TagXml class
Represents an XML tag that can behave like a POCO class and implement validations and computations
Just extend this class and point your gettes and setters to the XML nodes using getValueFromNode and setValueForNode
- Implemented types
- Implementers
- Available extensions
Constructors
- TagXml.fromTagName(String name)
-
Constructs a TagXml instance with the given
name.
Properties
-
attributes
→ XmlNodeList<
XmlAttribute> -
finalinherited
-
childElements
→ Iterable<
XmlElement> -
Return an Iterable over the
XmlElementchildren of this node.no setterinherited -
children
→ XmlNodeList<
XmlNode> -
finalinherited
- deepArrow → string
-
Return a string with a arrow with length equal to deepLevel
no setter
- deepLevel → int
-
Returns the deep level of the current node.
no setter
- firstChild → XmlNode?
-
Return the first child of this node, or
nullif there are no children.no setterinherited - firstElementChild → XmlElement?
-
Return the first child
XmlElement, ornullif there are none.no setterinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- hasParent → bool
-
Test whether the node has a parent or not.
no setterinherited
- isSelfClosing ↔ bool
-
Defines whether the element should be self-closing when empty.
getter/setter pairinherited
- lastChild → XmlNode?
-
Return the last child of this node, or
nullif there are no children.no setterinherited - lastElementChild → XmlElement?
-
Return the last child
XmlElement, ornullif there are none.no setterinherited - localName → String
-
Return the local name, excluding the namespace prefix.
no setterinherited
- name → XmlName
-
finalinherited
- namespacePrefix → String?
-
Return the namespace prefix, or
null.no setterinherited - namespaceUri → String?
-
Return the namespace URI, or
null.no setterinherited - nodeType → XmlNodeType
-
Return the node type of this node.
no setterinherited
- parent → XmlNode?
-
Return the parent node of this node, or
nullif there is none.no setterinherited - path → string
-
Returns the path of the current node.
no setter
- qualifiedName → String
-
Return the fully qualified name, including the namespace prefix.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tagName ↔ string
-
Gets or sets the tag name.
getter/setter pair
- text → String
-
Returns the concatenated text of this node or its descendants, for
text, CDATA, and comment nodes return the textual value of the node.
no setterinherited
- value → String?
-
Returns the value of the node, or
null.no setterinherited
Methods
-
accept(
XmlVisitor visitor) → void -
Dispatch the invocation depending on this type to the
visitor.inherited -
attachParent(
covariant XmlNode parent) → void -
Internal helper to attach a child to this parent, do not call directly.
inherited
-
compareAndSwap(
T other) → Iterable< T> -
Available on T, provided by the CompareAndSwap extension
Compares the current value with theothervalue and swaps them if necessary. -
compareTo(
dynamic other) → int -
compare this tag with another tag
override
-
compute(
) → void - compute this tag
-
computeAndValidate(
[bool throwException = false]) → bool -
Compute and validate this tag.
If
throwExceptionistrue, it throws an InvalidException if the tag is not valid. -
copy(
) → XmlElement -
Return a copy of this node and all its children.
inherited
-
detachParent(
covariant XmlNode parent) → void -
Internal helper to detach a child from its parent, do not call directly.
inherited
-
getAttribute(
String name, {String? namespace}) → String? -
Return the attribute value with the given
name, ornull.inherited -
getAttributeNode(
String name, {String? namespace}) → XmlAttribute? -
Return the attribute node with the given
name, ornull.inherited -
getElement(
String name, {String? namespace}) → XmlElement? -
Return the first child element with the given
name, ornull.inherited -
getFirstChild(
String tagName) → XmlElement? -
Returns a child node with the given
tagName. -
getTagAs<
T extends TagXml> (String tag, T constructor()) → T? -
Returns a child node with the given
tagas an instance ofT. -
getTagsFrom<
T extends TagXml> (String tagName, T itemConstructor()) → Iterable< T> -
Returns an iterable of child nodes with the given
tagNameas instances ofT. -
getTagsFromNodeList<
T extends TagXml> (String listName, string itemName, T constructor()) → Iterable< T> -
getValueFromNode<
T> (String tag, [T parser(string i)?]) → T? -
Returns the text value from a specific child node with the given
tag. -
hasChildren(
String tagName) → bool -
check if children with
tagNameexists -
isIn<
T extends TagXml> (T tag) → bool -
Checks if this node is a descendant of the given
tag. -
isInDocument<
T extends TagXml> (T tag) → bool -
Checks if this node is a descendant of the document thats
tagis. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pathJoin(
[string joiner = "."]) → string -
Returns the path of the current node.
The
joineris used to join the path segments. -
removeAttribute(
String name, {String? namespace}) → void -
Removes the attribute value with the given fully qualified
name.inherited -
removeChildren(
string tagName) → void -
Remove all child nodes with the given
tagName. -
renameChildren(
string oldTagName, string newTagName) → void -
setAttribute(
String name, String? value, {String? namespace}) → void -
Set the attribute value with the given fully qualified
nametovalue. If an attribute with the name already exist, its value is updated. If the value isnull, the attribute is removed.inherited -
setNodeList<
T extends TagXml, V extends TagXml> (String listRootTag, Iterable< V> values) → void - Add a node thats wrap a list of child nodes
-
setTagFrom<
T extends TagXml> (String childName, T? value) → T? -
Sets a child node with the given
childNameto the providedvalue. -
setValueForNode<
T, V> (String tag, V? value) → void -
Sets the text value for a specific child node with the given
tag. -
toString(
) → String -
Compute and return the preety XML string representation of the node.
override
-
toXmlString(
{bool pretty = false, XmlEntityMapping? entityMapping, int? level, String? indent, String? newLine, Predicate< XmlNode> ? preserveWhitespace, Predicate<XmlAttribute> ? indentAttribute, Comparator<XmlAttribute> ? sortAttributes, Predicate<XmlNode> ? spaceBeforeSelfClose}) → String -
Return an XML string of this object.
inherited
-
validate(
) → Iterable< String> -
Validates the current instance and returns a list of error messages if the instance is invalid.
override
-
validateOrThrow<
T extends Exception> ([T exception(Iterable< String> errors)?]) → void -
Available on Validator, provided by the ValidatorClassExtensions extension
Validates the object and throws an exception if there are any errors.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
fromXmlString<
T extends TagXml> (string xml, T constructor()) → T? -
Create a instance of
Tfrom a XML string and using the providedconstructor. Theconstructoris a function that creates a new instance ofTand returns it. -
fromXmlStringList<
T extends TagXml> (string xml, T constructor()) → Iterable< T> -
Create a list of instances of
Tfrom a XML string and using the providedconstructor. Theconstructoris a function that creates a new instance ofTand returns it. Provide the tagName ifTname is different fom tagName. -
mutate<
T extends TagXml> (XmlNode? element, T constructor(), [bool force = false]) → T? -
Mutate a
XmlElementinto a TagXml of typeT.