SF 1538011 -- document the fact that toString() convertes the underlying data type to a String type

This commit is contained in:
clay_shooter
2006-09-23 17:30:30 +00:00
parent 8e6be7ec6c
commit 3bd2d84f07
2 changed files with 17 additions and 2 deletions

View File

@@ -520,10 +520,12 @@ JNIEXPORT jstring JNICALL Java_com_jacob_com_Variant_toString
return env->NewStringUTF("null"); return env->NewStringUTF("null");
} }
HRESULT hr; HRESULT hr;
// this actually changes the type of the variant to a String!
if (FAILED(hr = VariantChangeType(v, v, 0, VT_BSTR))) { if (FAILED(hr = VariantChangeType(v, v, 0, VT_BSTR))) {
// cannot change type to a string // cannot change type to a string
return env->NewStringUTF("???"); return env->NewStringUTF("???");
} }
// create a returnable string from the converted variant
BSTR bs = V_BSTR(v); BSTR bs = V_BSTR(v);
jstring js = env->NewString(bs, SysStringLen(bs)); jstring js = env->NewString(bs, SysStringLen(bs));
return js; 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 JNIEXPORT void JNICALL Java_com_jacob_com_Variant_changeType
(JNIEnv *env, jobject _this, jshort t) (JNIEnv *env, jobject _this, jshort t)
{ {

View File

@@ -358,7 +358,8 @@ public class Variant extends JacobObject {
public native Object clone(); 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 * @return String
*/ */
public native String toString(); public native String toString();
@@ -647,8 +648,17 @@ public class Variant extends JacobObject {
throw new NotImplementedException("Not implemented"); 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); public native void changeType(short in);
/**
* cover for changeType(short)
* @param in type to convert this variant too
*/
public void changeType(int in) { public void changeType(int in) {
changeType((short) in); changeType((short) in);
} }
@@ -784,7 +794,7 @@ public class Variant extends JacobObject {
public native short getvt(); 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) * (after possible conversion)
* @return short * @return short
*/ */