org.ho.yaml
Class YamlConfig

java.lang.Object
  extended by org.ho.yaml.YamlConfig
All Implemented Interfaces:
java.lang.Cloneable, YamlOperations

public class YamlConfig
extends java.lang.Object
implements YamlOperations, java.lang.Cloneable

YamlConfig represents a Jyaml configuration and contains all methods in YamlOperations and is used as the entry point for Yaml operations when multiple Jyaml configurations are used in the same application. See YamlOperations for documentation on the Yaml entry point methods.


Field Summary
static java.lang.String CONSTRUCTOR_SCOPE
           
static java.lang.String DEFAULT
           
static java.lang.String FIELD_SCOPE
           
static java.lang.String PRIVATE
           
static java.lang.String PROPERTY_SCOPE
           
static java.lang.String PROTECTED
           
static java.lang.String PUBLIC
           
 
Constructor Summary
YamlConfig()
           
 
Method Summary
 java.lang.Object clone()
           
 java.lang.String dump(java.lang.Object obj)
          Dumps an object into Yaml format
 java.lang.String dump(java.lang.Object obj, boolean minimalOutput)
          Dumps an object into Yaml format
 void dump(java.lang.Object obj, java.io.File file)
          Dumps an object to a file in Yaml format
 void dump(java.lang.Object obj, java.io.File file, boolean minimalOutput)
          Dumps an object to a file in Yaml format
 java.lang.String dumpStream(java.util.Iterator iterator)
          Dumps a stream of objects specified with an iterator to a String in Yaml format, one document per object
 java.lang.String dumpStream(java.util.Iterator iterator, boolean minimalOutput)
          Dumps a stream of objects specified with an iterator to a String in Yaml format, one document per object
 void dumpStream(java.util.Iterator iterator, java.io.File file)
          Dumps a stream of objects specified with an iterator to a file in Yaml format, one document per object
 void dumpStream(java.util.Iterator iterator, java.io.File file, boolean minimalOutput)
          Dumps a stream of objects specified with an iterator to a file in Yaml format, one document per object
static YamlConfig fromFile(java.lang.String filename)
          Loads a YamlConfig from a Yaml configuration file
static YamlConfig fromResource(java.lang.String filename)
          Loads a YamlConfig from a resource on the classpath
 java.lang.String getDateFormat()
           
 java.text.DateFormat getDateFormatter()
          Returns a DateFormat object for converting dates to strings.
 java.util.Map<java.lang.String,java.lang.String> getDecodingAccessScope()
           
static YamlConfig getDefaultConfig()
          The default Jyaml configuration
 java.lang.String getEncoding()
          Returns the charset (or encoding) to use for both encoding and decoding.
 java.util.Map<java.lang.String,java.lang.String> getEncodingAccessScope()
           
 java.util.Map<java.lang.String,java.lang.Object> getHandlers()
           
 java.lang.String getIndentAmount()
          Returns the indentation amount used for one indentation level.
 org.ho.util.BiDirectionalMap<java.lang.String,java.lang.String> getTransfers()
          returns the transfer-to-classname mapping for this configuration
 ObjectWrapper getWrapper(java.lang.Class clazz)
           
 ObjectWrapper getWrapper(java.lang.Object obj)
           
 ObjectWrapper getWrapper(java.lang.String classname)
           
 ObjectWrapper getWrapperSetContent(java.lang.String classname, java.lang.String content)
           
 boolean isConstructorAccessibleForDecoding(java.lang.Class clazz)
           
 boolean isFieldAccessibleForDecoding(java.lang.reflect.Field field)
           
 boolean isFieldAccessibleForEncoding(java.lang.reflect.Field field)
           
 boolean isMinimalOutput()
          Returns whether the minimal output option is set.
 boolean isPropertyAccessibleForDecoding(java.beans.PropertyDescriptor prop)
           
 boolean isPropertyAccessibleForEncoding(java.beans.PropertyDescriptor prop)
           
 boolean isSuppressWarnings()
          returns whether the suppress warnings option is on
 java.lang.Object load(java.io.File file)
          Loads one object from a file in Yaml format
 java.lang.Object load(java.io.InputStream in)
          Loads one object from an input stream
 java.lang.Object load(java.io.Reader reader)
          Loads one object from a Reader
 java.lang.Object load(java.lang.String yamlText)
          Loads one object from a string of Yaml text
 java.lang.Object load(YamlDecoder dec)
           
 YamlStream loadStream(java.io.File file)
          Loads the objects in a file in Yaml format into a YamlStream, which is used to iterate the objects in the file
 YamlStream loadStream(java.io.InputStream in)
          Loads the objects in input stream in Yaml format into a YamlStream, which is used to iterate the objects in the input stream
 YamlStream loadStream(java.io.Reader reader)
          Loads the objects in reader in Yaml format into a YamlStream, which is used to iterate the objects in the input stream
 YamlStream loadStream(java.lang.String yamlText)
          Loads the objects in a Yaml text into a YamlStream, which is used to iterate the objects in the Yaml text
 YamlStream loadStream(YamlDecoder dec)
           
