com.jacob.com

## Class VariantUtilities

- java.lang.Object
- - com.jacob.com.VariantUtilities

-     public final class VariantUtilities
      extends java.lang.Object

  A utility class used to convert between Java objects and Variants

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected static Variant[]` | `objectsToVariants(java.lang.Object[] arrayOfObjectsToBeConverted)` converts an array of objects into an array of Variants by repeatedly calling obj2Variant(Object)
    `protected static Variant` | `objectToVariant(java.lang.Object objectToBeMadeIntoVariant)` Map arguments based on msdn documentation.
    `protected static void` | `populateVariant(Variant targetVariant, java.lang.Object pValueObject, boolean fByRef)` Populates a variant object from a java object.
    `static java.math.BigDecimal` | `roundToMSDecimal(java.math.BigDecimal sourceDecimal)` Rounds the scale and bit length so that it will pass validateDecimalScaleBits().
    `protected static void` | `validateDecimalMinMax(java.math.BigDecimal in)` Does any validation that couldn't have been fixed by rounding or scale modification.
    `protected static void` | `validateDecimalScaleAndBits(java.math.BigDecimal in)` Verifies that we have a scale 0 <= x <= 28 and now more than 96 bits of data.
    `protected static java.lang.Object` | `variantToObject(Variant sourceData)` Convert a JACOB Variant value to a Java object (type conversions).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### populateVariant

          protected static void populateVariant(Variant targetVariant,
                                                java.lang.Object pValueObject,
                                                boolean fByRef)

      Populates a variant object from a java object. This method attempts to figure out the appropriate Variant type
      Parameters:
        `targetVariant` -
        `pValueObject` -
        `fByRef` -

    - #### objectToVariant

          protected static Variant objectToVariant(java.lang.Object objectToBeMadeIntoVariant)

      Map arguments based on msdn documentation. This method relies on the variant constructor except for arrays.
      Parameters:
        `objectToBeMadeIntoVariant` -
      Returns:
        Variant that represents the object

    - #### objectsToVariants

          protected static Variant[] objectsToVariants(java.lang.Object[] arrayOfObjectsToBeConverted)

      converts an array of objects into an array of Variants by repeatedly calling obj2Variant(Object)
      Parameters:
        `arrayOfObjectsToBeConverted` -
      Returns:
        Variant[]

    - #### variantToObject

          protected static java.lang.Object variantToObject(Variant sourceData)

      Convert a JACOB Variant value to a Java object (type conversions). provided in Sourceforge feature request 959381. A fix was done to handle byRef bug report 1607878.

      Unlike other toXXX() methods, it does not do a type conversion except for special data types (it shouldn't do any!)

      Converts Variant.VariantArray types to SafeArrays

      Returns:
        Corresponding Java object of the type matching the Variant type.
      Throws:
        `java.lang.IllegalStateException` - if no underlying windows data structure
        `NotImplementedException` - if unsupported conversion is requested
        `JacobException` - if the calculated result was a JacobObject usually as a result of error

    - #### validateDecimalScaleAndBits

          protected static void validateDecimalScaleAndBits(java.math.BigDecimal in)

      Verifies that we have a scale 0 <= x <= 28 and now more than 96 bits of data. The roundToMSDecimal method will attempt to adjust a BigDecimal to pass this set of tests
      Parameters:
        `in` -
      Throws:
        `java.lang.IllegalArgumentException` - if out of bounds

    - #### validateDecimalMinMax

          protected static void validateDecimalMinMax(java.math.BigDecimal in)

      Does any validation that couldn't have been fixed by rounding or scale modification.
      Parameters:
        `in` - The BigDecimal to be validated
      Throws:
        `java.lang.IllegalArgumentException` - if the number is too large or too small or null

    - #### roundToMSDecimal

          public static java.math.BigDecimal roundToMSDecimal(java.math.BigDecimal sourceDecimal)

      Rounds the scale and bit length so that it will pass validateDecimalScaleBits(). Developers should call this method if they really want MS Decimal and don't want to lose precision.

      Changing the scale on a number that can fit in an MS Decimal can change the number's representation enough that it will round to a number too large to be represented by an MS VT_DECIMAL

      Parameters:
        `sourceDecimal` -
      Returns:
        BigDecimal a new big decimal that was rounded to fit in an MS VT_DECIMAL

http://jacob-project.sourceforge.net