org.yaml.snakeyaml
Class Yaml

java.lang.Object
  extended by org.yaml.snakeyaml.Yaml

public class Yaml
extends Object

Public YAML interface. Each Thread must have its own instance.


Field Summary
protected  BaseConstructor constructor
           
protected  DumperOptions options
           
protected  Representer representer
           
protected  Resolver resolver
           
 
Constructor Summary
Yaml()
          Create Yaml instance.
Yaml(BaseConstructor constructor)
          Create Yaml instance.
Yaml(BaseConstructor constructor, Representer representer)
          Create Yaml instance.
Yaml(BaseConstructor constructor, Representer representer, DumperOptions options)
          Create Yaml instance.
Yaml(BaseConstructor constructor, Representer representer, DumperOptions options, Resolver resolver)
          Create Yaml instance.
Yaml(Dumper dumper)
          Create Yaml instance.
Yaml(DumperOptions options)
          Create Yaml instance.
Yaml(Loader loader)
          Deprecated. use with Constructor instead of Loader
Yaml(Loader loader, Dumper dumper)
          Deprecated. use with Constructor instead of Loader
Yaml(Loader loader, Dumper dumper, Resolver resolver)
          Deprecated. use with Constructor instead of Loader
Yaml(Representer representer)
          Create Yaml instance.
Yaml(Representer representer, DumperOptions options)
          Create Yaml instance.
 
Method Summary
 void addImplicitResolver(String tag, Pattern regexp, String first)
          Deprecated. use Tag instead of String
 void addImplicitResolver(Tag tag, Pattern regexp, String first)
          Add an implicit scalar detector.
 Node compose(Reader yaml)
          Parse the first YAML document in a stream and produce the corresponding representation tree.
 Iterable<Node> composeAll(Reader yaml)
          Parse all YAML documents in a stream and produce corresponding representation trees.
 String dump(Object data)
          Serialize a Java object into a YAML String.
 void dump(Object data, Writer output)
          Serialize a Java object into a YAML stream.
 String dumpAll(Iterator<? extends Object> data)
          Serialize a sequence of Java objects into a YAML String.
 void dumpAll(Iterator<? extends Object> data, Writer output)
          Serialize a sequence of Java objects into a YAML stream.
 String getName()
          Get a meaningful name.
 Object load(InputStream io)
          Parse the first YAML document in a stream and produce the corresponding Java object.
 Object load(Reader io)
          Parse the first YAML document in a stream and produce the corresponding Java object.
 Object load(String yaml)
          Parse the first YAML document in a String and produce the corresponding Java object.
 Iterable<Object> loadAll(InputStream yaml)
          Parse all YAML documents in a stream and produce corresponding Java objects.
 Iterable<Object> loadAll(Reader yaml)
          Parse all YAML documents in a String and produce corresponding Java objects.
 Iterable<Object> loadAll(String yaml)
          Parse all YAML documents in a String and produce corresponding Java objects.
 Iterable<Event> parse(Reader yaml)
          Parse a YAML stream and produce parsing events.
 void setBeanAccess(BeanAccess beanAccess)
           
 void setName(String name)
          Set a meaningful name to be shown in toString()
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

resolver

protected final Resolver resolver

constructor

protected BaseConstructor constructor

representer

protected Representer representer

options

protected DumperOptions options
Constructor Detail

Yaml

public Yaml()
Create Yaml instance. It is safe to create a few instances and use them in different Threads.


Yaml

public Yaml(DumperOptions options)
Create Yaml instance.

Parameters:
options - DumperOptions to configure outgoing objects

Yaml

public Yaml(Representer representer)
Create Yaml instance. It is safe to create a few instances and use them in different Threads.

Parameters:
representer - Representer to emit outgoing objects

Yaml

public Yaml(BaseConstructor constructor)
Create Yaml instance. It is safe to create a few instances and use them in different Threads.

Parameters:
constructor - BaseConstructor to construct incoming documents

Yaml

public Yaml(BaseConstructor constructor,
            Representer representer)
Create Yaml instance. It is safe to create a few instances and use them in different Threads.

Parameters:
constructor - BaseConstructor to construct incoming documents
representer - Representer to emit outgoing objects

Yaml

public Yaml(Representer representer,
            DumperOptions options)
Create Yaml instance. It is safe to create a few instances and use them in different Threads.

Parameters:
representer - Representer to emit outgoing objects
options - DumperOptions to configure outgoing objects

Yaml

public Yaml(BaseConstructor constructor,
            Representer representer,
            DumperOptions options)
Create Yaml instance. It is safe to create a few instances and use them in different Threads.

Parameters:
constructor - BaseConstructor to construct incoming documents
representer - Representer to emit outgoing objects
options - DumperOptions to configure outgoing objects

Yaml

public Yaml(BaseConstructor constructor,
            Representer representer,
            DumperOptions options,
            Resolver resolver)
