Packages

  • package root
    Definition Classes
    root
  • package io
    Definition Classes
    root
  • package dylemma
    Definition Classes
    io
  • package spac

    SPaC (short for "Streaming Parser Combinators") is a library for building stream consumers in a declarative style, specialized for tree-like data types like XML and JSON.

    SPaC (short for "Streaming Parser Combinators") is a library for building stream consumers in a declarative style, specialized for tree-like data types like XML and JSON.

    Many utilities for handling XML and JSON data involve parsing the entire "document" to some DOM model, then inspecting and transforming that model to extract information. The downside to these utilities is that when the document is very large, the DOM may not fit in memory. The workaround for this type of problem is to treat the document as a stream of "events", e.g. "StartElement" and "EndElement" for XML, or "StartObject" and "EndObject" for JSON. The downside to this workaround is that writing code to handle these streams can be complicated and error-prone, especially when the DOM is complicated.

    SPaC's goal is to drastically simplify the process of creating code to handle these streams.

    This package contains the "core" SPaC traits; Parser, Transformer, Splitter, and ContextMatcher.

    See the xml and json subpackages (provided by the xml-spac and json-spac libraries respectively) for specific utilities related to handling XML and JSON event streams.

    Definition Classes
    dylemma
  • object Transformer

    Definition Classes
    spac
  • BoundHandler
  • Handler
  • HandlerLinkage
  • HandlerWrite
  • Stateless
  • TransformerKVParsingOps
  • TransformerParsingOps

trait Stateless[-In, +Out] extends Transformer[In, Out] with Handler[In, Out]

A stateless transformer acts as its own handler

In

The incoming event type

Out

The outgoing event type

Source
Transformer.scala
Linear Supertypes
Handler[In, Out], Transformer[In, Out], AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. Stateless
  2. Handler
  3. Transformer
  4. AnyRef
  5. Any