<T> YamlStream<T>
loadStreamOfType(java.io.File file, java.lang.Class<T> clazz)
          Loads the objects of a specified type in a file in Yaml format into a YamlStream, which is used to iterate the objects in the file
<T> YamlStream<T>
loadStreamOfType(java.io.InputStream in, java.lang.Class<T> clazz)
          Loads the objects of a specified type in an input stream in Yaml format into a YamlStream, which is used to iterate the objects in the input stream
<T> YamlStream<T>
loadStreamOfType(java.io.Reader reader, java.lang.Class<T> clazz)
          Loads the objects of a specified type in a reader in Yaml format into a YamlStream, which is used to iterate the objects in the input stream
<T> YamlStream<T>
loadStreamOfType(java.lang.String yamlText, java.lang.Class<T> clazz)
          Loads the objects of a specified type in a in Yaml format into a YamlStream, which is used to iterate the objects in the file
<T> YamlStream<T>
loadStreamOfType(YamlDecoder dec, java.lang.Class<T> clazz)
           
<T> T
loadType(java.io.File file, java.lang.Class<T> clazz)
          Loads one object from a file in Yaml format
<T> T
loadType(java.io.InputStream in, java.lang.Class<T> clazz)
          Loads one object from an input stream of the specified type
<T> T
loadType(java.io.Reader reader, java.lang.Class<T> clazz)
          Loads one object from a a reader of the specified type
<T> T
loadType(java.lang.String yamlText, java.lang.Class<T> clazz)
          Loads one object from a file in Yaml format
<T> T
loadType(YamlDecoder dec, java.lang.Class<T> clazz)
           
 void setDateFormat(java.lang.String dateFormat)
           
 void setDecodingAccessScope(java.util.Map<java.lang.String,java.lang.String> decodingAccessScope)
           
 void setEncoding(java.lang.String charset)
          sets the charset (or encoding) to use for both encoding and decoding.
 void setEncodingAccessScope(java.util.Map<java.lang.String,java.lang.String> encodingAccessScope)
           
 void setHandlers(java.util.Map<java.lang.String,java.lang.Object> handlers)
           
 void setIndentAmount(java.lang.String indentAmount)
          Sets indentation amount.
 void setMinimalOutput(boolean minimalOutput)
          Sets the minimal output option.
 void setSuppressWarnings(boolean suppressWarnings)
          sets the suppress warnings option
 void setTransfers(org.ho.util.BiDirectionalMap<java.lang.String,java.lang.String> transferDictionary)
          sets the transfer-to-classname mapping for this configuration
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONSTRUCTOR_SCOPE

public static final java.lang.String CONSTRUCTOR_SCOPE
See Also:
Constant Field Values

FIELD_SCOPE

public static final java.lang.String FIELD_SCOPE
See Also:
Constant Field Values

PROPERTY_SCOPE

public static final java.lang.String PROPERTY_SCOPE
See Also:
Constant Field Values

PRIVATE

public static final java.lang.String PRIVATE
See Also:
Constant Field Values

DEFAULT

public static final java.lang.String DEFAULT
See Also:
Constant Field Values

PROTECTED

public static final java.lang.String PROTECTED
See Also:
Constant Field Values

PUBLIC

public static final java.lang.String PUBLIC
See Also:
Constant Field Values
Constructor Detail

YamlConfig

public YamlConfig()
Method Detail

getDefaultConfig

public static YamlConfig getDefaultConfig()
The default Jyaml configuration

Returns:
the default Jyaml configuration

getEncoding

public java.lang.String getEncoding()
Returns the charset (or encoding) to use for both encoding and decoding. The default is UTF-8. See http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html for more info.

Returns:

setEncoding

public void setEncoding(java.lang.String charset)
sets the charset (or encoding) to use for both encoding and decoding. See http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html

Parameters:
encoding -

getIndentAmount

public java.lang.String getIndentAmount()
Returns the indentation amount used for one indentation level.

