trait Splitter[In, +C] extends AnyRef
Primary "spac" abstraction that acts as a selector for sub-streams within a single input stream.
A "sub-stream" is some series of consecutive values from the original stream, identified by a "context" value. Sub-streams do not overlap with each other.
For example, when handling a stream of XML events, you might want to create a Splitter that identifies
the events representing elements at a specific location within the XML; something like an XPATH that operates on streams.
When using xml-spac
, you might construct a splitter like Splitter.xml("rootElem" \ "things" \ "thing")
.
This would identify a new sub-stream for each <thing>
element that appears inside a <things>
element, inside the <rootElem>
element.
An example sub-stream for a <thing>
element might be ElemStart("thing"), Text("hello"), ElemEnd("thing")
.
A Splitter's general goal is to attach a Parser or Transformer to each sub-stream, passing the contents of that sub-stream
through the attached Parser or Transformer in order to get an interpretation of that sub-stream (i.e. the Parser's result,
or some emitted outputs from a Transformer).
With the <thing>
example above, you might attach a parser that concatenates the context all Text events it sees.
I.e. XmlParser.forText
. Since a separate parser handler will run for each sub-stream, this becomes something like
"A stream of Strings which each represent the concatenated text from an individual <thing>
element".
- In
Data event type for the input stream
- C
Context type used to identify each sub-stream
- Source
- Splitter.scala
- Alphabetic
- By Inheritance
- Splitter
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Abstract Value Members
- abstract def addBoundaries: Transformer[In, Either[ContextChange[In, C], In]]
Inject "boundary" events into an input stream, where a
ContextPush
represents the beginning of a new sub-stream, and aContextPop
represents the end of a sub-stream.Inject "boundary" events into an input stream, where a
ContextPush
represents the beginning of a new sub-stream, and aContextPop
represents the end of a sub-stream.- returns
A transformer that injects the boundary events into any given input stream
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- def ->[B](y: B): (Splitter[In, C], B)
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def as[Out](implicit parser: Parser[In, Out]): Transformer[In, Out]
Like
joinBy
, but the parser is passed implicitly - final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def ensuring(cond: (Splitter[In, C]) => Boolean, msg: => Any): Splitter[In, C]
- def ensuring(cond: (Splitter[In, C]) => Boolean): Splitter[In, C]
- def ensuring(cond: Boolean, msg: => Any): Splitter[In, C]
- def ensuring(cond: Boolean): Splitter[In, C]
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def flatMap[Out](transformMatches: (ContextPush[In, C]) => Transformer[In, Out]): Transformer[In, Out]
Creates a new transformer by attaching an "inner" transformer to each sub-stream based on the sub-stream context.
Creates a new transformer by attaching an "inner" transformer to each sub-stream based on the sub-stream context. For each sub-stream, a new transformer will be created, and the inputs from the sub-stream will be piped into the inner transformer. Anything that the inner transformer emits will be emitted by the returned transformer.
- def formatted(fmtstr: String): String
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def joinBy[Out](parser: Parser[In, Out]): Transformer[In, Out]
Like
map
, but when you want to use the same parser for each sub-stream, regardless of the context value - def map[Out](parseMatches: (C) => Parser[In, Out]): Transformer[In, Out]
Creates a new transformer by attaching a new parser to each sub-stream based on the sub-stream context.
Creates a new transformer by attaching a new parser to each sub-stream based on the sub-stream context. For each sub-stream, a new parser will be created, and inputs from the sub-stream will be piped into that parser. When the sub-stream ends, or if the parser finishes on its own, the parser's result will be emitted as an
Out
event.- Out
The parser's output type
- parseMatches
Given the context for a sub-stream, return a parser to handle that sub-stream
- returns
A transformer that will emit the result of each parsed sub-stream
- def mapTraced[Out](parseMatches: (ContextPush[In, C]) => Parser[In, Out]): Transformer[In, Out]
Like
map
, but using theContextPush
associated with the sub-stream, instead of just the context value itself. - final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
Deprecated Value Members
- def →[B](y: B): (Splitter[In, C], B)
- Implicit
- This member is added by an implicit conversion from Splitter[In, C] toArrowAssoc[Splitter[In, C]] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
->
instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.