final case class Elem(resolvedName: EName, resolvedAttributes: Map[EName, String], children: IndexedSeq[Node]) extends Node with queryapi.ClarkNodes.Elem with ClarkElemLike with UpdatableElemLike with TransformableElemLike with Product with Serializable
Element as abstract data type. It contains only expanded names, not qualified names. This reminds of James Clark notation for XML trees and expanded names, where qualified names are absent.
See the documentation of the mixed-in query API trait(s) for more details on the uniform query API offered by this class.
Namespace declarations (and undeclarations) are not considered attributes in this API, just like in the rest of yaidom.
To illustrate equality comparisons in action, consider the following example yaidom Elem
, named schemaElem1
:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://book" elementFormDefault="qualified"> <xsd:element name="book"> <xsd:complexType> <xsd:sequence> <xsd:element name="isbn" type="xsd:string" /> <xsd:element name="title" type="xsd:string" /> <xsd:element name="authors" type="xsd:string" /> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema>
Now consider the following equivalent yaidom Elem
, named schemaElem2
, differing only in namespace prefixes, and in
indentation:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://book" elementFormDefault="qualified"> <xs:element name="book"> <xs:complexType> <xs:sequence> <xs:element name="isbn" type="xs:string" /> <xs:element name="title" type="xs:string" /> <xs:element name="authors" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
These 2 XML trees can be considered equal, if we take indentation and namespace prefixes out of the equation. Note that namespace prefixes also occur in the "type" attributes! The following equality comparison returns true:
def replaceTypeAttributes(elem: Elem): Elem = { elem transformElemsOrSelf { e => e.plusAttributeOption(QName("type"), e.attributeAsResolvedQNameOption(EName("type")).map(_.toString)) } } resolved.Elem.from(replaceTypeAttributes(schemaElem1)).removeAllInterElementWhitespace == resolved.Elem.from(replaceTypeAttributes(schemaElem2)).removeAllInterElementWhitespace
- Alphabetic
- By Inheritance
- Elem
- Serializable
- Serializable
- Product
- Equals
- TransformableElemLike
- TransformableElemApi
- UpdatableElemLike
- UpdatableElemApi
- ClarkElemLike
- IsNavigable
- ElemLike
- Elem
- HasChildNodesApi
- AnyElemNodeApi
- ClarkElemApi
- IsNavigableApi
- ElemApi
- AnyElemApi
- Elem
- CanBeDocumentChild
- CanBeDocumentChild
- Node
- Node
- Node
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
Type Members
-
type
ThisElem = Elem
The element type itself.
The element type itself. It must be restricted to a sub-type of the query API trait in question.
Concrete element classes will restrict this type to that element class itself.
- Definition Classes
- Elem → TransformableElemLike → TransformableElemApi → UpdatableElemLike → UpdatableElemApi → ClarkElemLike → IsNavigable → ElemLike → Elem → HasChildNodesApi → ClarkElemApi → IsNavigableApi → ElemApi → AnyElemApi
-
type
ThisNode = Node
The node type, that is a super-type of the element type, but also of corresponding text node types etc.
The node type, that is a super-type of the element type, but also of corresponding text node types etc.
- Definition Classes
- Elem → Elem → AnyElemNodeApi
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
\(p: (ThisElem) ⇒ Boolean): IndexedSeq[ThisElem]
Shorthand for
filterChildElems(p)
. -
def
\@(expandedName: EName): Option[String]
Shorthand for
attributeOption(expandedName)
.Shorthand for
attributeOption(expandedName)
.- Definition Classes
- ClarkElemLike → ClarkElemApi
-
def
\\(p: (ThisElem) ⇒ Boolean): IndexedSeq[ThisElem]
Shorthand for
filterElemsOrSelf(p)
. -
def
\\!(p: (ThisElem) ⇒ Boolean): IndexedSeq[ThisElem]
Shorthand for
findTopmostElemsOrSelf(p)
. -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
attribute(expandedName: EName): String
Returns the value of the attribute with the given expanded name, and throws an exception otherwise.
Returns the value of the attribute with the given expanded name, and throws an exception otherwise.
- Definition Classes
- ClarkElemLike → ClarkElemApi
-
def
attributeOption(expandedName: EName): Option[String]
Returns the value of the attribute with the given expanded name, if any, wrapped in an
Option
.Returns the value of the attribute with the given expanded name, if any, wrapped in an
Option
.Note that this method can be far more expensive than a custom implementation for a specific element implementation. Therefore this method is non-final and can be overridden.
- Definition Classes
- ClarkElemLike → ClarkElemApi
-
def
childNodeIndex(pathEntry: Entry): Int
Finds the child node index of the given path entry, or -1 if not found.
Finds the child node index of the given path entry, or -1 if not found. More precisely, returns:
collectChildNodeIndexes(Set(pathEntry)).getOrElse(pathEntry, -1)
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
val
children: IndexedSeq[Node]
Returns the child nodes of this element, in the correct order
Returns the child nodes of this element, in the correct order
- Definition Classes
- Elem → UpdatableElemLike → UpdatableElemApi → HasChildNodesApi
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
coalesceAllAdjacentText: Elem
Returns a copy where adjacent text nodes have been combined into one text node, throughout the node tree
-
def
coalesceAllAdjacentTextAndPostprocess(f: (Text) ⇒ Text): Elem
Returns a copy where adjacent text nodes have been combined into one text node, throughout the node tree.
Returns a copy where adjacent text nodes have been combined into one text node, throughout the node tree. After combining the adjacent text nodes, all text nodes are transformed by calling the passed function.
-
def
coalesceAndNormalizeAllText: Elem
Returns a copy where adjacent text nodes have been combined into one text node, and where all text is normalized, throughout the node tree.
Returns a copy where adjacent text nodes have been combined into one text node, and where all text is normalized, throughout the node tree. Same as calling
coalesceAllAdjacentText
followed bynormalizeAllText
, but more efficient. -
def
collectChildNodeIndexes(pathEntries: Set[Entry]): Map[Entry, Int]
Filters the child elements with the given path entries, and returns a Map from the path entries of those filtered elements to the child node indexes.
Filters the child elements with the given path entries, and returns a Map from the path entries of those filtered elements to the child node indexes. The result Map has no entries for path entries that cannot be resolved. This method should be fast, especially if the passed path entry set is small.
- Definition Classes
- Elem → UpdatableElemLike → UpdatableElemApi
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
filterChildElems(p: (ThisElem) ⇒ Boolean): IndexedSeq[ThisElem]
Returns the child elements obeying the given predicate.
-
def
filterElems(p: (ThisElem) ⇒ Boolean): IndexedSeq[ThisElem]
Returns the descendant elements obeying the given predicate, in document order.
-
def
filterElemsOrSelf(p: (ThisElem) ⇒ Boolean): IndexedSeq[ThisElem]
Returns the descendant-or-self elements obeying the given predicate, in document order.
Returns the descendant-or-self elements obeying the given predicate, in document order. This method could be defined as:
def filterElemsOrSelf(p: ThisElem => Boolean): immutable.IndexedSeq[ThisElem] = Vector(this).filter(p) ++ (this.findAllChildElems flatMap (_.filterElemsOrSelf(p)))
It can be proven that the result is equivalent to
findAllElemsOrSelf filter p
. - def filteringAttributes(p: (EName, String) ⇒ Boolean): Elem
- def filteringChildren(p: (Node) ⇒ Boolean): Elem
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
findAllChildElems: IndexedSeq[Elem]
Returns the element children
-
def
findAllChildElemsWithPathEntries: IndexedSeq[(ThisElem, Entry)]
Returns all child elements paired with their path entries.
Returns all child elements paired with their path entries.
This method is final, so more efficient implementations for sub-types are not supported. This implementation is only efficient if finding all child elements as well as computing their resolved names is efficient. That is not the case for DOM wrappers or Scala XML Elem wrappers (due to their expensive Scope computations). On the other hand, those wrapper element implementations are convenient, but not intended for heavy use in production. Hence, this method should typically be fast enough.
- Definition Classes
- ClarkElemLike → IsNavigable → IsNavigableApi
-
def
findAllElems: IndexedSeq[ThisElem]
Returns all descendant elements (not including this element), in document order.
-
def
findAllElemsOrSelf: IndexedSeq[ThisElem]
Returns this element followed by all descendant elements (that is, the descendant-or-self elements), in document order.
-
def
findAttributeByLocalName(localName: String): Option[String]
Returns the first found attribute value of an attribute with the given local name, if any, wrapped in an
Option
.Returns the first found attribute value of an attribute with the given local name, if any, wrapped in an
Option
. Because of differing namespaces, it is possible that more than one such attribute exists, although this is not often the case.Note that this method can be far more expensive than a custom implementation for a specific element implementation. Therefore this method is non-final and can be overridden.
- Definition Classes
- ClarkElemLike → ClarkElemApi
-
def
findChildElem(p: (ThisElem) ⇒ Boolean): Option[ThisElem]
Returns the first found child element obeying the given predicate, if any, wrapped in an
Option
. -
def
findChildElemByPathEntry(entry: Entry): Option[ThisElem]
Finds the child element with the given
Path.Entry
(where this element is the root), if any, wrapped in anOption
.Finds the child element with the given
Path.Entry
(where this element is the root), if any, wrapped in anOption
.This method is final, so more efficient implementations for sub-types are not supported. This implementation is only efficient if finding all child elements as well as computing their resolved names is efficient. That is not the case for DOM wrappers or Scala XML Elem wrappers (due to their expensive Scope computations). On the other hand, those wrapper element implementations are convenient, but not intended for heavy use in production. Hence, this method should typically be fast enough.
- Definition Classes
- ClarkElemLike → IsNavigable → IsNavigableApi
-
def
findElem(p: (ThisElem) ⇒ Boolean): Option[ThisElem]
Returns the first found (topmost) descendant element obeying the given predicate, if any, wrapped in an
Option
. -
def
findElemOrSelf(p: (ThisElem) ⇒ Boolean): Option[ThisElem]
Returns the first found (topmost) descendant-or-self element obeying the given predicate, if any, wrapped in an
Option
. -
def
findElemOrSelfByPath(path: Path): Option[ThisElem]
Finds the element with the given
Path
(where this element is the root), if any, wrapped in anOption
.Finds the element with the given
Path
(where this element is the root), if any, wrapped in anOption
.That is, returns:
findReverseAncestryOrSelfByPath(path).map(_.last)
Note that for each non-empty Path, we have:
findElemOrSelfByPath(path) == findChildElemByPathEntry(path.firstEntry). flatMap(_.findElemOrSelfByPath(path.withoutFirstEntry))
- Definition Classes
- IsNavigable → IsNavigableApi
-
def
findReverseAncestryOrSelfByPath(path: Path): Option[IndexedSeq[ThisElem]]
Finds the reversed ancestry-or-self of the element with the given
Path
(where this element is the root), wrapped in an Option.Finds the reversed ancestry-or-self of the element with the given
Path
(where this element is the root), wrapped in an Option. None is returned if no element can be found at the given Path.Hence, the resulting element collection, if any, starts with this element and ends with the element at the given Path, relative to this element.
This method comes in handy for (efficiently) computing base URIs, where the (reverse) ancestry-or-self is needed as input.
- Definition Classes
- IsNavigable → IsNavigableApi
-
def
findTopmostElems(p: (ThisElem) ⇒ Boolean): IndexedSeq[ThisElem]
Returns the descendant elements obeying the given predicate that have no ancestor obeying the predicate.
-
def
findTopmostElemsOrSelf(p: (ThisElem) ⇒ Boolean): IndexedSeq[ThisElem]
Returns the descendant-or-self elements obeying the given predicate, such that no ancestor obeys the predicate.
Returns the descendant-or-self elements obeying the given predicate, such that no ancestor obeys the predicate. This method could be defined as:
def findTopmostElemsOrSelf(p: ThisElem => Boolean): immutable.IndexedSeq[ThisElem] = if (p(this)) Vector(this) else (this.findAllChildElems flatMap (_.findTopmostElemsOrSelf(p)))
-
def
getChildElem(p: (ThisElem) ⇒ Boolean): ThisElem
Returns the single child element obeying the given predicate, and throws an exception otherwise.
-
def
getChildElemByPathEntry(entry: Entry): ThisElem
Returns (the equivalent of)
findChildElemByPathEntry(entry).get
Returns (the equivalent of)
findChildElemByPathEntry(entry).get
- Definition Classes
- IsNavigable → IsNavigableApi
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
getElemOrSelfByPath(path: Path): ThisElem
Returns (the equivalent of)
findElemOrSelfByPath(path).get
Returns (the equivalent of)
findElemOrSelfByPath(path).get
- Definition Classes
- IsNavigable → IsNavigableApi
-
def
getReverseAncestryOrSelfByPath(path: Path): IndexedSeq[ThisElem]
Returns (the equivalent of)
findReverseAncestryOrSelfByPath(path).get
Returns (the equivalent of)
findReverseAncestryOrSelfByPath(path).get
- Definition Classes
- IsNavigable → IsNavigableApi
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
localName: String
The local name, that is, the local part of the EName
The local name, that is, the local part of the EName
- Definition Classes
- ClarkElemLike → ClarkElemApi
-
def
minusAttribute(attributeName: EName): Elem
Functionally removes the given attribute, if present.
-
def
minusChild(index: Int): ThisElem
Returns a copy in which the child at the given position (0-based) has been removed.
Returns a copy in which the child at the given position (0-based) has been removed. Throws an exception if
index >= children.size
.- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def nodeKind: NodeKind
-
def
normalizeAllText: Elem
Returns a copy where text nodes have been normalized, throughout the node tree.
Returns a copy where text nodes have been normalized, throughout the node tree. Note that it makes little sense to call this method before
coalesceAllAdjacentText
. -
def
normalizedText: String
Returns
XmlStringUtils.normalizeString(text)
.Returns
XmlStringUtils.normalizeString(text)
.- Definition Classes
- ClarkElemLike → ClarkElemApi
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
plusAttribute(attributeName: EName, attributeValue: String): Elem
Functionally adds or updates the given attribute.
-
def
plusAttributeOption(attributeName: EName, attributeValueOption: Option[String]): Elem
Functionally adds or updates the given attribute, if a value is given.
Functionally adds or updates the given attribute, if a value is given. That is, returns
if (attributeValueOption.isEmpty) thisElem else plusAttribute(attributeName, attributeValueOption.get)
. -
def
plusChild(child: ThisNode): ThisElem
Returns a copy in which the given child has been inserted at the end
Returns a copy in which the given child has been inserted at the end
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
plusChild(index: Int, child: ThisNode): ThisElem
Returns a copy in which the given child has been inserted at the given position (0-based).
Returns a copy in which the given child has been inserted at the given position (0-based). If
index == children.size
, adds the element at the end. Ifindex > children.size
, throws an exception.Afterwards, the resulting element indeed has the given child at position
index
(0-based).- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
plusChildOption(childOption: Option[ThisNode]): ThisElem
Returns a copy in which the given child, if any, has been inserted at the end.
Returns a copy in which the given child, if any, has been inserted at the end. That is, returns
plusChild(childOption.get)
if the given optional child element is non-empty.- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
plusChildOption(index: Int, childOption: Option[ThisNode]): ThisElem
Returns a copy in which the given child, if any, has been inserted at the given position (0-based).
Returns a copy in which the given child, if any, has been inserted at the given position (0-based). That is, returns
plusChild(index, childOption.get)
if the given optional child element is non-empty.- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
plusChildren(childSeq: IndexedSeq[ThisNode]): ThisElem
Returns a copy in which the given children have been inserted at the end
Returns a copy in which the given children have been inserted at the end
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
removeAllInterElementWhitespace: Elem
Returns a copy where inter-element whitespace has been removed, throughout the node tree.
Returns a copy where inter-element whitespace has been removed, throughout the node tree.
That is, for each descendant-or-self element determines if it has at least one child element and no non-whitespace text child nodes, and if so, removes all (whitespace) text children.
This method is useful if it is known that whitespace around element nodes is used for formatting purposes, and (in the absence of an XML Schema or DTD) can therefore be treated as "ignorable whitespace". In the case of "mixed content" (if text around element nodes is not all whitespace), this method will not remove any text children of the parent element.
XML space attributes (xml:space) are not respected by this method. If such whitespace preservation functionality is needed, it can be written as a transformation where for specific elements this method is not called.
-
val
resolvedAttributes: Map[EName, String]
The resolved attributes of the element as mapping from ENames to values
The resolved attributes of the element as mapping from ENames to values
- Definition Classes
- Elem → ClarkElemApi
-
val
resolvedName: EName
The EName of the element
The EName of the element
- Definition Classes
- Elem → ClarkElemApi
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
text: String
Returns the concatenation of the texts of text children, including whitespace.
Returns the concatenation of the texts of text children, including whitespace. Non-text children are ignored. If there are no text children, the empty string is returned.
- Definition Classes
- Elem → ClarkElemApi
-
def
textChildren: IndexedSeq[Text]
Returns the text children
-
def
thisElem: ThisElem
This element itself.
This element itself.
- Definition Classes
- Elem → AnyElemApi
-
def
transformAllText(f: (Text) ⇒ Text): Elem
Returns a copy where text nodes have been transformed, throughout the node tree.
-
def
transformChildElems(f: (Elem) ⇒ Elem): Elem
Returns the same element, except that child elements have been replaced by applying the given function.
Returns the same element, except that child elements have been replaced by applying the given function. Non-element child nodes occur in the result element unaltered.
That is, returns the equivalent of:
val newChildren = children map { case e: E => f(e) case n: N => n } withChildren(newChildren)
- Definition Classes
- Elem → TransformableElemLike → TransformableElemApi
-
def
transformChildElemsToNodeSeq(f: (Elem) ⇒ IndexedSeq[Node]): Elem
Returns the same element, except that child elements have been replaced by applying the given function.
Returns the same element, except that child elements have been replaced by applying the given function. Non-element child nodes occur in the result element unaltered.
That is, returns the equivalent of:
val newChildren = children flatMap { case e: E => f(e) case n: N => Vector(n) } withChildren(newChildren)
- Definition Classes
- Elem → TransformableElemLike → TransformableElemApi
-
def
transformElems(f: (ThisElem) ⇒ ThisElem): ThisElem
Transforms the element by applying the given function to all its descendant elements, in a bottom-up manner.
Transforms the element by applying the given function to all its descendant elements, in a bottom-up manner.
That is, returns the equivalent of:
transformChildElems (e => e.transformElemsOrSelf(f))
- Definition Classes
- TransformableElemLike → TransformableElemApi
-
def
transformElemsOrSelf(f: (ThisElem) ⇒ ThisElem): ThisElem
Transforms the element by applying the given function to all its descendant-or-self elements, in a bottom-up manner.
Transforms the element by applying the given function to all its descendant-or-self elements, in a bottom-up manner.
That is, returns the equivalent of:
f(transformChildElems (e => e.transformElemsOrSelf(f)))
In other words, returns the equivalent of:
f(transformElems(f))
- Definition Classes
- TransformableElemLike → TransformableElemApi
-
def
transformElemsOrSelfToNodeSeq(f: (ThisElem) ⇒ IndexedSeq[ThisNode]): IndexedSeq[ThisNode]
Transforms each descendant element to a node sequence by applying the given function to all its descendant-or-self elements, in a bottom-up manner.
Transforms each descendant element to a node sequence by applying the given function to all its descendant-or-self elements, in a bottom-up manner.
That is, returns the equivalent of:
f(transformChildElemsToNodeSeq(e => e.transformElemsOrSelfToNodeSeq(f)))
In other words, returns the equivalent of:
f(transformElemsToNodeSeq(f))
- Definition Classes
- TransformableElemLike → TransformableElemApi
-
def
transformElemsToNodeSeq(f: (ThisElem) ⇒ IndexedSeq[ThisNode]): ThisElem
Transforms each descendant element to a node sequence by applying the given function to all its descendant elements, in a bottom-up manner.
Transforms each descendant element to a node sequence by applying the given function to all its descendant elements, in a bottom-up manner. The function is not applied to this element itself.
That is, returns the equivalent of:
transformChildElemsToNodeSeq(e => e.transformElemsOrSelfToNodeSeq(f))
It is equivalent to the following expression:
transformElemsOrSelf { e => e.transformChildElemsToNodeSeq(che => f(che)) }
- Definition Classes
- TransformableElemLike → TransformableElemApi
-
def
trimmedText: String
Returns
text.trim
.Returns
text.trim
.- Definition Classes
- ClarkElemLike → ClarkElemApi
-
def
updateChildElem(pathEntry: Entry, newElem: ThisElem): ThisElem
Returns
updateChildElem(pathEntry) { e => newElem }
Returns
updateChildElem(pathEntry) { e => newElem }
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
updateChildElem(pathEntry: Entry)(f: (ThisElem) ⇒ ThisElem): ThisElem
Functionally updates the tree with this element as root element, by applying the passed function to the element that has the given eu.cdevreeze.yaidom.core.Path.Entry (compared to this element as root).
Functionally updates the tree with this element as root element, by applying the passed function to the element that has the given eu.cdevreeze.yaidom.core.Path.Entry (compared to this element as root).
It can be defined as follows:
updateChildElems(Set(pathEntry)) { case (che, pe) => f(che) }
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
updateChildElemWithNodeSeq(pathEntry: Entry, newNodes: IndexedSeq[ThisNode]): ThisElem
Returns
updateChildElemWithNodeSeq(pathEntry) { e => newNodes }
Returns
updateChildElemWithNodeSeq(pathEntry) { e => newNodes }
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
updateChildElemWithNodeSeq(pathEntry: Entry)(f: (ThisElem) ⇒ IndexedSeq[ThisNode]): ThisElem
Functionally updates the tree with this element as root element, by applying the passed function to the element that has the given eu.cdevreeze.yaidom.core.Path.Entry (compared to this element as root).
Functionally updates the tree with this element as root element, by applying the passed function to the element that has the given eu.cdevreeze.yaidom.core.Path.Entry (compared to this element as root).
It can be defined as follows:
updateChildElemsWithNodeSeq(Set(pathEntry)) { case (che, pe) => f(che) }
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
updateChildElems(pathEntries: Set[Entry])(f: (ThisElem, Entry) ⇒ ThisElem): ThisElem
Updates the child elements with the given path entries, applying the passed update function.
Updates the child elements with the given path entries, applying the passed update function.
That is, returns the equivalent of:
updateChildElemsWithNodeSeq(pathEntries) { case (che, pe) => Vector(f(che, pe)) }
If the set of path entries is small, this method is rather efficient.
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
updateChildElemsWithNodeSeq(pathEntries: Set[Entry])(f: (ThisElem, Entry) ⇒ IndexedSeq[ThisNode]): ThisElem
Updates the child elements with the given path entries, applying the passed update function.
Updates the child elements with the given path entries, applying the passed update function. This is the core method of the update API, and the other methods have implementations that directly or indirectly depend on this method.
That is, returns:
if (pathEntries.isEmpty) self else { val indexesByPathEntries: Seq[(Path.Entry, Int)] = collectChildNodeIndexes(pathEntries).toSeq.sortBy(_._2) // Updating in reverse order of indexes, in order not to invalidate the path entries val newChildren = indexesByPathEntries.reverse.foldLeft(self.children) { case (accChildNodes, (pathEntry, idx)) => val che = accChildNodes(idx).asInstanceOf[ThisElem] accChildNodes.patch(idx, f(che, pathEntry), 1) } self.withChildren(newChildren) }
If the set of path entries is small, this method is rather efficient.
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
updateElemOrSelf(path: Path, newElem: ThisElem): ThisElem
Returns
updateElemOrSelf(path) { e => newElem }
Returns
updateElemOrSelf(path) { e => newElem }
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
updateElemOrSelf(path: Path)(f: (ThisElem) ⇒ ThisElem): ThisElem
Functionally updates the tree with this element as root element, by applying the passed function to the element that has the given eu.cdevreeze.yaidom.core.Path (compared to this element as root).
Functionally updates the tree with this element as root element, by applying the passed function to the element that has the given eu.cdevreeze.yaidom.core.Path (compared to this element as root).
It can be defined as follows:
updateElemsOrSelf(Set(path)) { case (e, path) => f(e) }
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
updateElemWithNodeSeq(path: Path, newNodes: IndexedSeq[ThisNode]): ThisElem
Returns
updateElemWithNodeSeq(path) { e => newNodes }
Returns
updateElemWithNodeSeq(path) { e => newNodes }
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
updateElemWithNodeSeq(path: Path)(f: (ThisElem) ⇒ IndexedSeq[ThisNode]): ThisElem
Functionally updates the tree with this element as root element, by applying the passed function to the element that has the given eu.cdevreeze.yaidom.core.Path (compared to this element as root).
Functionally updates the tree with this element as root element, by applying the passed function to the element that has the given eu.cdevreeze.yaidom.core.Path (compared to this element as root). If the given path is the root path, this element itself is returned unchanged.
This function could be defined as follows:
updateElemsWithNodeSeq(Set(path)) { case (e, path) => f(e) }
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
updateElems(paths: Set[Path])(f: (ThisElem, Path) ⇒ ThisElem): ThisElem
Updates the descendant elements with the given paths, applying the passed update function.
Updates the descendant elements with the given paths, applying the passed update function.
That is, returns:
val pathsByFirstEntry: Map[Path.Entry, Set[Path]] = paths.filterNot(_.isEmpty).groupBy(_.firstEntry) updateChildElems(pathsByFirstEntry.keySet) { case (che, pathEntry) => che.updateElemsOrSelf(pathsByFirstEntry(pathEntry).map(_.withoutFirstEntry)) { case (elm, path) => f(elm, path.prepend(pathEntry)) } }
If the set of paths is small, this method is rather efficient.
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
updateElemsOrSelf(paths: Set[Path])(f: (ThisElem, Path) ⇒ ThisElem): ThisElem
Updates the descendant-or-self elements with the given paths, applying the passed update function.
Updates the descendant-or-self elements with the given paths, applying the passed update function.
That is, returns:
val pathsByFirstEntry: Map[Path.Entry, Set[Path]] = paths.filterNot(_.isEmpty).groupBy(_.firstEntry) val descendantUpdateResult = updateChildElems(pathsByFirstEntry.keySet) { case (che, pathEntry) => // Recursive (but non-tail-recursive) call che.updateElemsOrSelf(pathsByFirstEntry(pathEntry).map(_.withoutFirstEntry)) { case (elm, path) => f(elm, path.prepend(pathEntry)) } } if (paths.contains(Path.Empty)) f(descendantUpdateResult, Path.Empty) else descendantUpdateResult
In other words, returns:
val descendantUpdateResult = updateElems(paths)(f) if (paths.contains(Path.Empty)) f(descendantUpdateResult, Path.Empty) else descendantUpdateResult
If the set of paths is small, this method is rather efficient.
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
updateElemsOrSelfWithNodeSeq(paths: Set[Path])(f: (ThisElem, Path) ⇒ IndexedSeq[ThisNode]): IndexedSeq[ThisNode]
Updates the descendant-or-self elements with the given paths, applying the passed update function.
Updates the descendant-or-self elements with the given paths, applying the passed update function.
That is, returns:
val pathsByFirstEntry: Map[Path.Entry, Set[Path]] = paths.filterNot(_.isEmpty).groupBy(_.firstEntry) val descendantUpdateResult = updateChildElemsWithNodeSeq(pathsByFirstEntry.keySet) { case (che, pathEntry) => // Recursive (but non-tail-recursive) call che.updateElemsOrSelfWithNodeSeq( pathsByFirstEntry(pathEntry).map(_.withoutFirstEntry)) { case (elm, path) => f(elm, path.prepend(pathEntry)) } } if (paths.contains(Path.Empty)) f(descendantUpdateResult, Path.Empty) else Vector(descendantUpdateResult)
In other words, returns:
val descendantUpdateResult = updateElemsWithNodeSeq(paths)(f) if (paths.contains(Path.Empty)) f(descendantUpdateResult, Path.Empty) else Vector(descendantUpdateResult)
If the set of paths is small, this method is rather efficient.
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
updateElemsWithNodeSeq(paths: Set[Path])(f: (ThisElem, Path) ⇒ IndexedSeq[ThisNode]): ThisElem
Updates the descendant elements with the given paths, applying the passed update function.
Updates the descendant elements with the given paths, applying the passed update function.
That is, returns:
val pathsByFirstEntry: Map[Path.Entry, Set[Path]] = paths.filterNot(_.isEmpty).groupBy(_.firstEntry) updateChildElemsWithNodeSeq(pathsByFirstEntry.keySet) { case (che, pathEntry) => che.updateElemsOrSelfWithNodeSeq( pathsByFirstEntry(pathEntry).map(_.withoutFirstEntry)) { case (elm, path) => f(elm, path.prepend(pathEntry)) } }
If the set of paths is small, this method is rather efficient.
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
withAttributes(newAttributes: Map[EName, String]): Elem
Creates a copy, but with the attributes passed as parameter
newAttributes
-
def
withChildSeqs(newChildSeqs: IndexedSeq[IndexedSeq[ThisNode]]): ThisElem
Shorthand for
withChildren(newChildSeqs.flatten)
Shorthand for
withChildren(newChildSeqs.flatten)
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
withChildren(newChildren: IndexedSeq[Node]): Elem
Creates a copy, but with (only) the children passed as parameter
newChildren
Creates a copy, but with (only) the children passed as parameter
newChildren
- Definition Classes
- Elem → UpdatableElemLike → UpdatableElemApi
-
def
withPatchedChildren(from: Int, newChildren: IndexedSeq[ThisNode], replace: Int): ThisElem
Shorthand for
withChildren(children.patch(from, newChildren, replace))
Shorthand for
withChildren(children.patch(from, newChildren, replace))
- Definition Classes
- UpdatableElemLike → UpdatableElemApi
-
def
withUpdatedChildren(index: Int, newChild: ThisNode): ThisElem
Shorthand for
withChildren(children.updated(index, newChild))
Shorthand for
withChildren(children.updated(index, newChild))
- Definition Classes
- UpdatableElemLike → UpdatableElemApi