codesimian.wrap
Interface WrapAbilities

All Known Implementing Classes:
DefaultWrapAbilities, ListInListOutWrapAbilities, WrapAbilities.WrapWrapAbilities

public interface WrapAbilities

describes the abilities of some object to create wrappers that convert an object of type A to an object of type B, and with what fraction of accuracy.

The object must be able to take in an arbitrary object and output an other arbitrary object, defined by the type of object input and type of object requested.

For example, convert double[] to String or convert double[][] to String[]. SETGET wrapCreator = ...; WrapAbilities wa = (WrapAbilities) wrapCreator.GETL(WrapAbilities.class); if( wrapCreator.SETL(new double[][]{...}); String s[] = wrapCreator unfinished...


Nested Class Summary
static class WrapAbilities.WrapWrapAbilities
          wrap a subclass of WrapAbilities in this to limit it to the functions of WrapAbilities.
 
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()
          beware: these could be generated at the time this function is called
 

Method Detail

accuracyOfWrap

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.

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.


costOfWrap

double costOfWrap(java.lang.Class from,
                  java.lang.Class to)
default should be 1000


getAllFrom

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)


getAllTo

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)


getAllFromForThisTo

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)


getAllToForThisFrom

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)


getAllWrapAbilitys

java.util.List<WrapAbility> getAllWrapAbilitys()
beware: these could be generated at the time this function is called