Trait/Object

eu.cdevreeze.yaidom.queryapi

ElemUpdateLike

Related Docs: object ElemUpdateLike | package queryapi

Permalink

trait ElemUpdateLike extends ElemUpdateApi

This is the partially implemented (functional) element update API, as function API instead of OO API. That is, this is the function API corresponding to trait eu.cdevreeze.yaidom.queryapi.UpdatableElemLike.

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

Type Members

  1. abstract type ElemType <: NodeType

    Permalink
    Definition Classes
    ElemUpdateLikeElemUpdateApi
  2. abstract type NodeType

    Permalink
    Definition Classes
    ElemUpdateLikeElemUpdateApi

Abstract Value Members

  1. abstract def children(elem: ElemType): IndexedSeq[NodeType]

    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
    ElemUpdateLikeElemUpdateApi
  2. abstract def collectChildNodeIndexes(elem: ElemType, 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
    ElemUpdateLikeElemUpdateApi
  3. abstract def findAllChildElemsWithPathEntries(elem: ElemType): IndexedSeq[(ElemType, Entry)]

    Permalink

    Returns all child elements paired with their path entries.

    Returns all child elements paired with their path entries.

    Definition Classes
    ElemUpdateLikeElemUpdateApi
  4. abstract def withChildren(elem: ElemType, newChildren: IndexedSeq[NodeType]): ElemType

    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
    ElemUpdateLikeElemUpdateApi

Concrete 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: ElemType, 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
    ElemUpdateLikeElemUpdateApi
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

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

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

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

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

    Permalink
    Definition Classes
    Any
  13. final def minusChild(elem: ElemType, index: Int): ElemType

    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
    ElemUpdateLikeElemUpdateApi
  14. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  17. final def plusChild(elem: ElemType, child: NodeType): ElemType

    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
    ElemUpdateLikeElemUpdateApi
  18. final def plusChild(elem: ElemType, index: Int, child: NodeType): ElemType

    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
    ElemUpdateLikeElemUpdateApi
  19. final def plusChildOption(elem: ElemType, childOption: Option[NodeType]): ElemType

    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
    ElemUpdateLikeElemUpdateApi
  20. final def plusChildOption(elem: ElemType, index: Int, childOption: Option[NodeType]): ElemType

    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
    ElemUpdateLikeElemUpdateApi
  21. final def plusChildren(elem: ElemType, childSeq: IndexedSeq[NodeType]): ElemType

    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
    ElemUpdateLikeElemUpdateApi
  22. final def synchronized[T0](arg0: ⇒ T0): T0

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

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

    Permalink

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

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

    Definition Classes
    ElemUpdateLikeElemUpdateApi
  25. final def updateChildElem(elem: ElemType, pathEntry: Entry)(f: (ElemType) ⇒ ElemType): ElemType

    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
    ElemUpdateLikeElemUpdateApi
  26. final def updateChildElemWithNodeSeq(elem: ElemType, pathEntry: Entry, newNodes: IndexedSeq[NodeType]): ElemType

    Permalink

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

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

    Definition Classes
    ElemUpdateLikeElemUpdateApi
  27. final def updateChildElemWithNodeSeq(elem: ElemType, pathEntry: Entry)(f: (ElemType) ⇒ IndexedSeq[NodeType]): ElemType

    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
    ElemUpdateLikeElemUpdateApi
  28. final def updateChildElems(elem: ElemType, f: (ElemType, Entry) ⇒ Option[ElemType]): ElemType

    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, ElemType] =
      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
    ElemUpdateLikeElemUpdateApi
  29. final def updateChildElems(elem: ElemType, pathEntries: Set[Entry])(f: (ElemType, Entry) ⇒ ElemType): ElemType

    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
    ElemUpdateLikeElemUpdateApi
  30. final def updateChildElemsWithNodeSeq(elem: ElemType, f: (ElemType, Entry) ⇒ Option[IndexedSeq[NodeType]]): ElemType

    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[NodeType]] =
      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
    ElemUpdateLikeElemUpdateApi
  31. final def updateChildElemsWithNodeSeq(elem: ElemType, pathEntries: Set[Entry])(f: (ElemType, Entry) ⇒ IndexedSeq[NodeType]): ElemType

    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[ElemType]
          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
    ElemUpdateLikeElemUpdateApi
  32. final def updateElemOrSelf(elem: ElemType, path: Path, newElem: ElemType): ElemType

    Permalink

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

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

    Definition Classes
    ElemUpdateLikeElemUpdateApi
  33. final def updateElemOrSelf(elem: ElemType, path: Path)(f: (ElemType) ⇒ ElemType): ElemType

    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
    ElemUpdateLikeElemUpdateApi
  34. final def updateElemWithNodeSeq(elem: ElemType, path: Path, newNodes: IndexedSeq[NodeType]): ElemType

    Permalink

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

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

    Definition Classes
    ElemUpdateLikeElemUpdateApi
  35. final def updateElemWithNodeSeq(elem: ElemType, path: Path)(f: (ElemType) ⇒ IndexedSeq[NodeType]): ElemType

    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
    ElemUpdateLikeElemUpdateApi
  36. final def updateElems(elem: ElemType, paths: Set[Path])(f: (ElemType, Path) ⇒ ElemType): ElemType

    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
    ElemUpdateLikeElemUpdateApi
  37. final def updateElemsOrSelf(elem: ElemType, paths: Set[Path])(f: (ElemType, Path) ⇒ ElemType): ElemType

    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
    ElemUpdateLikeElemUpdateApi
  38. final def updateElemsOrSelfWithNodeSeq(elem: ElemType, paths: Set[Path])(f: (ElemType, Path) ⇒ IndexedSeq[NodeType]): IndexedSeq[NodeType]

    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
    ElemUpdateLikeElemUpdateApi
  39. final def updateElemsWithNodeSeq(elem: ElemType, paths: Set[Path])(f: (ElemType, Path) ⇒ IndexedSeq[NodeType]): ElemType

    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
    ElemUpdateLikeElemUpdateApi
  40. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  43. final def withChildSeqs(elem: ElemType, newChildSeqs: IndexedSeq[IndexedSeq[NodeType]]): ElemType

    Permalink

    Shorthand for withChildren(elem, newChildSeqs.flatten)

    Shorthand for withChildren(elem, newChildSeqs.flatten)

    Definition Classes
    ElemUpdateLikeElemUpdateApi
  44. final def withPatchedChildren(elem: ElemType, from: Int, newChildren: IndexedSeq[NodeType], replace: Int): ElemType

    Permalink

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

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

    Definition Classes
    ElemUpdateLikeElemUpdateApi
  45. final def withUpdatedChildren(elem: ElemType, index: Int, newChild: NodeType): ElemType

    Permalink

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

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

    Definition Classes
    ElemUpdateLikeElemUpdateApi

Inherited from ElemUpdateApi

Inherited from AnyRef

Inherited from Any

Ungrouped