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
Value members
Concrete methods
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
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
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
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'sopen
will be closed during the correspondingclose
operation.
- Returns:
A view of the given
collection
as aSource
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.