* @return the conversion preference. A high number indicates a low preference;
* -1 indicates that conversion is not possible.
*/
private int getConversionPreference(TypeHierarchy th, Expression arg, cli.System.Type required) {
ItemType itemType = arg.getItemType(th);
int cardinality = arg.getCardinality();
if (required == DotNetExtensionFunctionCall.CLI_OBJECT) {
return 100;
} else if (Cardinality.allowsMany(cardinality)) {
if (required.IsAssignableFrom(DotNetExtensionFunctionCall.CLI_SEQUENCEITERATOR)) {
return 20;
// } else if (required.IsAssignableFrom(DotNetExtensionFunctionCall.CLI_XDMVALUE)) {
// return 21;
} else if (required.IsAssignableFrom(DotNetExtensionFunctionCall.CLI_VALUE)) {
return 22;
} else if (DotNetExtensionFunctionCall.CLI_ICOLLECTION.IsAssignableFrom(required)) {
return 23;
} else if (required.get_IsArray()) {
return 24;
// sort out at run-time whether the component type of the array is actually suitable
} else {
return 80; // conversion possible only if external object model supports it
}
} else {
if (Type.isNodeType(itemType)) {
if (required.IsAssignableFrom(DotNetExtensionFunctionCall.CLI_NODEINFO)) {
return 20;
} else if (required.IsAssignableFrom(DotNetExtensionFunctionCall.CLI_DOCUMENTINFO)) {
return 21;
// } else if (required.IsAssignableFrom(DotNetExtensionFunctionCall.CLI_XDMNODE)) {
// return 20;
} else {
return 80;
}
// } else if (itemType instanceof ExternalObjectType) {
// TODO: support wrapping of external .NET objects
// cli.System.Type ext = ((ExternalObjectType)itemType).getJavaClass();
// if (required.IsAssignableFrom(ext)) {
// return 10;
// } else {
// return -1;
// }
} else {
int primitiveType = itemType.getPrimitiveType();
return atomicConversionPreference(primitiveType, required);
}
}
}