ca.quine.jcommons.transform.graph
Class TransformGraph

java.lang.Object
  |
  +--ca.quine.jcommons.transform.graph.TransformGraph

public class TransformGraph
extends Object


Constructor Summary
TransformGraph(String name)
           
 
Method Summary
 void addEdge(TransformEdge edge)
           
static List createListOfListsOfAllOrders(List labels, String[] newLabels)
          Returns a List of all Lists that start with the elements in the given labels list, and comprise every order of elements from the newLabels String array.
 Path dijkstra(String sourceLabel, String targetLabel)
           
 void export(IPrintStream out)
           
 TreeAndCost findMinimumCostTree(String nodeName, String[] outputTypes)
          This method is only used for testing.
 TransformEdge getEdgeWithTypes(String parentNode, String childNode)
           
 int getGeneticAlgorithmMinSize()
          Returns the minimum number of output nodes for which the genetic algorithm will be used to determine the minimum cost path for a given transform.
 Imports getImports()
           
 String getName()
           
 TransformNode getNodeWithName(String nodeName)
           
 int getNumEdges()
           
 double getNumNodes()
           
 ITransformer getTransformer(Object inputObject, String inputType, String[] outputTypes, Object[] transformReceivers)
          Finds a near-optimal path from the input type to all the output types and performs all the transforms to get the input type to those output types.
 ITransformer getTransformer(Object inputObject, String inputType, String outputType, Object transformReceiver)
          Finds the transforms required to take an Object in the input type to the output type, and then returns it as an ITransformer.
 void removeAllEdgeMarkers()
           
 void removeAllNodeMarkers()
           
static String[] removeElement(String[] inputArray, int i)
           
 void setGeneticAlgorithmMinSize(int newSize)
          Sets the minimum number of output nodes for which the genetic algorithm will be used to determine the minimum cost path for a given transform.
 void setImports(Imports imports)
           
 void setName(String name)
           
 void transform(Object inputObject, String inputType, String[] outputTypes, Object[] receivers)
           
 void transform(Object inputObject, String inputType, String outputType, Object transformReceiver)
          Finds the transforms required to take an Object in the input type to the output type, and then executes those transforms.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransformGraph

public TransformGraph(String name)
Method Detail

setGeneticAlgorithmMinSize

public void setGeneticAlgorithmMinSize(int newSize)
Sets the minimum number of output nodes for which the genetic algorithm will be used to determine the minimum cost path for a given transform. If the total number of output nodes for a requested transform is equal to or greater than this number, then the genetic algorithm will be used instead of the optimal algorithm.

Parameters:
newSize -

getGeneticAlgorithmMinSize

public int getGeneticAlgorithmMinSize()
Returns the minimum number of output nodes for which the genetic algorithm will be used to determine the minimum cost path for a given transform. If the total number of output nodes for a requested transform is equal to or greater than this number, then the genetic algorithm will be used instead of the optimal algorithm.


getImports

public Imports getImports()

setImports

public void setImports(Imports imports)

getName

public String getName()

setName

public void setName(String name)

addEdge

public void addEdge(TransformEdge edge)

transform

public void transform(Object inputObject,
                      String inputType,
                      String outputType,
                      Object transformReceiver)
               throws GraphException
Finds the transforms required to take an Object in the input type to the output type, and then executes those transforms. If a transform receiver is supplied, that receiver will receive the transform Objects produced by the transform that creates the final output type.

Parameters:
inputObject -
inputType -
outputType -
transformReceiver - must implement <T>, where <T> is the type in addTransformListener(<T>) on the final transform that takes the Object to the output type, or pass null
GraphException

transform

public void transform(Object inputObject,
                      String inputType,
                      String[] outputTypes,
                      Object[] receivers)
               throws GraphException
GraphException

getTransformer

public ITransformer getTransformer(Object inputObject,
                                   String inputType,
                                   String outputType,
                                   Object transformReceiver)
                            throws GraphException
Finds the transforms required to take an Object in the input type to the output type, and then returns it as an ITransformer. If a transform receiver is supplied, that receiver will receive the transform Objects produced by the transform that creates the final output type.

Parameters:
inputObject -
inputType -
outputType -
transformReceiver - must implement <T>, where <T> is the type in addTransformListener(<T>) on the final transform that takes the Object to the output type, or pass null
GraphException

getTransformer

public ITransformer getTransformer(Object inputObject,
                                   String inputType,
                                   String[] outputTypes,
                                   Object[] transformReceivers)
                            throws GraphException
Finds a near-optimal path from the input type to all the output types and performs all the transforms to get the input type to those output types. If transform receivers are supplied, those receivers will receive the transform Objects produced by the transforms that create the final output types.

Parameters:
inputObject -
inputType -
outputTypes -
transformReceivers - see transform(Object, String, String, Object)
GraphException

findMinimumCostTree

public TreeAndCost findMinimumCostTree(String nodeName,
                                       String[] outputTypes)
                                throws GraphException
This method is only used for testing.

Parameters:
nodeName -
GraphException

dijkstra

public Path dijkstra(String sourceLabel,
                     String targetLabel)

createListOfListsOfAllOrders

public static List createListOfListsOfAllOrders(List labels,
                                                String[] newLabels)
Returns a List of all Lists that start with the elements in the given labels list, and comprise every order of elements from the newLabels String array.

Parameters:
labels -
newLabels -

removeElement

public static String[] removeElement(String[] inputArray,
                                     int i)

removeAllNodeMarkers

public void removeAllNodeMarkers()

removeAllEdgeMarkers

public void removeAllEdgeMarkers()

getNodeWithName

public TransformNode getNodeWithName(String nodeName)

getEdgeWithTypes

public TransformEdge getEdgeWithTypes(String parentNode,
                                      String childNode)

getNumEdges

public int getNumEdges()

getNumNodes

public double getNumNodes()

export

public void export(IPrintStream out)
            throws IOException
IOException