Create Yaml instance. It is safe to create a few instances and use them in different Threads.

Parameters:
constructor - BaseConstructor to construct incoming documents
representer - Representer to emit outgoing objects
options - DumperOptions to configure outgoing objects
resolver - Resolver to detect implicit type

Yaml

public Yaml(Loader loader)
Deprecated. use with Constructor instead of Loader


Yaml

public Yaml(Loader loader,
            Dumper dumper)
Deprecated. use with Constructor instead of Loader


Yaml

public Yaml(Loader loader,
            Dumper dumper,
            Resolver resolver)
Deprecated. use with Constructor instead of Loader


Yaml

public Yaml(Dumper dumper)
Create Yaml instance. It is safe to create a few instances and use them in different Threads.

Parameters:
dumper - Dumper to emit outgoing objects
Method Detail

dump

public String dump(Object data)
Serialize a Java object into a YAML String.

Parameters:
data - Java object to be Serialized to YAML
Returns:
YAML String

dumpAll

public String dumpAll(Iterator<? extends Object> data)
Serialize a sequence of Java objects into a YAML String.

Parameters:
data - Iterator with Objects
Returns:
YAML String with all the objects in proper sequence

dump

public void dump(Object data,
                 Writer output)
Serialize a Java object into a YAML stream.

Parameters:
data - Java object to be Serialized to YAML
output - stream to write to

dumpAll

public void dumpAll(Iterator<? extends Object> data,
                    Writer output)
Serialize a sequence of Java objects into a YAML stream.

Parameters:
data - Iterator with Objects
output - stream to write to

load

public Object load(String yaml)
Parse the first YAML document in a String and produce the corresponding Java object. (Because the encoding in known BOM is not respected.)

Parameters:
yaml - YAML data to load from (BOM must not be present)
Returns:
parsed object

load

public Object load(InputStream io)
Parse the first YAML document in a stream and produce the corresponding Java object.

Parameters:
io - data to load from (BOM is respected and removed)
Returns:
parsed object

load

public Object load(Reader io)
Parse the first YAML document in a stream and produce the corresponding Java object.

Parameters:
io - data to load from (BOM must not be present)
Returns:
parsed object

loadAll

public Iterable<Object> loadAll(Reader yaml)
Parse all YAML documents in a String and produce corresponding Java objects.

Parameters:
yaml - YAML data to load from (BOM must not be present)
Returns:
an iterator over the parsed Java objects in this String in proper sequence

loadAll

public Iterable<Object> loadAll(String yaml)
Parse all YAML documents in a String and produce corresponding Java objects. (Because the encoding in known BOM is not respected.)

Parameters:
yaml - YAML data to load from (BOM must not be present)
Returns:
an iterator over the parsed Java objects in this String in proper sequence

loadAll

public Iterable<Object> loadAll(InputStream yaml)
Parse all YAML documents in a stream and produce corresponding Java objects.

Parameters:
yaml - YAML data to load from (BOM is respected and ignored)
Returns:
an iterator over the parsed Java objects in this stream in proper sequence

compose

public Node compose(Reader yaml)
Parse the first YAML document in a stream and produce the corresponding representation tree.

Parameters:
yaml - YAML document
Returns:
parsed root Node for the specified YAML document

composeAll

public Iterable<Node> composeAll(Reader yaml)
Parse all YAML documents in a stream and produce corresponding representation trees.

Parameters:
yaml - stream of YAML documents
Returns:
parsed root Nodes for all the specified YAML documents

addImplicitResolver

public void addImplicitResolver(String tag,
                                Pattern regexp,
                                String first)
Deprecated. use Tag instead of String

Add an implicit scalar detector. If an implicit scalar value matches the given regexp, the corresponding tag is assigned to the scalar.

Parameters:
tag - tag to assign to the node
regexp - regular expression to match against
first - a sequence of possible initial characters or null (which means any).

addImplicitResolver

public void addImplicitResolver(Tag tag,
                                Pattern regexp,
                                String first)
Add an implicit scalar detector. If an implicit scalar value matches the given regexp, the corresponding tag is assigned to the scalar.

Parameters:
tag - tag to assign to the node
regexp - regular expression to match against
first - a sequence of possible initial characters or null (which means any).

toString

public String toString()
Overrides:
toString in class Object

getName

public String getName()
Get a meaningful name. It simplifies debugging in a multi-threaded environment. If nothing is set explicitly the address of the instance is returned.

Returns:
human readable name

setName

public void setName(String name)
Set a meaningful name to be shown in toString()

Parameters:
name - human readable name

parse

public Iterable<Event> parse(Reader yaml)
Parse a YAML stream and produce parsing events.

Parameters:
yaml - YAML document(s)
Returns:
parsed events

setBeanAccess

public void setBeanAccess(BeanAccess beanAccess)


Copyright © 2008-2010. All Rights Reserved.