sk.uniba.euromath.gene
Enum SourceEnum

java.lang.Object
  extended by java.lang.Enum<SourceEnum>
      extended by sk.uniba.euromath.gene.SourceEnum
All Implemented Interfaces:
Serializable, Comparable<SourceEnum>

public enum SourceEnum
extends Enum<SourceEnum>

Enumerates all possible source types that exporter can accept as an input.

Author:
Martin Vysny

Enum Constant Summary
DOM
          The DOM Document instance source.
OBJECT
          Java Object source.
SAX
          The DocumentHandler instance source.
STREAM
          InputStream source.
 
Field Summary
static List<SourceEnum> priorityList
           List describing priorities for target-to-source conversion.
 
Method Summary
abstract  Source convert(Source source, ThreadGroup group)
           Tries to convert given source to this source type.
abstract  ResultEnum getPair()
          Returns result type that has the same type as this source.
static EnumSet<ResultEnum> getPairSet(EnumSet<SourceEnum> sourceTypes)
          Returns set consisting of pairs for all items in given set.
static EnumSet<SourceEnum> getRedirectKinds(EnumSet<ResultEnum> products)
          Computes all kinds of sources, that the product kinds are able to be redirected to.
 Class<? extends Source> getSourceClass()
          Returns the class of Source object that is represented by the enum item.
 boolean represents(Class<? extends Source> sourceClass)
          Returns true if this enum constant represents Source object of required instance.
static SourceEnum valueOf(Class<? extends Source> sourceClass)
          Finds appropriate enum item for the source instance.
static SourceEnum valueOf(String name)
          Returns the enum constant of this type with the specified name.
static SourceEnum[] values()
          Returns an array containing the constants of this enum type, in the order they're declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

DOM

public static final SourceEnum DOM
The DOM Document instance source.


SAX

public static final SourceEnum SAX
The DocumentHandler instance source.


STREAM

public static final SourceEnum STREAM
InputStream source.


OBJECT

public static final SourceEnum OBJECT
Java Object source.

Field Detail

priorityList

public static final List<SourceEnum> priorityList

List describing priorities for target-to-source conversion. First item has the highest priority. Items priorities are as follows:

  1. SourceEnum.OBJECT - native data exchange
  2. SourceEnum.SAX - lowest memory consumption,
  3. SourceEnum.DOM
  4. SourceEnum.STREAM

Method Detail

values

public static final SourceEnum[] values()
Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants as follows:
for(SourceEnum c : SourceEnum.values())
        System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they're declared

valueOf

public static SourceEnum valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name

getSourceClass

public Class<? extends Source> getSourceClass()
Returns the class of Source object that is represented by the enum item.

Returns:
the class of Source object that is represented by the enum item.

represents

public boolean represents(Class<? extends Source> sourceClass)
Returns true if this enum constant represents Source object of required instance.

Parameters:
sourceClass -
Returns:
true if this enum constant represents this class, false otherwise.

valueOf

public static SourceEnum valueOf(Class<? extends Source> sourceClass)
Finds appropriate enum item for the source instance.

Parameters:
sourceClass - class of Source object instance.
Returns:
enum item.

getPair

public abstract ResultEnum getPair()
Returns result type that has the same type as this source.

Returns:
result of same type.

convert

public abstract Source convert(Source source,
                               ThreadGroup group)
                        throws IOException,
                               TransformerException

Tries to convert given source to this source type. Conversion follows this table:

From To Description
DOM SAX Standard conversion
SAX DOM Standard conversion
DOM, SAX Stream Serialization is performed. Result is valid XML file. Output document formatting is undefined.
Stream DOM, SAX Stream is not parsed - one Text node containing stream contents is constructed instead. Stream is expected to be in UTF-8 encoding.
Object Stream, DOM, SAX Object's toString() is called and result is returned in form of stream (in case of Stream result; UTF-8 encoding), or as a Text node.
DOM, SAX, Stream Object Returns null

If both kinds are same then source is simply returned.

The conversion may be performed by a background thread, to save memory space.

Parameters:
source - source to convert.
group - attaches the thread to this group. For more info please look on Thread.Thread(ThreadGroup, String) description.
Returns:
source converted to this type. If the conversion is not possible then return null.
Throws:
IOException - if i/o error occurs during source reading.
TransformerException - if transformer fails while processing source.

getPairSet

public static EnumSet<ResultEnum> getPairSet(EnumSet<SourceEnum> sourceTypes)
Returns set consisting of pairs for all items in given set.

Parameters:
sourceTypes - the source types.
Returns:
set of target types

getRedirectKinds

public static final EnumSet<SourceEnum> getRedirectKinds(EnumSet<ResultEnum> products)
Computes all kinds of sources, that the product kinds are able to be redirected to.

Parameters:
products - set of result kinds.
Returns:
set of sources, each source is redirectable from at least one pipe output kind specified in products set.


Copyright 2003-2003-2006 null. All Rights Reserved.