diff --git a/jni/Variant.cpp b/jni/Variant.cpp index 216fc06..76c2dfe 100644 --- a/jni/Variant.cpp +++ b/jni/Variant.cpp @@ -520,10 +520,12 @@ JNIEXPORT jstring JNICALL Java_com_jacob_com_Variant_toString return env->NewStringUTF("null"); } HRESULT hr; + // this actually changes the type of the variant to a String! if (FAILED(hr = VariantChangeType(v, v, 0, VT_BSTR))) { // cannot change type to a string return env->NewStringUTF("???"); } + // create a returnable string from the converted variant BSTR bs = V_BSTR(v); jstring js = env->NewString(bs, SysStringLen(bs)); return js; @@ -1114,6 +1116,9 @@ JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putFloat } } +/** + * changes the type of the underlying variant data + * */ JNIEXPORT void JNICALL Java_com_jacob_com_Variant_changeType (JNIEnv *env, jobject _this, jshort t) { diff --git a/src/com/jacob/com/Variant.java b/src/com/jacob/com/Variant.java index 4d4836d..e9b1ed9 100644 --- a/src/com/jacob/com/Variant.java +++ b/src/com/jacob/com/Variant.java @@ -358,7 +358,8 @@ public class Variant extends JacobObject { public native Object clone(); /** - * attempts to return the content of this variant as a string + * Attempts to return the content of this variant as a string + * Will convert the underlying data type to a string(!) * @return String */ public native String toString(); @@ -647,8 +648,17 @@ public class Variant extends JacobObject { throw new NotImplementedException("Not implemented"); } + /** + * Convertes variant to the passed in type by converting the underlying + * windows variant structure + * @param in the desired resulting type + */ public native void changeType(short in); + /** + * cover for changeType(short) + * @param in type to convert this variant too + */ public void changeType(int in) { changeType((short) in); } @@ -784,7 +794,7 @@ public class Variant extends JacobObject { public native short getvt(); /** - * attempts tor return the contents of this Variant as a short + * attempts to return the contents of this Variant as a short * (after possible conversion) * @return short */