Object

eu.cdevreeze.yaidom.indexed.Elem

ElemUpdates

Related Doc: package Elem

Permalink

object ElemUpdates extends ElemUpdateLike

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ElemUpdates
  2. ElemUpdateLike
  3. ElemUpdateApi
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type Elem = IndexedScopedNode.Elem[simple.Elem]

    Permalink
    Definition Classes
    ElemUpdates → ElemUpdateLike → ElemUpdateApi
  2. type Node = IndexedScopedNode.Node

    Permalink
    Definition Classes
    ElemUpdates → ElemUpdateLike → ElemUpdateApi

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. final def childNodeIndex(elem: Elem, pathEntry: Entry): Int

    Permalink

    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(elem, Set(pathEntry)).getOrElse(pathEntry, -1)
    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  6. def children(elem: Elem): IndexedSeq[Node]

    Permalink

    Returns the child nodes of this element, in the correct order

    Returns the child nodes of this element, in the correct order

    Definition Classes
    ElemUpdates → ElemUpdateLike → ElemUpdateApi
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def collectChildNodeIndexes(elem: Elem, pathEntries: Set[Entry]): Map[Entry, Int]

    Permalink

    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
    ElemUpdates → ElemUpdateLike → ElemUpdateApi
  9. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. def findAllChildElemsWithPathEntries(elem: Elem): IndexedSeq[(Elem, Entry)]

    Permalink

    Returns all child elements paired with their path entries.

    Returns all child elements paired with their path entries.

    Definition Classes
    ElemUpdates → ElemUpdateLike → ElemUpdateApi
  13. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  15. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  16. final def minusChild(elem: Elem, index: Int): Elem

    Permalink

    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(elem).size.

    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  17. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  18. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. final def plusChild(elem: Elem, child: Node): Elem

    Permalink

    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
    ElemUpdateLike → ElemUpdateApi
  21. final def plusChild(elem: Elem, index: Int, child: Node): Elem

    Permalink

    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(elem).size, adds the element at the end. If index > children(elem).size, throws an exception.

    Afterwards, the resulting element indeed has the given child at position index (0-based).

    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  22. final def plusChildOption(elem: Elem, childOption: Option[Node]): Elem

    Permalink

    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(elem, childOption.get) if the given optional child element is non-empty.

    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  23. final def plusChildOption(elem: Elem, index: Int, childOption: Option[Node]): Elem

    Permalink

    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(elem, index, childOption.get) if the given optional child element is non-empty.

    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  24. final def plusChildren(elem: Elem, childSeq: IndexedSeq[Node]): Elem

    Permalink

    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
    ElemUpdateLike → ElemUpdateApi
  25. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  26. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  27. final def updateChildElem(elem: Elem, pathEntry: Entry, newElem: Elem): Elem

    Permalink

    Returns updateChildElem(elem, pathEntry) { e => newElem }

    Returns updateChildElem(elem, pathEntry) { e => newElem }

    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  28. final def updateChildElem(elem: Elem, pathEntry: Entry)(f: (Elem) ⇒ Elem): Elem

    Permalink

    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(elem, Set(pathEntry)) { case (che, pe) => f(che) }
    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  29. final def updateChildElemWithNodeSeq(elem: Elem, pathEntry: Entry, newNodes: IndexedSeq[Node]): Elem

    Permalink

    Returns updateChildElemWithNodeSeq(elem, pathEntry) { e => newNodes }

    Returns updateChildElemWithNodeSeq(elem, pathEntry) { e => newNodes }

    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  30. final def updateChildElemWithNodeSeq(elem: Elem, pathEntry: Entry)(f: (Elem) ⇒ IndexedSeq[Node]): Elem

    Permalink

    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(elem, Set(pathEntry)) { case (che, pe) => f(che) }
    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  31. final def updateChildElems(elem: Elem, f: (Elem, Entry) ⇒ Option[Elem]): Elem

    Permalink

    Invokes updateChildElems, passing the path entries for which the passed function is defined.

    Invokes updateChildElems, passing the path entries for which the passed function is defined. It is equivalent to:

    val editsByPathEntries: Map[Path.Entry, Elem] =
      findAllChildElemsWithPathEntries(elem).flatMap({ case (che, pe) => f(che, pe).map(newE => (pe, newE)) }).toMap
    
    updateChildElems(elem, editsByPathEntries.keySet) { case (che, pe) => editsByPathEntries.getOrElse(pe, che) }
    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  32. final def updateChildElems(elem: Elem, pathEntries: Set[Entry])(f: (Elem, Entry) ⇒ Elem): Elem

    Permalink

    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(elem, pathEntries) { case (che, pe) => Vector(f(che, pe)) }

    If the set of path entries is small, this method is rather efficient.

    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  33. final def updateChildElemsWithNodeSeq(elem: Elem, f: (Elem, Entry) ⇒ Option[IndexedSeq[Node]]): Elem

    Permalink

    Invokes updateChildElemsWithNodeSeq, passing the path entries for which the passed function is defined.

    Invokes updateChildElemsWithNodeSeq, passing the path entries for which the passed function is defined. It is equivalent to:

    val editsByPathEntries: Map[Path.Entry, immutable.IndexedSeq[Node]] =
      findAllChildElemsWithPathEntries(elem).flatMap({ case (che, pe) => f(che, pe).map(newNodes => (pe, newNodes)) }).toMap
    
    updateChildElemsWithNodeSeq(elem, editsByPathEntries.keySet) { case (che, pe) =>
      editsByPathEntries.getOrElse(pe, immutable.IndexedSeq(che))
    }
    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  34. final def updateChildElemsWithNodeSeq(elem: Elem, pathEntries: Set[Entry])(f: (Elem, Entry) ⇒ IndexedSeq[Node]): Elem

    Permalink

    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) elem
    else {
      val indexesByPathEntries: Seq[(Path.Entry, Int)] =
        collectChildNodeIndexes(elem, pathEntries).toSeq.sortBy(_._2)
    
      // Updating in reverse order of indexes, in order not to invalidate the path entries
      val newChildren = indexesByPathEntries.reverse.foldLeft(children(elem)) {
        case (accChildNodes, (pathEntry, idx)) =>
          val che = accChildNodes(idx).asInstanceOf[Elem]
          accChildNodes.patch(idx, f(che, pathEntry), 1)
      }
      withChildren(elem, newChildren)
    }

    If the set of path entries is small, this method is rather efficient.

    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  35. final def updateElemOrSelf(elem: Elem, path: Path, newElem: Elem): Elem

    Permalink

    Returns updateElemOrSelf(elem, path) { e => newElem }

    Returns updateElemOrSelf(elem, path) { e => newElem }

    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  36. final def updateElemOrSelf(elem: Elem, path: Path)(f: (Elem) ⇒ Elem): Elem

    Permalink

    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(elem, Set(path)) { case (e, path) => f(e) }
    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  37. final def updateElemWithNodeSeq(elem: Elem, path: Path, newNodes: IndexedSeq[Node]): Elem

    Permalink

    Returns updateElemWithNodeSeq(elem, path) { e => newNodes }

    Returns updateElemWithNodeSeq(elem, path) { e => newNodes }

    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  38. final def updateElemWithNodeSeq(elem: Elem, path: Path)(f: (Elem) ⇒ IndexedSeq[Node]): Elem

    Permalink

    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(elem, Set(path)) { case (e, path) => f(e) }
    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  39. final def updateElems(elem: Elem, paths: Set[Path])(f: (Elem, Path) ⇒ Elem): Elem

    Permalink

    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(elem, pathsByFirstEntry.keySet) {
      case (che, pathEntry) =>
        updateElemsOrSelf(che, 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
    ElemUpdateLike → ElemUpdateApi
  40. final def updateElemsOrSelf(elem: Elem, paths: Set[Path])(f: (Elem, Path) ⇒ Elem): Elem

    Permalink

    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(elem, pathsByFirstEntry.keySet) {
        case (che, pathEntry) =>
          // Recursive (but non-tail-recursive) call
          updateElemsOrSelf(che, 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(elem, 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
    ElemUpdateLike → ElemUpdateApi
  41. final def updateElemsOrSelfWithNodeSeq(elem: Elem, paths: Set[Path])(f: (Elem, Path) ⇒ IndexedSeq[Node]): IndexedSeq[Node]

    Permalink

    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(elem, pathsByFirstEntry.keySet) {
        case (che, pathEntry) =>
          // Recursive (but non-tail-recursive) call
          updateElemsOrSelfWithNodeSeq(che, 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(elem, 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
    ElemUpdateLike → ElemUpdateApi
  42. final def updateElemsWithNodeSeq(elem: Elem, paths: Set[Path])(f: (Elem, Path) ⇒ IndexedSeq[Node]): Elem

    Permalink

    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(elem, pathsByFirstEntry.keySet) {
      case (che, pathEntry) =>
        updateElemsOrSelfWithNodeSeq(che, 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
    ElemUpdateLike → ElemUpdateApi
  43. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  44. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  45. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  46. final def withChildSeqs(elem: Elem, newChildSeqs: IndexedSeq[IndexedSeq[Node]]): Elem

    Permalink

    Shorthand for withChildren(elem, newChildSeqs.flatten)

    Shorthand for withChildren(elem, newChildSeqs.flatten)

    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  47. def withChildren(elem: Elem, newChildren: IndexedSeq[Node]): Elem

    Permalink

    Returns an element with the same name, attributes and scope as this element, but with the given child nodes

    Returns an element with the same name, attributes and scope as this element, but with the given child nodes

    Definition Classes
    ElemUpdates → ElemUpdateLike → ElemUpdateApi
  48. final def withPatchedChildren(elem: Elem, from: Int, newChildren: IndexedSeq[Node], replace: Int): Elem

    Permalink

    Shorthand for withChildren(elem, children(elem).patch(from, newChildren, replace))

    Shorthand for withChildren(elem, children(elem).patch(from, newChildren, replace))

    Definition Classes
    ElemUpdateLike → ElemUpdateApi
  49. final def withUpdatedChildren(elem: Elem, index: Int, newChild: Node): Elem

    Permalink

    Shorthand for withChildren(elem, children(elem).updated(index, newChild))

    Shorthand for withChildren(elem, children(elem).updated(index, newChild))

    Definition Classes
    ElemUpdateLike → ElemUpdateApi

Inherited from ElemUpdateLike

Inherited from ElemUpdateApi

Inherited from AnyRef

Inherited from Any

Ungrouped