Returns:
the amount of indentation used for one indentation level.

setIndentAmount

public void setIndentAmount(java.lang.String indentAmount)
Sets indentation amount.

Parameters:
indentAmount - must be a string consisting only of spaces.

isMinimalOutput

public boolean isMinimalOutput()
Returns whether the minimal output option is set.

Returns:
whether the minimal output option is set.

setMinimalOutput

public void setMinimalOutput(boolean minimalOutput)
Sets the minimal output option.

Parameters:
minimalOutput - true for on; false for off.

isSuppressWarnings

public boolean isSuppressWarnings()
returns whether the suppress warnings option is on

Returns:
whether the suppress warnings option is on

setSuppressWarnings

public void setSuppressWarnings(boolean suppressWarnings)
sets the suppress warnings option

Parameters:
suppressWarnings - true for on; false for off.

getTransfers

public org.ho.util.BiDirectionalMap<java.lang.String,java.lang.String> getTransfers()
returns the transfer-to-classname mapping for this configuration

Returns:
a transfer-classname bi-directional map

setTransfers

public void setTransfers(org.ho.util.BiDirectionalMap<java.lang.String,java.lang.String> transferDictionary)
sets the transfer-to-classname mapping for this configuration

Parameters:
transferDictionary - a transfer-classname bi-directional map

getHandlers

public java.util.Map<java.lang.String,java.lang.Object> getHandlers()

setHandlers

public void setHandlers(java.util.Map<java.lang.String,java.lang.Object> handlers)

getWrapper

public ObjectWrapper getWrapper(java.lang.Object obj)

getWrapper

public ObjectWrapper getWrapper(java.lang.Class clazz)

getWrapper

public ObjectWrapper getWrapper(java.lang.String classname)

getWrapperSetContent

public ObjectWrapper getWrapperSetContent(java.lang.String classname,
                                          java.lang.String content)

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

getDateFormat

public java.lang.String getDateFormat()

setDateFormat

public void setDateFormat(java.lang.String dateFormat)

getDateFormatter

public java.text.DateFormat getDateFormatter()
Returns a DateFormat object for converting dates to strings.

If no date format has been set then returns null.


fromFile

public static YamlConfig fromFile(java.lang.String filename)
                           throws java.io.FileNotFoundException,
                                  java.io.EOFException
Loads a YamlConfig from a Yaml configuration file

Parameters:
filename - the name of the file to load
Returns:
a YamlConfig object
Throws:
java.io.FileNotFoundException
java.io.EOFException

fromResource

public static YamlConfig fromResource(java.lang.String filename)
                               throws java.io.EOFException
Loads a YamlConfig from a resource on the classpath

Parameters:
filename - the name of the resource
Returns:
a YamlConfig object
Throws:
java.io.EOFException

load

public java.lang.Object load(YamlDecoder dec)

load

public java.lang.Object load(java.io.InputStream in)
Description copied from interface: YamlOperations
Loads one object from an input stream

Specified by:
load in interface YamlOperations
Parameters:
in - the stream to read from
Returns:
the first object on the stream in Yaml format

load

public java.lang.Object load(java.io.Reader reader)
Description copied from interface: YamlOperations
Loads one object from a Reader

Specified by:
load in interface YamlOperations
Parameters:
reader - the reader to read from
Returns:
the first object on the stream in Yaml format

load

public java.lang.Object load(java.io.File file)
                      throws java.io.FileNotFoundException
Description copied from interface: YamlOperations
Loads one object from a file in Yaml format

Specified by:
load in interface YamlOperations
Parameters:
file - the file to read from
Returns:
the first object in the file in Yaml format
Throws:
java.io.FileNotFoundException

load

public java.lang.Object load(java.lang.String yamlText)
Description copied from interface: YamlOperations
Loads one object from a string of Yaml text

Specified by:
load in interface YamlOperations
Parameters:
yamlText - the text to read from
Returns:
the first object in the Yaml text

loadType

public <T> T loadType(YamlDecoder dec,
                      java.lang.Class<T> clazz)

loadType

public <T> T loadType(java.io.InputStream in,
                      java.lang.Class<T> clazz)
Description copied from interface: YamlOperations
Loads one object from an input stream of the specified type

Specified by:
loadType in interface YamlOperations
Type Parameters:
T - the specified type
Parameters:
in - the stream to read from
clazz - the class of the specified type
Returns:
the first object in the stream in Yaml format

loadType

public <T> T loadType(java.io.Reader reader,
                      java.lang.Class<T> clazz)
