sk.uniba.euromath.gene
Enum ResultEnum

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

public enum ResultEnum
extends Enum<ResultEnum>

Enumerates all possible target types that exporter can accept as an output.

Author:
Martin Vysny

Enum Constant Summary
DOM
          The DOM Document instance.
OBJECT
          Java object result.
SAX
          SAX XMLReader result.
STREAM
          OutputStream result.
 
Field Summary
static List<ResultEnum> priorityList
           List describing priorities for target-to-source conversion.
 
Method Summary
abstract  boolean canBeRedirectedTo(SourceEnum source)
          Checks if output from this kind of result can be redirected to given kind of source.
static ResultEnum getBestResultSourcePair(EnumSet<ResultEnum> result, EnumSet<SourceEnum> source)
          Determines the best way of redirecting result to source.
 SourceEnum getBestSource(EnumSet<SourceEnum> sourceTypes)
          Returns the best source for this result.
abstract  SourceEnum getPair()
          Returns source type that has the same type as this result.
static EnumSet<SourceEnum> getPairSet(EnumSet<ResultEnum> targetTypes)
          Returns set consisting of pairs for all items in given set.
 Class<? extends Result> getResultClass()
          Returns the class of Result object that is represented by the enum item.
 boolean represents(Class<? extends Result> resultClass)
          Returns true if this enum constant represents Source object of required instance.
static ResultEnum valueOf(Class<? extends Result> sourceClass)
          Finds appropriate enum item for the result instance.
static ResultEnum valueOf(String name)
          Returns the enum constant of this type with the specified name.
static ResultEnum[] 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 ResultEnum DOM
The DOM Document instance.


SAX

public static final ResultEnum SAX
SAX XMLReader result.


STREAM

public static final ResultEnum STREAM
OutputStream result.


OBJECT

public static final ResultEnum OBJECT
Java object result.

Field Detail

priorityList

public static final List<ResultEnum> 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.DOM
  3. SourceEnum.SAX - lowest memory consumption,
  4. SourceEnum.STREAM

SourceEnum.SAX should be before DOM however current version of exporter does not support direct SAX-SAX connection - SAX result is connected to SAX source using intermediate DOM document.

Method Detail

values

public static final ResultEnum[] 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(ResultEnum c : ResultEnum.values())
        System.out.println(c);

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

valueOf

public static ResultEnum 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

getResultClass

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

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

represents

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

Parameters:
resultClass - the class of result object.
Returns:
true if this enum constant represents this class, false otherwise.

canBeRedirectedTo

public abstract boolean canBeRedirectedTo(SourceEnum source)
Checks if output from this kind of result can be redirected to given kind of source. Object can be redirected to object only, stream can be redirected to stream only, SAX and DOM can be redirected to anything except the object source.

Parameters:
source - source type to check.
Returns:
true if data flow from this result can be redirected to given source, false otherwise.

valueOf

public static ResultEnum valueOf(Class<? extends Result> sourceClass)
Finds appropriate enum item for the result instance.

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

getPair

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

Returns:
source of same type.

getPairSet

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

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

getBestSource

public SourceEnum getBestSource(EnumSet<SourceEnum> sourceTypes)
Returns the best source for this result.

Parameters:
sourceTypes - allowed source types.
Returns:
the type of the source that best fits this result type, or null if no source type fits.

getBestResultSourcePair

public static ResultEnum getBestResultSourcePair(EnumSet<ResultEnum> result,
                                                 EnumSet<SourceEnum> source)
Determines the best way of redirecting result to source. Returns first item of the result-source pair. Second item can be queried using getBestSource() method.

Parameters:
result - set of possible target types.
source - set of possible source types.
Returns:
best result type that shall form the pair, or null if no pair can be made.


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