SingleItemContextMatcher

trait SingleItemContextMatcher[Item, +A] extends ContextMatcher[Item, A]

Specialization of ContextMatcher which only checks the first element in the stack for matching operations. Transformation operations on single-element matchers will yield other single-element matchers (rather than the base ContextMatcher type). Combination operations involving other single-element matchers will also yield single-element matchers. SingleElementContextMatchers form the building blocks of more complex matchers.

Type parameters:
A

The type of the matched context.

Companion:
object
trait ContextMatcher[Item, A]
class Object
trait Matchable
class Any
class And[Item, A, B, R]
class Default[Item, A]
class Mapped[Item, A, B]
class Or[Item, A]
class Predicate[Item]

Value members

Abstract methods

def applyElem(elem: Item): Option[A]

The matching operation for single-element matchers.

The matching operation for single-element matchers.

Value parameters:
elem

The first element in the XML tag stack

Returns:

Some(context) for a successful match, None otherwise

Concrete methods

def &[A1 >: A, B, R](that: SingleItemContextMatcher[Item, B])(implicit reduce: Aux[A1, B, R]): SingleItemContextMatcher[Item, R]

Operator version of and

Operator version of and

def and[A1 >: A, B, R](that: SingleItemContextMatcher[Item, B])(implicit reduce: Aux[A1, B, R]): SingleItemContextMatcher[Item, R]

Creates a new single-element matcher which combines the results of both this matcher and that matcher. Both this and that will operate on the first element of the stack (as opposed to Chained matchers).

Creates a new single-element matcher which combines the results of both this matcher and that matcher. Both this and that will operate on the first element of the stack (as opposed to Chained matchers).

Type parameters:
A1

To satisfy covariance on A

B

The other matcher's result type

R

The combined result type

Value parameters:
reduce

The TypeReduce rule for combining the two match results

that

The matcher to combine

Returns:

A new matcher which combines the results of this and that

def applyChained[B](stack: IndexedSeq[Item], offset: Int, avail: Int, next: ContextMatcher[Item, B]): Option[(A, B)]
override def filter(p: A => Boolean): SingleItemContextMatcher[Item, A]
Definition Classes
override def flatMap[B](f: A => Option[B]): SingleItemContextMatcher[Item, B]
Definition Classes
override def map[B](f: A => B): SingleItemContextMatcher[Item, B]
Definition Classes
def or[A2 >: A](that: SingleItemContextMatcher[Item, A2]): SingleItemContextMatcher[Item, A2]

Specialization of the default or method, specifically for SingleElementContextMatchers

Specialization of the default or method, specifically for SingleElementContextMatchers

def |[A2 >: A](that: SingleItemContextMatcher[Item, A2]): SingleItemContextMatcher[Item, A2]

Operator version of or, specialized for SingleElementContextMatchers

Operator version of or, specialized for SingleElementContextMatchers

Inherited methods

def \[A1 >: A, B, R](next: ContextMatcher[Item, B])(implicit reduce: Aux[A1, B, R]): ContextMatcher[Item, R]

Create a new matcher by forming a chain with this matcher at the front, and the next matcher at the back. In other words, a matcher for a context within another context.

Create a new matcher by forming a chain with this matcher at the front, and the next matcher at the back. In other words, a matcher for a context within another context.

Type parameters:
A1

To satisfy covariance on A

B

The next matcher's context type

R

The "reduced" content type, derived from the tuple type (A, B) based on the reduce rule.

Value parameters:
next

A matcher which will be used to match the "inner" context

reduce

The TypeReduce rule to help omit Unit from the resulting context type

Returns:

A matcher which delegates to this matcher first, then the next matcher for the remaining stack.

Inherited from:
ContextMatcher
def apply(stack: IndexedSeq[Item], offset: Int, avail: Int): Option[A]

The main context match method.

The main context match method.

Inspects the elements in the XML "tag stack", which is essentially a List[StartElement], but for performance reasons is represented as an array with an "offset" index and a number of available elements from that offset. If the elements correspond to a context value of A, the implementation must then pass the remaining elements of the stack to the next matcher, i.e. by calling next(stack, offset + numConsumed, avail - numConsumed).

The difference between this method and applyChained is the lack of the next parameter; in this method, the current matcher is assumed to be the end of the chain.

Value parameters:
avail

The number of elements available in the stack starting from the offset.

offset

The index of the first element to be considered by the matching logic. From this method's point of view, the "first" element in the stack is actually at stack(offset)

stack

A reference to the complete XML "tag stack". Note that the responsibility of this method is limited to a slice of this value, as defined by offset and avail.

Returns:

An option containing the successfully-matched context, or None.

Inherited from:
ContextMatcher
def or[A2 >: A](that: ContextMatcher[Item, A2]): ContextMatcher[Item, A2]

Create a new ContextMatcher which will fall back to a second matcher in the event that this matcher fails to match a context.

Create a new ContextMatcher which will fall back to a second matcher in the event that this matcher fails to match a context.

Type parameters:
A2

The resulting context type (common supertype between this matcher and that)

Value parameters:
that

The matcher which will be used as the fallback

Returns:

A matcher that falls back to another matcher in case of failure

Inherited from:
ContextMatcher
def |[A2 >: A](that: ContextMatcher[Item, A2]): ContextMatcher[Item, A2]

Operator version of or

Operator version of or

Inherited from:
ContextMatcher