| java.lang.Object bsh.Types
Types | class Types (Code) | | Static routines supporing type comparison and conversion in BeanShell.
The following are notes on type comparison and conversion in BeanShell.
|
Method Summary | |
static boolean | areSignaturesEqual(Class[] from, Class[] to) Are the two signatures exactly equal? This is checked for a special
case in overload resolution. | static UtilEvalError | castError(Class lhsType, Class rhsType, int operation) | static UtilEvalError | castError(String lhs, String rhs, int operation) | public static Object | castObject(Object fromValue, Class toType, int operation) Attempt to cast an object instance to a new type if possible via
BeanShell extended syntax rules. | public static Class[] | getTypes(Object[] args) Get the Java types of the arguments. | static boolean | isBshAssignable(Class toType, Class fromType) Test if a type can be converted to another type via BeanShell
extended syntax rules (a superset of Java conversion rules). | static boolean | isJavaAssignable(Class lhsType, Class rhsType) Test if a conversion of the rhsType type to the lhsType type is legal via
standard Java assignment conversion rules (i.e. | static boolean | isJavaBaseAssignable(Class lhsType, Class rhsType) Is the assignment legal via original Java (up to version 1.4)
assignment rules, not including auto-boxing/unboxing. | static boolean | isJavaBoxTypesAssignable(Class lhsType, Class rhsType) Determine if the type is assignable via Java boxing/unboxing rules. | static boolean | isSignatureAssignable(Class[] from, Class[] to, int round) Is the 'from' signature (argument types) assignable to the 'to'
signature (candidate method types)
This method handles the special case of null values in 'to' types
indicating a loose type and matching anything. |
CASTASSIGNMENT | final static int CASTASSIGNMENT(Code) | | |
FIRST_ROUND_ASSIGNABLELAST_ROUND_ASSIGNABLE | final static int FIRST_ROUND_ASSIGNABLELAST_ROUND_ASSIGNABLE(Code) | | |
JAVA_BASE_ASSIGNABLEJAVA_BOX_TYPES_ASSIGABLEJAVA_VARARGS_ASSIGNABLEBSH_ASSIGNABLE | final static int JAVA_BASE_ASSIGNABLEJAVA_BOX_TYPES_ASSIGABLEJAVA_VARARGS_ASSIGNABLEBSH_ASSIGNABLE(Code) | | |
VALID_CAST | static Primitive VALID_CAST(Code) | | Special value that indicates by identity that the result of a cast
operation was a valid cast. This is used by castObject() and
castPrimitive() in the checkOnly mode of operation. This value is a
Primitive type so that it can be returned by castPrimitive.
|
areSignaturesEqual | static boolean areSignaturesEqual(Class[] from, Class[] to)(Code) | | Are the two signatures exactly equal? This is checked for a special
case in overload resolution.
|
castError | static UtilEvalError castError(Class lhsType, Class rhsType, int operation)(Code) | | Return a UtilEvalError or UtilTargetError wrapping a ClassCastException
describing an illegal assignment or illegal cast, respectively.
|
castObject | public static Object castObject(Object fromValue, Class toType, int operation) throws UtilEvalError(Code) | | Attempt to cast an object instance to a new type if possible via
BeanShell extended syntax rules. These rules are always a superset of
Java conversion rules. If you wish to impose context sensitive
conversion rules then you must test before calling this method.
This method can handle fromValue Primitive types (representing
primitive casts) as well as fromValue object casts requiring interface
generation, etc.
Parameters: toType - the class type of the cast result, which may includeprimitive types, e.g. Byte.TYPE Parameters: fromValue - an Object or bsh.Primitive primitive value (includingPrimitive.NULL or Primitive.VOID ) See Also: Types.isBshAssignable(Class,Class) |
getTypes | public static Class[] getTypes(Object[] args)(Code) | | Get the Java types of the arguments.
|
isBshAssignable | static boolean isBshAssignable(Class toType, Class fromType)(Code) | | Test if a type can be converted to another type via BeanShell
extended syntax rules (a superset of Java conversion rules).
|
isJavaAssignable | static boolean isJavaAssignable(Class lhsType, Class rhsType)(Code) | | Test if a conversion of the rhsType type to the lhsType type is legal via
standard Java assignment conversion rules (i.e. without a cast).
The rules include Java 5 autoboxing/unboxing.
For Java primitive TYPE classes this method takes primitive promotion
into account. The ordinary Class.isAssignableFrom() does not take
primitive promotion conversions into account. Note that Java allows
additional assignments without a cast in combination with variable
declarations and array allocations. Those are handled elsewhere
(maybe should be here with a flag?)
This class accepts a null rhsType type indicating that the rhsType was the
value Primitive.NULL and allows it to be assigned to any reference lhsType
type (non primitive).
Note that the getAssignableForm() method is the primary bsh method for
checking assignability. It adds additional bsh conversions, etc.
See Also: Types.isBshAssignable(Class,Class) Parameters: lhsType - assigning from rhsType to lhsType Parameters: rhsType - assigning from rhsType to lhsType |
isJavaBaseAssignable | static boolean isJavaBaseAssignable(Class lhsType, Class rhsType)(Code) | | Is the assignment legal via original Java (up to version 1.4)
assignment rules, not including auto-boxing/unboxing.
Parameters: rhsType - may be null to indicate primitive null value |
isJavaBoxTypesAssignable | static boolean isJavaBoxTypesAssignable(Class lhsType, Class rhsType)(Code) | | Determine if the type is assignable via Java boxing/unboxing rules.
|
isSignatureAssignable | static boolean isSignatureAssignable(Class[] from, Class[] to, int round)(Code) | | Is the 'from' signature (argument types) assignable to the 'to'
signature (candidate method types)
This method handles the special case of null values in 'to' types
indicating a loose type and matching anything.
|
|
|