Description copied from interface: YamlOperations
Loads one object from a a reader of the specified type

Specified by:
loadType in interface YamlOperations
Type Parameters:
T - the specified type
Parameters:
reader - the reader to read from
clazz - the class of the specified type
Returns:
the first object in the stream in Yaml format

loadType

public <T> T loadType(java.io.File file,
                      java.lang.Class<T> clazz)
           throws java.io.FileNotFoundException
Description copied from interface: YamlOperations
Loads one object from a file in Yaml format

Specified by:
loadType in interface YamlOperations
Type Parameters:
T - the specified type
Parameters:
file - the file to read from
clazz - the class of the specified type
Returns:
the first object in the file in Yaml format
Throws:
java.io.FileNotFoundException

loadType

public <T> T loadType(java.lang.String yamlText,
                      java.lang.Class<T> clazz)
Description copied from interface: YamlOperations
Loads one object from a file in Yaml format

Specified by:
loadType in interface YamlOperations
Type Parameters:
T - the specified type
Parameters:
yamlText - the Yaml text
clazz - the class of the specified type
Returns:
the first object in the Yaml text

loadStream

public YamlStream loadStream(YamlDecoder dec)

loadStream

public YamlStream loadStream(java.io.Reader reader)
Description copied from interface: YamlOperations
Loads the objects in reader in Yaml format into a YamlStream, which is used to iterate the objects in the input stream

Specified by:
loadStream in interface YamlOperations
Parameters:
reader - the reader to read from
Returns:
a YamlStream for iterating the objects

loadStream

public YamlStream loadStream(java.io.InputStream in)
Description copied from interface: YamlOperations
Loads the objects in input stream in Yaml format into a YamlStream, which is used to iterate the objects in the input stream

Specified by:
loadStream in interface YamlOperations
Parameters:
in - the stream to read from
Returns:
a YamlStream for iterating the objects

loadStream

public YamlStream loadStream(java.io.File file)
                      throws java.io.FileNotFoundException
Description copied from interface: YamlOperations
Loads the objects in a file in Yaml format into a YamlStream, which is used to iterate the objects in the file

Specified by:
loadStream in interface YamlOperations
Parameters:
file - the file to read from
Returns:
a YamlStream for iterating the objects
Throws:
java.io.FileNotFoundException

loadStream

public YamlStream loadStream(java.lang.String yamlText)
Description copied from interface: YamlOperations
Loads the objects in a Yaml text into a YamlStream, which is used to iterate the objects in the Yaml text

Specified by:
loadStream in interface YamlOperations
Returns:
a YamlStream for iterating the objects

loadStreamOfType

public <T> YamlStream<T> loadStreamOfType(YamlDecoder dec,
                                          java.lang.Class<T> clazz)

loadStreamOfType

public <T> YamlStream<T> loadStreamOfType(java.io.Reader reader,
                                          java.lang.Class<T> clazz)
Description copied from interface: YamlOperations
Loads the objects of a specified type in a reader in Yaml format into a YamlStream, which is used to iterate the objects in the input stream

Specified by:
loadStreamOfType in interface YamlOperations
Type Parameters:
T - the specified type
Parameters:
reader - the reader to read from
clazz - the class of the specified type
Returns:
a YamlStream for iterating the objects

loadStreamOfType

public <T> YamlStream<T> loadStreamOfType(java.io.InputStream in,
                                          java.lang.Class<T> clazz)
Description copied from interface: YamlOperations
Loads the objects of a specified type in an input stream in Yaml format into a YamlStream, which is used to iterate the objects in the input stream

Specified by:
loadStreamOfType in interface YamlOperations
Type Parameters:
T - the specified type
Parameters:
in - the stream to read from
clazz - the class of the specified type
Returns:
a YamlStream for iterating the objects

loadStreamOfType

public <T> YamlStream<T> loadStreamOfType(java.io.File file,
                                          java.lang.Class<T> clazz)
                               throws java.io.FileNotFoundException
Description copied from interface: YamlOperations
Loads the objects of a specified type in a file in Yaml format into a YamlStream, which is used to iterate the objects in the file

Specified by:
loadStreamOfType in interface YamlOperations
Type Parameters:
T - the specified type
Parameters:
file - the file to read from
clazz - the class of the specified type
Returns:
a YamlStream for iterating the objects
Throws:
java.io.FileNotFoundException

loadStreamOfType

public <T> YamlStream<T> loadStreamOfType(java.lang.String yamlText,
                                          java.lang.Class<T> clazz)
