Top Description Inners Fields Constructors Methods
org.snakeyaml.engine.v2.api

public Class Load

extends Object
Class Inheritance
Imports
java.io.InputStream, .Reader, java.util.Iterator, .Objects, .Optional, org.snakeyaml.engine.v2.composer.Composer, org.snakeyaml.engine.v2.constructor.BaseConstructor, .StandardConstructor, org.snakeyaml.engine.v2.nodes.Node, org.snakeyaml.engine.v2.parser.ParserImpl, org.snakeyaml.engine.v2.scanner.StreamReader

Common way to load Java instance(s). This class is not thread-safe. Which means that all the methods of the same instance can be called only by one thread. It is better to create an instance for every YAML stream. The instance is stateful. Only one of the 'load' methods may be called, and it may be called only once.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final BaseConstructor
private final LoadSettings

Constructor Summary

AccessConstructor and Description
public
Load(LoadSettings
- configuration
settings
)

Create instance to parse the incoming YAML data and create Java instances

public
Load(LoadSettings
- configuration
settings
,
BaseConstructor
- custom YAML constructor
constructor
)

Create instance to parse the incoming YAML data and create Java instances

Method Summary

Modifier and TypeMethod and Description
private Composer

Returns:

configured Composer
createComposer
(StreamReader
- the input
streamReader
)

Create Composer

protected Composer

Returns:

configured Composer
createComposer
(InputStream
- the input
yamlStream
)

Create Composer

protected Composer

Returns:

configured Composer
createComposer
(String
- the input
yaml
)

Create Composer

protected Composer

Returns:

configured Composer
createComposer
(Reader
- the input
yamlReader
)

Create Composer

private Iterable<Object>
loadAll(Composer composer)

public Iterable<Object>

Returns:

an Iterable over the parsed Java objects in this stream in proper sequence
loadAllFromInputStream
(InputStream
- YAML data to load from (BOM is respected to detect encoding and removed from the data)
yamlStream
)

Parse all YAML documents in a stream and produce corresponding Java objects.

public Iterable<Object>

Returns:

an Iterable over the parsed Java objects in this stream in proper sequence
loadAllFromReader
(Reader
- YAML data to load from (BOM must not be present)
yamlReader
)

Parse all YAML documents in a String and produce corresponding Java objects.

public Iterable<Object>

Returns:

an Iterable over the parsed Java objects in this stream in proper sequence
loadAllFromString
(String
- YAML data to load from (BOM must not be present)
yaml
)

Parse all YAML documents in a String and produce corresponding Java objects.

public Object

Returns:

parsed Java instance
loadFromInputStream
(InputStream
- data to load from (BOM is respected to detect encoding and removed from the data)
yamlStream
)

Parse the only YAML document in a stream and produce the corresponding Java object.

public Object

Returns:

parsed Java instance
loadFromReader
(Reader
- data to load from (BOM must not be present)
yamlReader
)

Parse a YAML document and create a Java instance

public Object

Returns:

parsed Java instance
loadFromString
(String
- YAML data to load from (BOM must not be present)
yaml
)

Parse a YAML document and create a Java instance

protected Object

Returns:

deserialised YAML document
loadOne
(Composer
- the component to create the Node
composer
)

Load with provided Composer

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

constructorback to summary
private final BaseConstructor constructor
settingsback to summary
private final LoadSettings settings

Constructor Detail

Loadback to summary
public Load(LoadSettings settings)

Create instance to parse the incoming YAML data and create Java instances

Parameters
settings:LoadSettings

- configuration

Loadback to summary
public Load(LoadSettings settings, BaseConstructor constructor)

Create instance to parse the incoming YAML data and create Java instances

Parameters
settings:LoadSettings

- configuration

constructor:BaseConstructor

- custom YAML constructor

Method Detail

createComposerback to summary
private Composer createComposer(StreamReader streamReader)

Create Composer

Parameters
streamReader:StreamReader

- the input

Returns:Composer

configured Composer