Implicitly
  1. by TransformerKVParsingOps
  2. by TransformerParsingOps
  3. by TransformerKVParsingOps
  4. by TransformerParsingOps
  5. by any2stringadd
  6. by StringFormat
  7. by Ensuring
  8. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def finish(out: HandlerWrite[Out]): Unit

    In response to the end of the stream of incoming values, this handler may output any number of final output values via the provided HandlerWrite.

    In response to the end of the stream of incoming values, this handler may output any number of final output values via the provided HandlerWrite. The expectation is that a Handler's finish method will only ever be called once before that Handler is discarded, with the exception of Stateless Transformers, which act as their own Handlers and will be reused.

    out

    The downstream receiver of output values

    Definition Classes
    Handler
  2. abstract def push(in: In, out: HandlerWrite[Out]): Signal

    In response to some input value in, this handler may output any number of output values via the provided HandlerWrite, possibly change its internal state, and signal to the upstream caller whether it wants to continue or stop receiving new inputs.

    In response to some input value in, this handler may output any number of output values via the provided HandlerWrite, possibly change its internal state, and signal to the upstream caller whether it wants to continue or stop receiving new inputs. Upstream handlers SHOULD avoid making more calls to this handler's push after it returns Signal.Stop.

    in

    An input value

    out

    The downstream receiver of output values

    returns

    A "signal" indicating whether this handler wants to continue receiving inputs afterward

    Definition Classes
    Handler

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from Stateless[In, Out] toany2stringadd[Stateless[In, Out]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (Stateless[In, Out], B)
    Implicit
    This member is added by an implicit conversion from Stateless[In, Out] toArrowAssoc[Stateless[In, Out]] performed by method ArrowAssoc in scala.Predef.This conversion will take place only if Out is a subclass of (Nothing, Nothing) (Out <: (Nothing, Nothing)).
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def asTopLevelHandler(caller: SpacTraceElement): Handler[In, Out]

    Wraps this handler as a "top level" handler, which will inject a SpacTraceElement (representing the current input or the "EOF" signal) to any exception is thrown by this handler when calling its step or finish methods.

    Wraps this handler as a "top level" handler, which will inject a SpacTraceElement (representing the current input or the "EOF" signal) to any exception is thrown by this handler when calling its step or finish methods.

    Used internally by Transformers transform and toPipe methods.

    Definition Classes
    Handler
  8. def bubbleUp(err: Throwable): Nothing

    In response to an error thrown and caught from a downstream consumer, this handler may modify the exception on its way back upstream.

    In response to an error thrown and caught from a downstream consumer, this handler may modify the exception on its way back upstream. Used by the "spac frame" transformer.

    err

    An error thrown by some downstream handler

    returns

    Nothing, because this method must always throw *something*

    Definition Classes
    Handler
  9. def cast[Out2](implicit ev: <:<[Out, Out2]): Transformer[In, Out2]

    Returns this transformer, but with a different view of the Out type.

    Returns this transformer, but with a different view of the Out type. The Out <:< Out2 implicit evidence is used to make sure the asInstanceOf cast is safe. This is mostly useful when you know you have a transformer that yields a tuple or some kind of type constructor.

    Definition Classes
    Transformer
  10. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  11. def collect[Out2](pf: PartialFunction[Out, Out2]): Transformer[In, Out2]

    Creates a new transformer which filters and maps the outputs from this transformer

    Creates a new transformer which filters and maps the outputs from this transformer

    Out2

    Result type of the pf

    pf

    Partial function responsible for the filtering and mapping of outputs from this transformer

    returns

    The filteried and mapped transformer

    Definition Classes
    Transformer
  12. def drain: Parser[In, Unit]

    Convenience for this into Parser.drain

    Convenience for this into Parser.drain

    Definition Classes
    Transformer
  13. def ensuring(cond: (Stateless[In, Out]) => Boolean, msg: => Any): Stateless[In, Out]
    Implicit
    This member is added by an implicit conversion from Stateless[In, Out] toEnsuring[Stateless[In, Out]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: (Stateless[In, Out]) => Boolean): Stateless[In, Out]
    Implicit
    This member is added by an implicit conversion from Stateless[In, Out] toEnsuring[Stateless[In, Out]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. def ensuring(cond: Boolean, msg: => Any): Stateless[In, Out]
    Implicit
    This member is added by an implicit conversion from Stateless[In, Out] toEnsuring[Stateless[In, Out]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. def ensuring(cond: Boolean): Stateless[In, Out]
    Implicit
    This member is added by an implicit conversion from Stateless[In, Out] toEnsuring[Stateless[In, Out]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  17. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  19. def filter(predicate: (Out) => Boolean): Transformer[In, Out]

    Creates a new transformer which filters the outputs from this transformer.

    Creates a new transformer which filters the outputs from this transformer.

    predicate

    A function which decides whether an output from this transformer should be emitted from the returned transformer. true means emit, false means skip.

    returns

    The filtered transformer

    Definition Classes
    Transformer
  20. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  21. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from Stateless[In, Out] toStringFormat[Stateless[In, Out]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  22. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  23. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  24. def into[Out2](parser: Parser[Out, Out2]): Parser[In, Out2]

    Attach this transformer to a parser, creating a new parser that encapsulates the pair.

    Attach this transformer to a parser, creating a new parser that encapsulates the pair. Values emitted from this transformer will be passed as inputs to the parser, and the resulting output from the parser will be yielded as output by the combined parser.

    Definition Classes
    Transformer
  25. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  26. def map[Out2](f: (Out) => Out2): Transformer[In, Out2]

    Creates a new transformer which applies the transformation function f to each of this transformer's outputs.

    Creates a new transformer which applies the transformation function f to each of this transformer's outputs.

    Out2

    The transformation output type

    f

    A transformation function

    returns

    The mapped transformer

    Definition Classes
    Transformer
  27. def mapFlatten[Out2](f: (Out) => Iterable[Out2]): Transformer[In, Out2]

    Creates a new transformer which transforms the outputs of this transformer via the given function f, emitting each individual value from the output of that function in order before continuing.

    Creates a new transformer which transforms the outputs of this transformer via the given function f, emitting each individual value from the output of that function in order before continuing.

    Out2

    The transformed output type

    f

    A function that transforms outputs from this transformer into a collection of other outputs

    returns

    A new transformer which emits any number of transformed outputs based on outputs from this transformer

    Definition Classes
    Transformer
  28. def merge[In2 <: In, Out2 >: Out](that: Transformer[In2, Out2]): Transformer[In2, Out2]

    Like mergeEither, but when both sides have a common output type.

    Like mergeEither, but when both sides have a common output type. This is a less-roundabout way of doing .mergeEither(right).map(_.merge). The same order-of-operations rules apply as with mergeEither, where this transformer "goes first" for each input.

    In2

    Contravariance-friendly version of In

    Out2

    Common output type between this and that

    that

    Another transformer

    returns

    The merged transformer

    Definition Classes
    Transformer
  29. def mergeEither[In2 <: In, Out2](right: Transformer[In2, Out2]): Transformer[In2, Either[Out, Out2]]

    Creates a new transformer which sends inputs to both this transformer and the right transformer.

    Creates a new transformer which sends inputs to both this transformer and the right transformer. Whenever either this or right emit a value, that value will be emitted from the returned transformer, wrapped as a Left or Right depending on which underlying transformer emitted it. For each individual input, the resulting values emitted by this transformer will be emitted before the resulting values emitted by the right transformer.

    In2

    Contravariance-friendly version of In

    Out2

    The output type of the right transformer

    right

    Another transformer

    returns

    The merged transformer

    Definition Classes
    Transformer
  30. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  31. def newHandler: Stateless.this.type

    Transformer's main abstract method; constructs a new Handler representing this transformer's logic.

    Transformer's main abstract method; constructs a new Handler representing this transformer's logic. Transformers are expected to be immutable, but Handlers may be internally-mutable.

    Definition Classes
    StatelessTransformer
  32. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  33. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  34. def parseAsFold[Out2](init: Out2)(f: (Out2, Out) => Out2): Parser[In, Out2]

    Convenience for this into Parser.fold(init)(f)

    Convenience for this into Parser.fold(init)(f)

    Definition Classes
    Transformer
  35. def parseFirstOpt: Parser[In, Option[Out]]

    Convenience for this into Parser.firstOpt

    Convenience for this into Parser.firstOpt

    Definition Classes
    Transformer
  36. def parseTap(f: (Out) => Unit): Parser[In, Unit]

    Convenience for this into Parser.tap(f)

    Convenience for this into Parser.tap(f)

    Definition Classes
    Transformer
  37. def parseToList: Parser[In, List[Out]]

    Convenience for this into Parser.toList

    Convenience for this into Parser.toList

    Definition Classes
    Transformer
  38. def pushMany(ins: Iterator[In], out: HandlerWrite[Out]): Signal

    Convenience for calling push multiple times, aborting early if the signal becomes Stop in response to any one push.

    Convenience for calling push multiple times, aborting early if the signal becomes Stop in response to any one push.

    ins

    An iterator which produces input values to push into this handler

    out

    The downstream receiver of output values

    returns

    A "signal" indicating whether this handler wants to continue receiving inputs afterward

    Definition Classes
    Handler
  39. def scan[Out2](init: Out2)(op: (Out2, Out) => Out2): Transformer[In, Out2]

    Creates a new transformer which folds outputs from this transformer into a "state" which is emitted each time.

    Creates a new transformer which folds outputs from this transformer into a "state" which is emitted each time.

    Out2

    The type of the scan "state"

    init

    The initial "state"

    op

    State update function; this is called for each Out emitted by this transformer, and the result is emitted by the combined transformer in addition to becoming the next "state"

    returns

    The new transformer

    Definition Classes
    Transformer
  40. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  41. def through[Out2](next: Transformer[Out, Out2]): Transformer[In, Out2]

    Attach this transformer to the next transformer, creating a single transformer that encapsulates the pair.

    Attach this transformer to the next transformer, creating a single transformer that encapsulates the pair. Values emitted from this transformer will be passed as inputs to the next transformer, and the resulting outputs from the next transformer are emitted as outputs from the combined transformer.

    Definition Classes
    Transformer
  42. def toPipe[F[_]](implicit pos: CallerPos): Pipe[F, In, Out]

    Convert this transformer to a Pipe which will apply this transformer's logic to an fs2 Stream.

    Convert this transformer to a Pipe which will apply this transformer's logic to an fs2 Stream.

    F

    Effect type for the Pipe/Stream

    pos

    Captures the caller filename and line number, used to fill in the 'spac trace' if the parser throws an exception

    returns

    An fs2.Pipe[F, In, Out] that will apply this transformer's logic

    Definition Classes
    Transformer
  43. def toString(): String
    Definition Classes
    AnyRef → Any
  44. def transform(itr: Iterator[In])(implicit pos: CallerPos): Iterator[Out]

    Applies this transformer's logic to an iterator, returning a new Iterator which yields values emitted by this transformer when run on the underlying itr.

    Applies this transformer's logic to an iterator, returning a new Iterator which yields values emitted by this transformer when run on the underlying itr.

    itr

    An iterator

    returns

    A wrapped version of itr, transformed via this transformer

    Definition Classes
    Transformer
  45. def upcast[In2 <: In, Out2 >: Out]: Transformer[In2, Out2]

    Returns this transformer, but with less restricted In / Out types.

    Returns this transformer, but with less restricted In / Out types.

    In2

    A subtype of In

    Out2

    A supertype of Out

    returns

    This transformer (not a copy, it's actually literally this)

    Definition Classes
    Transformer
  46. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  47. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  48. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  49. def withFilter(predicate: (Out) => Boolean): Transformer[In, Out]

    Alias for filter, used under the hood by for-comprehensions

    Alias for filter, used under the hood by for-comprehensions

    predicate

    The filtering function

    returns

    The filtered transformer

    Definition Classes
    Transformer
  50. def withName(name: String): Transformer[In, Out]

    Creates a copy of this transformer, but with a different toString

    Creates a copy of this transformer, but with a different toString

    name

    The new "name" (i.e. toString for this transformer

    returns

    A copy of this transformer whose toString returns the given name

    Definition Classes
    Transformer

Shadowed Implicit Value Members

  1. def parseFirst(implicit A: TypeName[Out]): Parser[In, Out]

    Convenience for this into Parser.first

    Convenience for this into Parser.first

    Implicit
    This member is added by an implicit conversion from Stateless[In, Out] toTransformerParsingOps[In, Out] performed by method TransformerParsingOps in io.dylemma.spac.Transformer.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (stateless: TransformerParsingOps[In, Out]).parseFirst(A)
    Definition Classes
    TransformerParsingOps
  2. def parseFirst(implicit A: TypeName[Out]): Parser[In, Out]

    Convenience for this into Parser.first

    Convenience for this into Parser.first

    Implicit
    This member is added by an implicit conversion from Stateless[In, Out] toTransformerParsingOps[In, Out] performed by method TransformerParsingOps in io.dylemma.spac.Transformer.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (stateless: TransformerParsingOps[In, Out]).parseFirst(A)
    Definition Classes
    TransformerParsingOps
  3. def parseToMap: Parser[In, Map[K, V]]

    Convenience for this into Parser.toMap[K, V]

    Convenience for this into Parser.toMap[K, V]

    Implicit
    This member is added by an implicit conversion from Stateless[In, Out] toTransformerKVParsingOps[In, K, V] performed by method TransformerKVParsingOps in io.dylemma.spac.Transformer.This conversion will take place only if Out is a subclass of (K, V) (Out <: (K, V)).
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (stateless: TransformerKVParsingOps[In, K, V]).parseToMap
    Definition Classes
    TransformerKVParsingOps
  4. def parseToMap: Parser[In, Map[K, V]]

    Convenience for this into Parser.toMap[K, V]

    Convenience for this into Parser.toMap[K, V]

    Implicit
    This member is added by an implicit conversion from Stateless[In, Out] toTransformerKVParsingOps[In, K, V] performed by method TransformerKVParsingOps in io.dylemma.spac.Transformer.This conversion will take place only if Out is a subclass of (K, V) (Out <: (K, V)).
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (stateless: TransformerKVParsingOps[In, K, V]).parseToMap
    Definition Classes
    TransformerKVParsingOps

Deprecated Value Members

  1. def >>[Out2](parser: Parser[Out, Out2]): Parser[In, Out2]
    Definition Classes
    Transformer
    Annotations
    @deprecated
    Deprecated

    (Since version v0.9) Due to troubles with operator precedence and type inference, this operator is being phased out in favor of into

  2. def >>[Out2](next: Transformer[Out, Out2]): Transformer[In, Out2]
    Definition Classes
    Transformer
    Annotations
    @deprecated
    Deprecated

    (Since version v0.9) Due to troubles with operator precedence and type inference, this operator is being phased out in favor of through

  3. def andThen[Out2](next: Transformer[Out, Out2]): Transformer[In, Out2]
    Definition Classes
    Transformer
    Annotations
    @deprecated
    Deprecated

    (Since version v0.9) This method is being renamed to through

  4. def parallel[In2 <: In, Out2 >: Out](that: Transformer[In2, Out2]): Transformer[In2, Out2]
    Definition Classes
    Transformer
    Annotations
    @deprecated
    Deprecated

    (Since version v0.9) This method is being renamed to merge

  5. def parallelEither[In2 <: In, Out2](right: Transformer[In2, Out2]): Transformer[In2, Either[Out, Out2]]
    Definition Classes
    Transformer
    Annotations
    @deprecated
    Deprecated

    (Since version v0.9) This method is being renamed to mergeEither

  6. def parseFirstOption: Parser[In, Option[Out]]
    Definition Classes
    Transformer
    Annotations
    @deprecated
    Deprecated

    (Since version v0.9) This method is being renamed to parseFirstOpt

  7. def parseForeach(f: (Out) => Any): Parser[In, Unit]
    Definition Classes
    Transformer
    Annotations
    @deprecated
    Deprecated

    (Since version v0.9) This method is being renamed to parseTap

  8. def parseWith[Out2](parser: Parser[Out, Out2], setDebugName: Option[String]): Parser[In, Out2]
    Definition Classes
    Transformer
    Annotations
    @deprecated
    Deprecated

    (Since version v0.9) Use the single-argument version of into, then call withName on the resulting parser

  9. def parseWith[Out2](parser: Parser[Out, Out2]): Parser[In, Out2]
    Definition Classes
    Transformer
    Annotations
    @deprecated
    Deprecated

    (Since version v0.9) Use into instead

  10. def sink: Parser[In, Unit]
    Definition Classes
    Transformer
    Annotations
    @deprecated
    Deprecated

    (Since version v0.9) This method is being renamed to drain

  11. def [B](y: B): (Stateless[In, Out], B)
    Implicit
    This member is added by an implicit conversion from Stateless[In, Out] toArrowAssoc[Stateless[In, Out]] performed by method ArrowAssoc in scala.Predef.This conversion will take place only if Out is a subclass of (Nothing, Nothing) (Out <: (Nothing, Nothing)).
    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.

Inherited from Handler[In, Out]

Inherited from Transformer[In, Out]

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion TransformerKVParsingOps fromStateless[In, Out] to TransformerKVParsingOps[In, K, V]

Inherited by implicit conversion TransformerParsingOps fromStateless[In, Out] to TransformerParsingOps[In, Out]

Inherited by implicit conversion TransformerKVParsingOps fromStateless[In, Out] to TransformerKVParsingOps[In, K, V]

Inherited by implicit conversion TransformerParsingOps fromStateless[In, Out] to TransformerParsingOps[In, Out]

Inherited by implicit conversion any2stringadd fromStateless[In, Out] to any2stringadd[Stateless[In, Out]]

Inherited by implicit conversion StringFormat fromStateless[In, Out] to StringFormat[Stateless[In, Out]]

Inherited by implicit conversion Ensuring fromStateless[In, Out] to Ensuring[Stateless[In, Out]]

Inherited by implicit conversion ArrowAssoc fromStateless[In, Out] to ArrowAssoc[Stateless[In, Out]]

Abstract Members

Applying a Transformer to a Stream

Transformation / Combinator Methods

Conversions to Parser

Ungrouped