se.js.jesdob
Class DobFactory

java.lang.Object
  extended by se.js.jesdob.DobFactory

public class DobFactory
extends java.lang.Object

A DobFactory can be used to create Dobs and DobCollection from Dob datastrings, xml-data or json-data. A DobFactory can also be used to load Dobs from files, either from a resource in your jar-file, or from a specific path on disc. This makes it possible to store your Dobs separated from your source code, which makes it possible to use use Dobs for domain specific languages or scripting.


Nested Class Summary
static class DobFactory.DataFormat
          Data formats that can be used for creating Dob-objects.
 
Constructor Summary
DobFactory()
           
 
Method Summary
static IDob getDob(DobFactory.DataFormat dataFormat, java.lang.String data)
          Returns one specific IDob-object from Dob-data-string.
static IDobCollection getDobs(DobFactory.DataFormat dataFormat, java.lang.String data)
          Returns a new IDobCollection from Dob-data-string.
static IDobCollection getDobsFromFile(java.lang.String filePath)
          Returns a new IDobCollection, read from file from a specific path.
static IDobCollection getDobsFromResource(java.lang.String resourcePath)
          Returns a new IDobCollection, read from file from a resource path.
 void setEncoding(java.lang.String encoding)
          Sets the encoding used when reading Dob-data from files and/or resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DobFactory

public DobFactory()
Method Detail

setEncoding

public void setEncoding(java.lang.String encoding)
Sets the encoding used when reading Dob-data from files and/or resources. If no encoding is set UTF-8 will be used as default encoding.

Parameters:
encoding -

getDobsFromFile

public static IDobCollection getDobsFromFile(java.lang.String filePath)
                                      throws UnsupportedFormatException,
                                             se.js.jesload.loader.CouldNotLoadResourceException
Returns a new IDobCollection, read from file from a specific path.

The dob data in the file can be stored in dob-format, xml-format or json-format. The file must use the correct extention (.dob, .json or .xml), since the DobFactory is using the extention to determine the data type.

Parameters:
filePath - The path to the file containing the dob data.
Returns:
The new IDobCollection, created from the file data.
Throws:
UnsupportedFormatException
se.js.jesload.loader.CouldNotLoadResourceException

getDobsFromResource

public static IDobCollection getDobsFromResource(java.lang.String resourcePath)
                                          throws UnsupportedFormatException,
                                                 se.js.jesload.loader.CouldNotLoadResourceException
Returns a new IDobCollection, read from file from a resource path.

The dob data in the file can be stored in dob-format, xml-format or json-format. The file must use the correct extention (.dob, .json or .xml), since the DobFactory is using the extention to determine the data type.

Parameters:
resourcePath - The path to the project resource.
Returns:
The new IDobCollection, created from the file data.
Throws:
UnsupportedFormatException
se.js.jesload.loader.CouldNotLoadResourceException

getDobs

public static IDobCollection getDobs(DobFactory.DataFormat dataFormat,
                                     java.lang.String data)
Returns a new IDobCollection from Dob-data-string.

The Dob data string can be formatted in dob-format, json-format or xml-format.

Parameters:
dataFormat - The format used in the data-string.
data - The data-string containing the Dob-data.
Returns:
A new IDobCollection, created from the supplied data-string.

getDob

public static IDob getDob(DobFactory.DataFormat dataFormat,
                          java.lang.String data)
Returns one specific IDob-object from Dob-data-string.

The Dob data string can be formatted in dob-format, json-format or xml-format.

Parameters:
dataFormat - The format used in the data-string.
data - The data-string containing the Dob-data.
Returns:
A new IDob, created from the supplied data-string.