mulan.data
Class LabelsBuilder

java.lang.Object
  extended by mulan.data.LabelsBuilder

public final class LabelsBuilder
extends Object

The LabelsBuilder is responsible for creation of LabelsMetaDataImpl instance from specified XML file source. The builder ensures XML source validity against XML schema.

Version:
2012.02.26
Author:
Jozef Vilcek

Field Summary
protected static String LABELS_SCHEMA_NAMESPACE
          The namespace of the schema for label representation
 
Constructor Summary
LabelsBuilder()
           
 
Method Summary
static LabelsMetaData createLabels(InputStream inputStream)
          Creates a LabelsMetaData instance from specified input stream.
static LabelsMetaData createLabels(String xmlLabelsFilePath)
          Creates a LabelsMetaData instance from XML file specified by the path.
static void dumpLabels(LabelsMetaData labelsMetaData, OutputStream outputStream)
          Dumps specified labels meta-data, in XML format, into the specified OutputStream.
static void dumpLabels(LabelsMetaData labelsMetaData, String xmlDumpFilePath)
          Dumps specified labels meta-data into the file in XML format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LABELS_SCHEMA_NAMESPACE

protected static final String LABELS_SCHEMA_NAMESPACE
The namespace of the schema for label representation

See Also:
Constant Field Values
Constructor Detail

LabelsBuilder

public LabelsBuilder()
Method Detail

createLabels

public static LabelsMetaData createLabels(String xmlLabelsFilePath)
                                   throws LabelsBuilderException
Creates a LabelsMetaData instance from XML file specified by the path.

Parameters:
xmlLabelsFilePath - the path to XML file containing labels definition
Returns:
the LabelsMetaData instance
Throws:
ArgumentNullException - if specified path to XML file is null
IllegalArgumentException - if file under specified path does not exists
LabelsBuilderException - if specified file can not be read/opened

createLabels

public static LabelsMetaData createLabels(InputStream inputStream)
                                   throws LabelsBuilderException
Creates a LabelsMetaData instance from specified input stream.

Parameters:
inputStream - the input stream containing labels definition in XML format
Returns:
the LabelsMetaData instance
Throws:
ArgumentNullException - if specified input stream is null
LabelsBuilderException - if any error occur when validating XML against schema or when creating labels data form specified input stream

dumpLabels

public static void dumpLabels(LabelsMetaData labelsMetaData,
                              String xmlDumpFilePath)
                       throws LabelsBuilderException
Dumps specified labels meta-data into the file in XML format. If the file already exists, the content will be overwritten.

Parameters:
labelsMetaData - the meta-data which has to be dumped into the file
xmlDumpFilePath - the path to the file where meta-data should be dumped
Throws:
LabelsBuilderException - if specified file can not be read/opened
ArgumentNullException - if path to the file is not specified

dumpLabels

public static void dumpLabels(LabelsMetaData labelsMetaData,
                              OutputStream outputStream)
                       throws LabelsBuilderException
Dumps specified labels meta-data, in XML format, into the specified OutputStream.

Parameters:
labelsMetaData - the meta-data which has to be dumped
outputStream - the output stream where XML dup will be written
Throws:
LabelsBuilderException - if error occurs during the serialization of meta-data to the XML format of resulting XML is not valid against the schema
ArgumentNullException - if specified output strema is null.