| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static Primitive | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static Primitive | VALID_CAST
Special value that indicates by identity that the result of a cast operation was a valid cast. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static UtilEvalError | |
| pack-priv static UtilEvalError | |
| public static Object | castObject(Object
an Object or bsh.Primitive primitive value (including
Primitive.NULL or Primitive.VOID ) fromValue, Class<T> the class type of the cast result, which may include
primitive types, e.g. Byte.TYPE toType, int operation)Attempt to cast an object instance to a new type if possible via BeanShell extended syntax rules. |
| private static Object | castObject(Class<T>
the class type of the cast result, which may include
primitive types, e.g. Byte.TYPE. toType may be null to indicate a
loose type assignment (which matches any fromType). toType, Class<T> is the class type of the value to be cast including
java primitive TYPE classes for primitives.
If fromValue is (or would be) Primitive.NULL then fromType should be null. fromType, Object an Object or bsh.Primitive primitive value (including
Primitive.NULL or Primitive.VOID ) fromValue, int is Types.CAST or Types.ASSIGNMENT operation, boolean If checkOnly is true then fromValue must be null.
FromType is checked for the cast to toType...
If checkOnly is false then fromValue must be non-null
(Primitive.NULL is ok) and the actual cast is performed. checkOnly)Perform a type conversion or test if a type conversion is possible with respect to BeanShell extended rules. |
| public static Class | |
| pack-priv static boolean | isBshAssignable(Class<T> toType, Class<T> fromType)
Test if a type can be converted to another type via BeanShell extended syntax rules (a superset of Java conversion rules). |
| pack-priv static boolean | isJavaAssignable(Class<T>
assigning from rhsType to lhsType lhsType, Class<T> assigning from rhsType to lhsType rhsType)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). |
| pack-priv static boolean | isJavaBaseAssignable(Class<T> lhsType, Class<T>
may be null to indicate primitive null value rhsType)Is the assignment legal via original Java (up to version 1.4) assignment rules, not including auto-boxing/unboxing. |
| pack-priv static boolean | isJavaBoxTypesAssignable(Class<T> lhsType, Class<T> rhsType)
Determine if the type is assignable via Java boxing/unboxing rules. |
| pack-priv static boolean | isSignatureAssignable(Class<T>[] from, Class<T>[] 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. |
| private static boolean |
| ASSIGNMENT | back to summary |
|---|---|
| pack-priv static final int ASSIGNMENT | |
| BSH_ASSIGNABLE | back to summary |
|---|---|
| pack-priv static final int BSH_ASSIGNABLE | |
| CAST | back to summary |
|---|---|
| pack-priv static final int CAST | |
| FIRST_ROUND_ASSIGNABLE | back to summary |
|---|---|
| pack-priv static final int FIRST_ROUND_ASSIGNABLE | |
| INVALID_CAST | back to summary |
|---|---|
| pack-priv static Primitive INVALID_CAST | |
| JAVA_BASE_ASSIGNABLE | back to summary |
|---|---|
| pack-priv static final int JAVA_BASE_ASSIGNABLE | |
| JAVA_BOX_TYPES_ASSIGABLE | back to summary |
|---|---|
| pack-priv static final int JAVA_BOX_TYPES_ASSIGABLE | |
| JAVA_VARARGS_ASSIGNABLE | back to summary |
|---|---|
| pack-priv static final int JAVA_VARARGS_ASSIGNABLE | |
| LAST_ROUND_ASSIGNABLE | back to summary |
|---|---|
| pack-priv static final int LAST_ROUND_ASSIGNABLE | |
| VALID_CAST | back to summary |
|---|---|
| pack-priv static Primitive VALID_CAST 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. | |
| Types | back to summary |
|---|---|
| pack-priv Types() | |
| castError | back to summary |
|---|---|
| pack-priv static UtilEvalError castError(Class<T> lhsType, Class<T> rhsType, int operation) Return a UtilEvalError or UtilTargetError wrapping a ClassCastException describing an illegal assignment or illegal cast, respectively. | |
| castError | back to summary |
|---|---|
| pack-priv static UtilEvalError castError(String lhs, String rhs, int operation) | |
| castObject | back to summary |
|---|---|
| public static Object castObject(Object fromValue, Class<T> toType, int operation) throws UtilEvalError 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.
| |
| castObject | back to summary |
|---|---|
| private static Object castObject(Class<T> toType, Class<T> fromType, Object fromValue, int operation, boolean checkOnly) throws UtilEvalError Perform a type conversion or test if a type conversion is possible with respect to BeanShell extended rules. These rules are always a superset of the Java language rules, so this method can also perform (but not test) any Java language assignment or cast conversion. This method can perform the functionality of testing if an assignment or cast is ultimately possible (with respect to BeanShell) as well as the functionality of performing the necessary conversion of a value based on the specified target type. This combined functionality is done for expediency and could be separated later. Other methods such as isJavaAssignable() should be used to determine the suitability of an assignment in a fine grained or restrictive way based on context before calling this method A CAST is stronger than an ASSIGNMENT operation in that it will attempt to perform primtive operations that cast to a smaller type. e.g. (byte)myLong; These are used in explicit primitive casts, primitive delclarations and array declarations. I don't believe there are any object conversions which are different between ASSIGNMENT and CAST (e.g. scripted object to interface proxy in bsh is done on assignment as well as cast). This method does not obey strictJava(), you must test first before using this method if you care. (See #isJavaAssignable()).
| |
| getTypes | back to summary |
|---|---|
| public static Class Get the Java types of the arguments. | |
| isBshAssignable | back to summary |
|---|---|
| pack-priv static boolean isBshAssignable(Class<T> toType, Class<T> fromType) Test if a type can be converted to another type via BeanShell extended syntax rules (a superset of Java conversion rules). | |
| isJavaAssignable | back to summary |
|---|---|
| pack-priv static boolean isJavaAssignable(Class<T> lhsType, Class<T> rhsType) 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.
| |
| isJavaBaseAssignable | back to summary |
|---|---|
| pack-priv static boolean isJavaBaseAssignable(Class<T> lhsType, Class<T> rhsType) Is the assignment legal via original Java (up to version 1.4) assignment rules, not including auto-boxing/unboxing.
| |
| isJavaBoxTypesAssignable | back to summary |
|---|---|
| pack-priv static boolean isJavaBoxTypesAssignable(Class<T> lhsType, Class<T> rhsType) Determine if the type is assignable via Java boxing/unboxing rules. | |
| isSignatureAssignable | back to summary |
|---|---|
| pack-priv static boolean isSignatureAssignable(Class<T>[] from, Class<T>[] 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. | |
| isSignatureVarargsAssignable | back to summary |
|---|---|
| private static boolean isSignatureVarargsAssignable(Class<T>[] from, Class<T>[] to) | |