ptolemy.data.expr
Class CachedMethod.ArgumentConversion

java.lang.Object
  extended by ptolemy.data.expr.CachedMethod.ArgumentConversion
Direct Known Subclasses:
CachedMethod.TypeArgumentConversion
Enclosing class:
CachedMethod

public static class CachedMethod.ArgumentConversion
extends java.lang.Object

Class representing an argument conversion. Instances of this class are returned by getConversions(). Note that in most cases, it is not necessary to reference this class directly, as the invoke() method applies all the necessary conversions. It is provided for code, such as the code generator that need more than the usual amount of information about methods that have been found.

The preference is n index given an order to the preference of conversions. Lower preferences represent less desirable conversions than higher preferences.


Field Summary
protected  int _preference
          The preference is n index given an order to the preference of conversions.
 
Constructor Summary
private CachedMethod.ArgumentConversion(int preference)
          Construct an argument conversino.
 
Method Summary
 java.lang.Object convert(Token input)
          Convert the given token into an object that can be used to invoke a method through the reflection mechanism.
 int getPreference()
          Return the preference of this conversion, relative to other conversions.
 boolean isPreferableTo(CachedMethod.ArgumentConversion conversion)
          Return true if this conversion is preferable to the given conversion.
 java.lang.String toString()
          Return a string representation of this conversion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_preference

protected int _preference
The preference is n index given an order to the preference of conversions. Lower preferences represent less desirable conversions than higher preferences.

Constructor Detail

CachedMethod.ArgumentConversion

private CachedMethod.ArgumentConversion(int preference)
Construct an argument conversino.

Parameters:
preference - The preference of this conversion. The preference is n index given an order to the preference of conversions. Lower preferences represent less desirable conversions than higher preferences.
Method Detail

getPreference

public int getPreference()
Return the preference of this conversion, relative to other conversions. The higher the preference, the more preferable the conversion.

Returns:
The preference of this conversion.

convert

public java.lang.Object convert(Token input)
                         throws IllegalActionException
Convert the given token into an object that can be used to invoke a method through the reflection mechanism. Derived classes will override this method to provide different types of argument conversions.

Parameters:
input - The token to be converted
Throws:
IllegalActionException - Always thrown in this base class.

isPreferableTo

public boolean isPreferableTo(CachedMethod.ArgumentConversion conversion)
Return true if this conversion is preferable to the given conversion.

Parameters:
conversion - The conversion to be tested.
Returns:
True if this conversion is prefereable to the given conversion.

toString

public java.lang.String toString()
Return a string representation of this conversion.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this conversion.