📄 variant.java
字号:
// verify we aren't released yet
getvt();
putVariantByte(in);
};
/**
* @deprecated superseded by SafeArray
* @param in
* doesn't matter because this method does nothing
* @throws com.jacob.com.NotImplementedException
*/
@Deprecated
public void putByteArray(Object in) {
throw new NotImplementedException("Not implemented");
}
/**
* pushes a byte into the variant by ref and sets the type
*
* @param in
*/
public void putByteRef(byte in) {
// verify we aren't released yet
getvt();
putVariantByteRef(in);
}
/**
* @param in
* the object that would be wrapped by the Variant if this method
* was implemented
* @deprecated superseded by SafeArray
* @throws com.jacob.com.NotImplementedException
*/
@Deprecated
public void putCharArray(Object in) {
throw new NotImplementedException("Not implemented");
}
/**
* Puts a value in as a currency and sets the variant type. MS Currency
* objects are 64 bit fixed point numbers with 15 digits to the left and 4
* to the right of the decimal place.
*
* @param in
* the long that will be put into the 64 bit currency object.
*/
public void putCurrency(Currency in) {
// verify we aren't released yet
getvt();
putVariantCurrency(in.longValue());
}
/**
* Pushes a long into the variant as currency and sets the type. MS Currency
* objects are 64 bit fixed point numbers with 15 digits to the left and 4
* to the right of the decimal place.
*
* @param in
* the long that will be put into the 64 bit currency object
*/
public void putCurrencyRef(Currency in) {
// verify we aren't released yet
getvt();
putVariantCurrencyRef(in.longValue());
}
/**
* converts a java date to a windows time and calls putDate(double) SF
* 959382
*
* @param inDate
* a Java date to be converted
* @throws IllegalArgumentException
* if inDate = null
*/
public void putDate(Date inDate) {
if (inDate == null) {
throw new IllegalArgumentException(
"Cannot put null in as windows date");
// do nothing
} else {
putDate(DateUtilities.convertDateToWindowsTime(inDate));
}
}
/**
* puts a windows date double into the variant and sets the type
*
* @param in
*/
public void putDate(double in) {
// verify we aren't released yet
getvt();
putVariantDate(in);
}
/**
* converts a java date to a windows time and calls putDateRef(double) SF
* 959382
*
* @param inDate
* a Java date to be converted
* @throws IllegalArgumentException
* if inDate = null
*/
public void putDateRef(Date inDate) {
if (inDate == null) {
throw new IllegalArgumentException(
"Cannot put null in as windows date");
// do nothing
} else {
putDateRef(DateUtilities.convertDateToWindowsTime(inDate));
}
}
/**
* set the content of this variant to a date (VT_DATE|VT_BYREF)
*
* @param in
*/
public void putDateRef(double in) {
// verify we aren't released
getvt();
putVariantDateRef(in);
}
/**
* This actual does all the validating and massaging of the BigDecimalValues
* when converting them to MS Decimal types
*
* @param in
* number to be made into VT_DECIMAL
* @param byRef
* store by reference or not
* @param roundingBehavior
* one of the BigDecimal ROUND_xxx methods. Any method other than
* ROUND_UNECESSARY means that the value will be rounded to fit
*/
private void putDecimal(BigDecimal in, boolean byRef) {
// verify we aren't released
getvt();
// first validate the min and max
VariantUtilities.validateDecimalMinMax(in);
BigInteger allWordBigInt;
allWordBigInt = in.unscaledValue();
// Assume any required rounding has been done.
VariantUtilities.validateDecimalScaleAndBits(in);
// finally we can do what we actually came here to do
int sign = in.signum();
// VT_DECIMAL always has positive value with just the sign
// flipped
if (in.signum() < 0) {
in = in.negate();
}
// ugh, reusing allWordBigInt but now should always be positive
// and any round is applied
allWordBigInt = in.unscaledValue();
byte scale = (byte) in.scale();
int lowWord = allWordBigInt.intValue();
BigInteger middleWordBigInt = allWordBigInt.shiftRight(32);
int middleWord = middleWordBigInt.intValue();
BigInteger highWordBigInt = allWordBigInt.shiftRight(64);
int highWord = highWordBigInt.intValue();
if (byRef) {
putVariantDecRef(sign, scale, lowWord, middleWord, highWord);
} else {
putVariantDec(sign, scale, lowWord, middleWord, highWord);
}
}
/**
* EXPERIMENTAL 1.14 feature to support rounded decimals.
* <p>
* Set the value of this variant and set the type. This may throw exceptions
* more often than the caller expects because most callers don't manage the
* scale of their BigDecimal objects.
* <p>
* This default set method throws exceptions if precision or size is out of
* bounds
* <p>
* There are 12 bytes available for the integer number.
* <p>
* There is 1 byte for the scale.
*
* @param in
* the BigDecimal that will be converted to VT_DECIMAL
* @throws IllegalArgumentException
* if the scale is > 28, the maximum for VT_DECIMAL or if there
* are more than 12 bytes worth the digits
*/
public void putDecimal(BigDecimal in) {
putDecimal(in, false);
}
/**
* Set the value of this variant and set the type. This may throw exceptions
* more often than the caller expects because most callers don't manage the
* scale of their BigDecimal objects.
* <p>
* This default set method throws exceptions if precision or size is out of
* bounds
* <p>
* There are 12 bytes available for the integer number.
* <p>
* There is 1 byte for the scale.
*
* @param in
* the BigDecimal that will be converted to VT_DECIMAL
* @throws IllegalArgumentException
* if the scale is > 28, the maximum for VT_DECIMAL or if there
* are more than 12 bytes worth the digits
*/
public void putDecimalRef(BigDecimal in) {
putDecimal(in, true);
}
/**
* This acts a cover for putVariant Dispatch.
*
* @param in
* the Dispatch we're putting down in the COM variant space.
*/
public void putDispatch(Dispatch in) {
putVariantDispatch(in);
}
/**
* Dispatch and dispatchRef are treated the same This is a cover for
* putVariantDispatch(). putDispatch and putDispatchRef are treated the same
* because no one has written the COM code for putDispatchRef.
*
* @param in
* the Dispatch we're putting down in the COM variant space.
*/
public void putDispatchRef(Dispatch in) {
putVariantDispatch(in);
}
/**
* wraps this Variant around the passed in double.
*
* @param in
*/
public void putDouble(double in) {
// verify we aren't released yet
getvt();
putVariantDouble(in);
}
/**
* set the content of this variant to a double (VT_R8|VT_BYREF)
*
* @param in
*/
public void putDoubleRef(double in) {
// verify we aren't released
getvt();
putVariantDoubleRef(in);
}
/**
* sets the type to VariantEmpty
*
*/
public void putEmpty() {
// verify we aren't released yet
getvt();
putVariantEmpty();
}
/**
* puts an error code (I think) into the variant and sets the type
*
* @param in
*/
public void putError(int in) {
// verify we aren't released yet
getvt();
putVariantError(in);
}
/**
* pushes an error code into the variant by ref and sets the type
*
* @param in
*/
public void putErrorRef(int in) {
// verify we aren't released yet
getvt();
putVariantErrorRef(in);
}
/**
* fills the Variant with a float and sets the type to float
*
* @param in
*/
public void putFloat(float in) {
// verify we haven't been released yet
getvt();
putVariantFloat(in);
}
/**
* pushes a float into the variant and sets the type
*
* @param in
*/
public void putFloatRef(float in) {
// verify we aren't released yet
getvt();
putVariantFloatRef(in);
}
/**
* set the value of this variant and set the type
*
* @param in
*/
public void putInt(int in) {
// verify we aren't released yet
getvt();
putVariantInt(in);
}
/**
* set the content of this variant to an int (VT_I4|VT_BYREF)
*
* @param in
*/
public void putIntRef(int in) {
// verify we aren't released
getvt();
putVariantIntRef(in);
}
/**
* Puts a 64 bit Java Long into a 64 bit Variant Long. Only works on x64
* systems otherwise throws an error. 64 bit long support added 1.14
*
* @param in
* the long that will be put into the 64 bit Long object.
*/
public void putLong(long in) {
// verify we aren't released yet
getvt();
putVariantLong(in);
}
/**
* Puts a 64 bit Java Long into a 64 bit Variant Long. Only works on x64
* systems otherwise throws an error. 64 bit long support added 1.14
*
* @param in
* the long that will be put into the 64 bit Long object.
*/
public void putLongRef(long in) {
// verify we aren't released yet
getvt();
putVariantLongRef(in);
}
/**
* sets the type to VT_ERROR and the error message to DISP_E_PARAMNOTFOIUND
*/
public void putNoParam() {
// verify we aren't released yet
getvt();
putVariantNoParam();
}
/**
* Sets the type to VariantDispatch and sets the value to null Equivalent to
* VB's nothing
*/
public void putNothing() {
// verify we aren't released yet
getvt();
putVariantNothing();
}
/**
* Set this Variant's type to VT_NULL (the VB equivalent of NULL)
*/
public void putNull() {
// verify we aren't released yet
getvt();
putVariantNull();
}
/**
* Puts an object into the Variant -- converts to Dispatch. Acts as a cover
* for putVariantDispatch(); This primarily exists to support jacobgen. This
* should be deprecated.
*
* @param in
* the object we are putting into the Variant, assumes a
* @see Variant#putDispatch(Dispatch)
* @deprecated should use putDispatch()
*/
@Deprecated
public void putObject(Object in) {
// this should verify in instanceof Dispatch
putVariantDispatch(in);
}
/**
* Just a cover for putObject(). We shouldn't accept any old random object.
* This has been left in to support jacobgen. This should be deprecated.
*
* @param in
* @deprecated
*/
@Deprecated
public void putObjectRef(Object in) {
putObject(in);
}
/**
* have no idea...
*
* @param in
*/
public void putSafeArray(SafeArray in) {
// verify we haven't been released yet
getvt();
putVariantSafeArray(in);
}
/**
* have no idea...
*
* @param in
*/
public void putSafeArrayRef(SafeArray in) {
// verify we haven't been released yet
getvt();
putVariantSafeArrayRef(in);
}
/**
* set the content of this variant to a short (VT_I2)
*
* @param in
*/
public void putShort(short in) {
// verify we aren't released
getvt();
putVariantShort(in);
}
/**
* set the content of this variant to a short (VT_I2|VT_BYREF)
*
* @param in
*/
public void putShortRef(short in) {
// verify we aren't released
getvt();
putVariantShortRef(in);
}
/**
* put a string into the variant and set its type
*
* @param in
*/
public void putString(String in) {
// verify we aren't released yet
getvt();
putVariantString(in);
}
/**
* set the content of this variant to a string (VT_BSTR|VT_BYREF)
*
* @param in
*/
public void putStringRef(String in) {
// verify we aren't released
getvt();
putVariantStringRef(in);
}
/**
* Puts a variant into this variant making it type VT_VARIANT. Added 1.12
* pre 6
*
* @param objectToBeWrapped
* A object that is to be referenced by this variant. If
* objectToBeWrapped is already of type Variant, then it is used.
* If objectToBeWrapped is not Variant then
* <code>new Variant(objectToBeWrapped)</code> is called and
* the result is passed into the com layer
* @throws IllegalArgumentException
* if inVariant = null or if inVariant is a Varint
*/
public void putVariant(Object objectToBeWrapped) {
if (objectToBeWrapped == null) {
throw new IllegalArgumentException(
"Cannot put null in as a variant");
} else if (objectToBeWrapped instanceof Variant) {
throw new IllegalArgumentException(
"Cannot putVariant() only accepts non jacob objects.");
} else {
Variant inVariant = new Variant(objectToBeWrapped);
putVariantVariant(inVariant);
// This could be done in Variant.cpp
if (JacobObject.isDebugEnabled()) {
JacobObject
.debug("Zeroing out enclosed Variant's ref to windows memory");
}
inVariant.m_pVariant = 0;
}
}
/**
* @deprecated superseded by SafeArray
* @param in
* doesn't matter because this method does nothing
* @throws com.jacob.com.NotImplementedException
*/
@Deprecated
public void putVariantArray(Variant[] in) {
throw new NotImplementedException("Not implemented");
}
/**
* @param in
* the thing that would be come an array if this method was
* implemented
* @deprecated superseded by SafeArray
* @throws com.jacob.com.NotImplementedException
*/
@Deprecated
public void putVariantArrayRef(Variant[] in) {
throw new NotImplementedException("Not implemented");
}
/**
* puts a boolean into the variant and sets it's type
*
* @param in
* the new value
*/
private native void putVariantBoolean(boolean in);
/**
* puts a boolean into the variant and sets it's type
*
* @param in
* the new value
*/
private native void putVariantBooleanRef(boolean in);
/**
* puts a byte into the variant and sets it's type
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -