pl.psnc.dl.ege
Class EGEImpl

java.lang.Object
  extended by pl.psnc.dl.ege.EGEImpl
All Implemented Interfaces:
EGE, ExceptionListener

public class EGEImpl
extends java.lang.Object
implements EGE, ExceptionListener

Standard Enrich Garage Engine(EGE) implementation.

Implementation uses JUNG library for generating graph of conversions.

Author:
mariuszs

Field Summary
static int BUFFER_SIZE
           
 
Constructor Summary
EGEImpl()
          Default Constructor : initializes basic structures.
 
Method Summary
 void catchException(java.lang.Exception ex)
          Implemented method normally would store received exception.
 java.util.List<ConversionsPath> findConversionPaths(DataType sourceDataType)
          Method returns every possible conversion path for specified input DataType.
 java.util.List<ConversionsPath> findConversionPaths(DataType sourceDataType, DataType resultDataType)
          Method return every possible/unique convert path for specified input type data with pointed output type data.
 edu.uci.ics.jung.graph.Graph<ConversionAction,java.lang.Integer> getConvertersGraph()
          Returns conversion graph.
 void performConversion(java.io.InputStream inputStream, java.io.OutputStream outputStream, ConversionsPath path)
          Performs sequence of conversions based on specified convert path.
 java.lang.String performRecognition(java.io.InputStream inputData)
          Method performs recognition of the MIME type of an input data.
 ValidationResult performValidation(java.io.InputStream inputData, DataType inputDataType)
          Method performs validation using all loaded through extension mechanism Validator implementations.
 java.util.Set<DataType> returnSupportedInputFormats()
          Returns all supported by EGE input formats - entry points for conversion.
 java.util.Set<DataType> returnSupportedValidationFormats()
          Returns set of data types that are supported for validation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE
See Also:
Constant Field Values
Constructor Detail

EGEImpl

public EGEImpl()
Default Constructor : initializes basic structures.

Method Detail

findConversionPaths

public java.util.List<ConversionsPath> findConversionPaths(DataType sourceDataType)
Method returns every possible conversion path for specified input DataType. One of the received paths can be then used to perform chained conversion.

Specified by:
findConversionPaths in interface EGE
Parameters:
sourceDataType - input data type
Returns:
list of possible convert paths.

findConversionPaths

public java.util.List<ConversionsPath> findConversionPaths(DataType sourceDataType,
                                                           DataType resultDataType)
Method return every possible/unique convert path for specified input type data with pointed output type data.

Specified by:
findConversionPaths in interface EGE
Parameters:
sourceDataType - input data type
resultDataType - expected output data type
Returns:
list of possible convert paths.

performValidation

public ValidationResult performValidation(java.io.InputStream inputData,
                                          DataType inputDataType)
                                   throws java.io.IOException,
                                          ValidatorException,
                                          EGEException

Method performs validation using all loaded through extension mechanism Validator implementations.

Method returns instance of ValidationResult which contains validation status and error/warning messages.
If there is no validator that supports specified data type, then ValidatorException will be throw.
If some unexpected errors occurs during validation, method will throw EGEException.

Specified by:
performValidation in interface EGE
Parameters:
inputData - input stream that contains necessary data
inputDataType - validation argument
Returns:
instance of ValidationResult
Throws:
java.io.IOException
{@link - ValidatorException}
{@link - EGEException}
ValidatorException
EGEException

performRecognition

public java.lang.String performRecognition(java.io.InputStream inputData)
                                    throws RecognizerException,
                                           java.io.IOException
Method performs recognition of the MIME type of an input data. If any of the loaded Recognizer implementations recognizes MIME type, method returns String value of this MIME type, otherwise method throws exception.

Specified by:
performRecognition in interface EGE
Parameters:
inputData - input stream that contains necessary data
Returns:
MIME type as String
Throws:
RecognizerException
java.io.IOException

performConversion

public void performConversion(java.io.InputStream inputStream,
                              java.io.OutputStream outputStream,
                              ConversionsPath path)
                       throws ConverterException,
                              EGEException,
                              java.io.IOException
Performs sequence of conversions based on specified convert path.
Data is taken from selected input stream and after all sequenced conversions sent to pointed output stream.

Specified by:
performConversion in interface EGE
Parameters:
inputStream - source of data to convert
outputStream - output stream for converted data
path - defines sequence of conversion.
Throws:
EGEException - if unexpected error occurred within method.
ConverterException - if during conversion method an exception occurred.
java.io.IOException

returnSupportedValidationFormats

public java.util.Set<DataType> returnSupportedValidationFormats()

Returns set of data types that are supported for validation.

Specified by:
returnSupportedValidationFormats in interface EGE
Returns:
set of data types

returnSupportedInputFormats

public java.util.Set<DataType> returnSupportedInputFormats()

Returns all supported by EGE input formats - entry points for conversion.

Specified by:
returnSupportedInputFormats in interface EGE
Returns:
set of a supported input formats

getConvertersGraph

public edu.uci.ics.jung.graph.Graph<ConversionAction,java.lang.Integer> getConvertersGraph()
Returns conversion graph.

Returns:
JUNG graph structure of conversion actions

catchException

public void catchException(java.lang.Exception ex)
Description copied from interface: ExceptionListener
Implemented method normally would store received exception.

Specified by:
catchException in interface ExceptionListener
Parameters:
ex - received exception


Copyright © 2010. All Rights Reserved.