createComposerback to summary
protected Composer createComposer(InputStream yamlStream)

Create Composer

Parameters
yamlStream:InputStream

- the input

Returns:Composer

configured Composer

createComposerback to summary
protected Composer createComposer(String yaml)

Create Composer

Parameters
yaml:String

- the input

Returns:Composer

configured Composer

createComposerback to summary
protected Composer createComposer(Reader yamlReader)

Create Composer

Parameters
yamlReader:Reader

- the input

Returns:Composer

configured Composer

loadAllback to summary
private Iterable<Object> loadAll(Composer composer)
loadAllFromInputStreamback to summary
public Iterable<Object> loadAllFromInputStream(InputStream yamlStream)

Parse all YAML documents in a stream and produce corresponding Java objects. The documents are parsed only when the iterator is invoked.

Parameters
yamlStream:InputStream

- YAML data to load from (BOM is respected to detect encoding and removed from the data)

Returns:Iterable<Object>

an Iterable over the parsed Java objects in this stream in proper sequence

loadAllFromReaderback to summary
public Iterable<Object> loadAllFromReader(Reader yamlReader)

Parse all YAML documents in a String and produce corresponding Java objects. The documents are parsed only when the iterator is invoked.

Parameters
yamlReader:Reader

- YAML data to load from (BOM must not be present)

Returns:Iterable<Object>

an Iterable over the parsed Java objects in this stream in proper sequence

loadAllFromStringback to summary
public Iterable<Object> loadAllFromString(String yaml)

Parse all YAML documents in a String and produce corresponding Java objects. (Because the encoding in known BOM is not respected.) The documents are parsed only when the iterator is invoked.

Parameters
yaml:String

- YAML data to load from (BOM must not be present)

Returns:Iterable<Object>

an Iterable over the parsed Java objects in this stream in proper sequence

loadFromInputStreamback to summary
public Object loadFromInputStream(InputStream yamlStream)

Parse the only YAML document in a stream and produce the corresponding Java object.

Parameters
yamlStream:InputStream

- data to load from (BOM is respected to detect encoding and removed from the data)

Returns:Object

parsed Java instance

loadFromReaderback to summary
public Object loadFromReader(Reader yamlReader)

Parse a YAML document and create a Java instance

Parameters
yamlReader:Reader

- data to load from (BOM must not be present)

Returns:Object

parsed Java instance

loadFromStringback to summary
public Object loadFromString(String yaml)

Parse a YAML document and create a Java instance

Parameters
yaml:String

- YAML data to load from (BOM must not be present)

Returns:Object

parsed Java instance

Exceptions
YamlEngineException:
if the YAML is not valid
loadOneback to summary
protected Object loadOne(Composer composer)

Load with provided Composer

Parameters
composer:Composer

- the component to create the Node

Returns:Object

deserialised YAML document

org.snakeyaml.engine.v2.api back to summary

private Class Load.YamlIterable

extends Object
implements Iterable<Object>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable

Field Summary

Modifier and TypeField and Description
private final Iterator<Object>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Iterator<Object>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

iteratorback to summary
private final Iterator<Object> iterator

Constructor Detail

YamlIterableback to summary
public YamlIterable(Iterator<Object> iterator)

Method Detail

iteratorback to summary
public Iterator<Object> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Annotations
@Override
org.snakeyaml.engine.v2.api back to summary

private Class Load.YamlIterator

extends Object
implements Iterator<Object>
Class Inheritance
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
private final Composer
private boolean
private final BaseConstructor

Constructor Summary

AccessConstructor and Description
public
YamlIterator(Composer composer, BaseConstructor constructor)

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public Object
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

composerback to summary
private final Composer composer
composerInitiatedback to summary
private boolean composerInitiated
constructorback to summary
private final BaseConstructor constructor

Constructor Detail

YamlIteratorback to summary
public YamlIterator(Composer composer, BaseConstructor constructor)

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Annotations
@Override
nextback to summary
public Object next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override