Source

object Source

Note: this companion object provides a few very basic Source-constructor helpers, but the real useful functionality is provided by the "parser backend" modules like xml-spac-javax and json-spac-jackson, via JavaxSource and JacksonSource.

Companion:
class
class Object
trait Matchable
class Any
Source.type

Value members

Concrete methods

def defer[A](getUnderlying: => Source[A]): Source[A]

Creates a reusable source which will construct a new underlying source, by calling getUnderlying, each time its open is called.

Creates a reusable source which will construct a new underlying source, by calling getUnderlying, each time its open is called.

Value parameters:
getUnderlying

A call-by-name expression that constructs the underlying source. The expression is expected to be reusable, i.e. it might construct a new InputStream internally, and should not "close over" an existing stream that cannot be reused

def deferOnce[A](getUnderlying: => Source[A]): Source[A]

Creates a new Source which delegates to an underlying Source constructed from a call-by-name parameter, and ensures the new Source can only be opened once.

Creates a new Source which delegates to an underlying Source constructed from a call-by-name parameter, and ensures the new Source can only be opened once.

Type parameters:
A

The source item type

Value parameters:
getUnderlying

A call-by-name expression that constructs the underlying source that should be used at most once

Returns:

A new Source

def fromChain[A](chain: Chain[A]): Source[A]

Wraps a Chain as a Source.

Wraps a Chain as a Source.

Type parameters:
A

The Chain item type

Value parameters:
chain

The wrapped Chain

Returns:

A new Source which delegates to the Chain

def fromIterable[A](collection: Iterable[A], shouldCloseIterators: Boolean): Source[A]

Converts an iterable collection to a Source.

Converts an iterable collection to a Source.

Type parameters:
A

The Source item type

Value parameters:
collection

The collection

shouldCloseIterators

If true, any AutoCloseable iterators returned by this source's open will be closed during the corresponding close operation.

Returns:

A view of the given collection as a Source

def singleUse[A](itr: Iterator[A]): Source[A]

Wraps an existing iterator as a Source which may only be used once.

Wraps an existing iterator as a Source which may only be used once.

Type parameters:
A

The iterator's item type

Value parameters:
itr

The wrapped iterator

Returns:

A new Source that will return the given iterator when opened, and has a no-op close operation.