net.sourceforge.yamlbeans
Class YamlReader

java.lang.Object
  extended by net.sourceforge.yamlbeans.YamlReader

public class YamlReader
extends java.lang.Object

Deserializes Java objects from YAML.


Nested Class Summary
 class YamlReader.YamlReaderException
           
 
Constructor Summary
YamlReader(java.io.Reader reader)
           
YamlReader(java.io.Reader reader, YamlConfig config)
           
YamlReader(java.lang.String yaml)
           
YamlReader(java.lang.String yaml, YamlConfig config)
           
 
Method Summary
 void close()
           
protected  java.lang.Object createObject(java.lang.Class type)
          Returns a new object of the requested type.
 YamlConfig getConfig()
           
static void main(java.lang.String[] args)
           
 java.lang.Object read()
          Reads the next YAML document and deserializes it into an object.
<T> T
read(java.lang.Class<T> type)
          Reads an object of the specified type from YAML.
<T> T
read(java.lang.Class<T> type, java.lang.Class elementType)
          Reads an array, Map, List, or Collection object of the specified type from YAML, using the specified element type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

YamlReader

public YamlReader(java.io.Reader reader)

YamlReader

public YamlReader(java.io.Reader reader,
                  YamlConfig config)

YamlReader

public YamlReader(java.lang.String yaml)

YamlReader

public YamlReader(java.lang.String yaml,
                  YamlConfig config)
Method Detail

getConfig

public YamlConfig getConfig()

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

read

public java.lang.Object read()
                      throws YamlException
Reads the next YAML document and deserializes it into an object. The type of object is defined by the YAML tag. If there is no YAML tag, the object will be an ArrayList, HashMap, or String.

Throws:
YamlException

read

public <T> T read(java.lang.Class<T> type)
       throws YamlException
Reads an object of the specified type from YAML.

Parameters:
type - The type of object to read. If null, behaves the same as {read().
Throws:
YamlException

read

public <T> T read(java.lang.Class<T> type,
                  java.lang.Class elementType)
       throws YamlException
Reads an array, Map, List, or Collection object of the specified type from YAML, using the specified element type.

Parameters:
type - The type of object to read. If null, behaves the same as {read().
Throws:
YamlException

createObject

protected java.lang.Object createObject(java.lang.Class type)
                                 throws java.lang.reflect.InvocationTargetException
Returns a new object of the requested type.

Throws:
java.lang.reflect.InvocationTargetException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception