codesimian.wrap
Class ListInListOutWrapAbilities

java.lang.Object
  extended by codesimian.wrap.ListInListOutWrapAbilities
All Implemented Interfaces:
WrapAbilities

public class ListInListOutWrapAbilities
extends java.lang.Object
implements WrapAbilities

unlike DefaultWrapAbilities, ListInListOutWrapAbilities does not consider Classes in pairs. It has a list of ok input classes and a list of ok output classes, and any input class may be cast to any output class. It also has a cost for each class, and the cost for x converted to y is the sum of x cost and y cost, but no pairs of cost. Similarly it has an accuracy for each class, but no pairs of accuracy.


Nested Class Summary
 
Nested classes/interfaces inherited from interface codesimian.wrap.WrapAbilities
WrapAbilities.WrapWrapAbilities
 
Constructor Summary
ListInListOutWrapAbilities(java.lang.Class[] in, double[] inAccuracy, double[] inCost, java.lang.Class[] out, double[] outAccuracy, double[] outCost)
           
 
Method Summary
 double accuracyOfWrap(java.lang.Class from, java.lang.Class to)
          returns 0 if can not wrap that way, else returns a number between 0 and 1.
 double costOfWrap(java.lang.Class from, java.lang.Class to)
          default should be 1000
 java.util.List<java.lang.Class> getAllFrom()
          all types of input objects that can be used to create at least 1 other type of object each, (and optionally with preferred classes at lower index)
 java.util.List<java.lang.Class> getAllFromForThisTo(java.lang.Class to)
          returns all input types that can be converted to the 'to' type, (and optionally with preferred classes at lower index)
 java.util.List<java.lang.Class> getAllTo()
          all types that can be created, given the required input object, (and optionally with preferred classes at lower index)
 java.util.List<java.lang.Class> getAllToForThisFrom(java.lang.Class from)
          returns all output types that can be converted to the 'from' type, (and optionally with preferred classes at lower index)
 java.util.List<WrapAbility> getAllWrapAbilitys()
          Wastes memory and is slow because all inputs can be converted to all outputs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListInListOutWrapAbilities

public ListInListOutWrapAbilities(java.lang.Class[] in,
                                  double[] inAccuracy,
                                  double[] inCost,
                                  java.lang.Class[] out,
                                  double[] outAccuracy,
                                  double[] outCost)
Method Detail

accuracyOfWrap

public double accuracyOfWrap(java.lang.Class from,
                             java.lang.Class to)
Description copied from interface: WrapAbilities
returns 0 if can not wrap that way, else returns a number between 0 and 1.

For example, accuracyOfWrap(byte.class,int.class) should return 1, but accuracyOfWrap(int.class,byte.class) should return 0.25 since 3/4 of the bits are lost, but since ints use all their bits less often than bytes use all their bytes, you may return (for example) .4 instead.

accuracyOfWrap(StringBuffer.class,String.class) should return a high fraction. accuracyOfWrap(boolean.class,ANYTHINGEXCEPTBOOLEAN.class) should return a very low fraction because there is only 1 bit of information in a boolean.

Specified by:
accuracyOfWrap in interface WrapAbilities

costOfWrap

public double costOfWrap(java.lang.Class from,
                         java.lang.Class to)
Description copied from interface: WrapAbilities
default should be 1000

Specified by:
costOfWrap in interface WrapAbilities

getAllFrom

public java.util.List<java.lang.Class> getAllFrom()
Description copied from interface: WrapAbilities
all types of input objects that can be used to create at least 1 other type of object each, (and optionally with preferred classes at lower index)

Specified by:
getAllFrom in interface WrapAbilities

getAllTo

public java.util.List<java.lang.Class> getAllTo()
Description copied from interface: WrapAbilities
all types that can be created, given the required input object, (and optionally with preferred classes at lower index)

Specified by:
getAllTo in interface WrapAbilities

getAllFromForThisTo

public java.util.List<java.lang.Class> getAllFromForThisTo(java.lang.Class to)
Description copied from interface: WrapAbilities
returns all input types that can be converted to the 'to' type, (and optionally with preferred classes at lower index)

Specified by:
getAllFromForThisTo in interface WrapAbilities

getAllToForThisFrom

public java.util.List<java.lang.Class> getAllToForThisFrom(java.lang.Class from)
Description copied from interface: WrapAbilities
returns all output types that can be converted to the 'from' type, (and optionally with preferred classes at lower index)

Specified by:
getAllToForThisFrom in interface WrapAbilities

getAllWrapAbilitys

public java.util.List<WrapAbility> getAllWrapAbilitys()
Wastes memory and is slow because all inputs can be converted to all outputs. Creates them in an immutable list the first time and returns it for later calls.

Specified by:
getAllWrapAbilitys in interface WrapAbilities