Description copied from interface: YamlOperations
Loads the objects of a specified type in a in Yaml format into a YamlStream, which is used to iterate the objects in the file

Specified by:
loadStreamOfType in interface YamlOperations
Type Parameters:
T - the specified type
Parameters:
yamlText - the text to read from
clazz - the class of the specified type
Returns:
a YamlStream for iterating the objects

dump

public void dump(java.lang.Object obj,
                 java.io.File file)
          throws java.io.FileNotFoundException
Description copied from interface: YamlOperations
Dumps an object to a file in Yaml format

Specified by:
dump in interface YamlOperations
Parameters:
obj - the object to dump
file - the file to dump to
Throws:
java.io.FileNotFoundException

dump

public void dump(java.lang.Object obj,
                 java.io.File file,
                 boolean minimalOutput)
          throws java.io.FileNotFoundException
Description copied from interface: YamlOperations
Dumps an object to a file in Yaml format

Specified by:
dump in interface YamlOperations
Parameters:
obj - the object to dump
file - the file to dump to
minimalOutput - whether minimal output is on
Throws:
java.io.FileNotFoundException

dumpStream

public void dumpStream(java.util.Iterator iterator,
                       java.io.File file,
                       boolean minimalOutput)
                throws java.io.FileNotFoundException
Description copied from interface: YamlOperations
Dumps a stream of objects specified with an iterator to a file in Yaml format, one document per object

Specified by:
dumpStream in interface YamlOperations
Parameters:
iterator - the iterator to read objects from
file - the file to write to
minimalOutput - whether minimal output is on
Throws:
java.io.FileNotFoundException

dumpStream

public void dumpStream(java.util.Iterator iterator,
                       java.io.File file)
                throws java.io.FileNotFoundException
Description copied from interface: YamlOperations
Dumps a stream of objects specified with an iterator to a file in Yaml format, one document per object

Specified by:
dumpStream in interface YamlOperations
Parameters:
iterator - the iterator to read objects from
file - the file to write to
Throws:
java.io.FileNotFoundException

dump

public java.lang.String dump(java.lang.Object obj)
Description copied from interface: YamlOperations
Dumps an object into Yaml format

Specified by:
dump in interface YamlOperations
Parameters:
obj - the object to dump
Returns:
a String in Yaml format representing the object

dump

public java.lang.String dump(java.lang.Object obj,
                             boolean minimalOutput)
Description copied from interface: YamlOperations
Dumps an object into Yaml format

Specified by:
dump in interface YamlOperations
Parameters:
obj - the object to dump
minimalOutput - whether minimal output is on
Returns:
a String in Yaml format representing the object

dumpStream

public java.lang.String dumpStream(java.util.Iterator iterator)
Description copied from interface: YamlOperations
Dumps a stream of objects specified with an iterator to a String in Yaml format, one document per object

Specified by:
dumpStream in interface YamlOperations
Parameters:
iterator - the iterator to read objects from
Returns:
a String in Yaml format representing the object

dumpStream

public java.lang.String dumpStream(java.util.Iterator iterator,
                                   boolean minimalOutput)
Description copied from interface: YamlOperations
Dumps a stream of objects specified with an iterator to a String in Yaml format, one document per object

Specified by:
dumpStream in interface YamlOperations
Parameters:
iterator - the iterator to read objects from
minimalOutput - whether minimal output is on
Returns:
a String in Yaml format representing the object

getDecodingAccessScope

public java.util.Map<java.lang.String,java.lang.String> getDecodingAccessScope()

setDecodingAccessScope

public void setDecodingAccessScope(java.util.Map<java.lang.String,java.lang.String> decodingAccessScope)

getEncodingAccessScope

public java.util.Map<java.lang.String,java.lang.String> getEncodingAccessScope()

setEncodingAccessScope

public void setEncodingAccessScope(java.util.Map<java.lang.String,java.lang.String> encodingAccessScope)

isFieldAccessibleForDecoding

public boolean isFieldAccessibleForDecoding(java.lang.reflect.Field field)

isFieldAccessibleForEncoding

public boolean isFieldAccessibleForEncoding(java.lang.reflect.Field field)

isConstructorAccessibleForDecoding

public boolean isConstructorAccessibleForDecoding(java.lang.Class clazz)

isPropertyAccessibleForDecoding

public boolean isPropertyAccessibleForDecoding(java.beans.PropertyDescriptor prop)

isPropertyAccessibleForEncoding

public boolean isPropertyAccessibleForEncoding(java.beans.PropertyDescriptor prop)