// see if the variant is a wrapper object
if (variant.getType() != COM.VT_DISPATCH) {
return false;
}
OleAutomation auto = null;
Variant result = null;
try {
auto = new OleAutomation(variant.getDispatch());
// see if it has a valueOf method
int[] ids = auto.getIDsOfNames(new String[] {"valueOf"});
if (ids == null) {
return false;
}
result = auto.invoke(ids[0]);
/*
* If the return type of the valueOf method is string, we assume it is a
* String wrapper object.
*/
return result.getType() == COM.VT_BSTR;
} finally {
if (auto != null) {
auto.dispose();
}
if (result != null) {
result.dispose();
}
}
}