au.com.swz.swttocom.swt.types
Class TypeUtils

java.lang.Object
  extended by au.com.swz.swttocom.swt.types.TypeUtils

public final class TypeUtils
extends java.lang.Object

Utility class for type conversions

Author:
Mark Richter

Constructor Summary
TypeUtils()
           
 
Method Summary
static org.eclipse.swt.ole.win32.Variant convertFromBigDecimal(java.math.BigDecimal db)
          Converts a BigDecimal to a Variant.
static org.eclipse.swt.ole.win32.Variant convertFromDate(java.util.Date date)
          Converts a java.util.Date object into a Variant containing a VT_DATE type.
static double convertFromDateToDouble(java.util.Date date)
          Converts a java.util.Date object into a COM compliant double.
static org.eclipse.swt.ole.win32.Variant convertFromFontData(org.eclipse.swt.graphics.FontData fontData)
          Converts a SWT FontData object to a Variant that contains a IFontDisp automation object.
static org.eclipse.swt.ole.win32.Variant convertFromHRESULT(HRESULT hresult)
          Converts a HRESULT into a Variant.
static org.eclipse.swt.ole.win32.Variant convertFromIPictureDisp(IPictureDisp picture)
          Converts a IPictureDisp object to a Variant that contains a IPictureDisp automation object.
static org.eclipse.swt.ole.win32.Variant convertFromOleColor(OleColor oleColor)
          Converts a OleColor into a Variant containing an integer representation of the OLE_COLOR.
static java.math.BigDecimal convertToBigDecimal(org.eclipse.swt.ole.win32.Variant v)
          Converts a Variant to a BigDecimal.
static java.util.Date convertToDate(double date)
          Converts a COM double date type to a java.util.Date.
static java.util.Date convertToDate(org.eclipse.swt.ole.win32.Variant v)
          Converts a Variant VT_DATE type to a java.util.Date.
static org.eclipse.swt.graphics.FontData convertToFontData(org.eclipse.swt.ole.win32.Variant v)
           
static HRESULT convertToHRESULT(org.eclipse.swt.ole.win32.Variant v)
          Converts a Variant to a HRESULT.
static IPictureDisp convertToIPictureDisp(org.eclipse.swt.ole.win32.Variant v)
          Converts a variant to a IPictureDisp interface.
static OleColor convertToOleColor(org.eclipse.swt.ole.win32.Variant v)
          Converts an OLE_COLOR contained within a Variant to an OleColor java object.
static org.eclipse.swt.internal.ole.win32.GUID IIDFromString(java.lang.String lpsz)
          This method was copied from org.eclipse.swt.internal.ole.win32.COM to make it public.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeUtils

public TypeUtils()
Method Detail

convertToOleColor

public static OleColor convertToOleColor(org.eclipse.swt.ole.win32.Variant v)
Converts an OLE_COLOR contained within a Variant to an OleColor java object.

Parameters:
v - The variant that is to be convert to an OleColor.

convertToFontData

public static org.eclipse.swt.graphics.FontData convertToFontData(org.eclipse.swt.ole.win32.Variant v)

convertToIPictureDisp

public static IPictureDisp convertToIPictureDisp(org.eclipse.swt.ole.win32.Variant v)
Converts a variant to a IPictureDisp interface.

Parameters:
v - the variant to be converted
Returns:
A reference to the IPictureDisp interface.

convertToDate

public static java.util.Date convertToDate(org.eclipse.swt.ole.win32.Variant v)
Converts a Variant VT_DATE type to a java.util.Date. In Java 0 is Jan 1 1970 whilst in COM 0 is Dec 30 1899. This makes the difference of 25569 days (accounting for 17 leap years).

Parameters:
v - the VT_DATE variant to convert to a java.util.Date
Returns:
the converted java.util.Date

convertToDate

public static java.util.Date convertToDate(double date)
Converts a COM double date type to a java.util.Date. In Java 0 is Jan 1 1970 whilst in COM 0 is Dec 30 1899. This makes the difference of 25569 days (accounting for 17 leap years).

Parameters:
date - the COM double date to convert to a java.util.Date
Returns:
the converted java.util.Date

convertToBigDecimal

public static java.math.BigDecimal convertToBigDecimal(org.eclipse.swt.ole.win32.Variant v)
Converts a Variant to a BigDecimal. This is done by using the SWT Variants built in conversion via VariantChangeType. We convert the decimal to a String and then use the java.math.BigDecimal to convert the String to a BigDecimal.

Parameters:
v - the VT_DECIMAL Variant to be converted to a BigDecimal.
Returns:
the converted BigDecimal

convertToHRESULT

public static HRESULT convertToHRESULT(org.eclipse.swt.ole.win32.Variant v)
Converts a Variant to a HRESULT. A HRESULT is simply a 32 bit unsigned integer that has a special bit interpretation. See the HRESULT class for more details.

Parameters:
v - the VT_INT variant to be converted to a HRESULT.
Returns:
the converted HRESULT

convertFromOleColor

public static org.eclipse.swt.ole.win32.Variant convertFromOleColor(OleColor oleColor)
Converts a OleColor into a Variant containing an integer representation of the OLE_COLOR.

Parameters:
oleColor - the OleColor object to convert.
Returns:
a Variant that contains the OLE_COLOR.

convertFromFontData

public static org.eclipse.swt.ole.win32.Variant convertFromFontData(org.eclipse.swt.graphics.FontData fontData)
Converts a SWT FontData object to a Variant that contains a IFontDisp automation object.

Parameters:
fontData - the SWT FontData object to convert.
Returns:
a Variant that contains IFontDisp automation object.

convertFromIPictureDisp

public static org.eclipse.swt.ole.win32.Variant convertFromIPictureDisp(IPictureDisp picture)
Converts a IPictureDisp object to a Variant that contains a IPictureDisp automation object.

Parameters:
picture - the SWT FontData object to convert.
Returns:
a Variant that contains IFontDisp automation object.

convertFromDate

public static org.eclipse.swt.ole.win32.Variant convertFromDate(java.util.Date date)
Converts a java.util.Date object into a Variant containing a VT_DATE type.

Parameters:
date - the java.util.Date object to convert.
Returns:
a Variant that contains the VT_DATE.

convertFromDateToDouble

public static double convertFromDateToDouble(java.util.Date date)
Converts a java.util.Date object into a COM compliant double.

Parameters:
date - the java.util.Date object to convert.
Returns:
a double that contains the encoded date.

convertFromHRESULT

public static org.eclipse.swt.ole.win32.Variant convertFromHRESULT(HRESULT hresult)
Converts a HRESULT into a Variant. A HRESULT is a 32 bit integer so this method returns a VT_INT Variant containing the HRESULT.

Parameters:
hresult - the HRESULT to be converted.
Returns:
a Variant that contains the HRESULT integer.

convertFromBigDecimal

public static org.eclipse.swt.ole.win32.Variant convertFromBigDecimal(java.math.BigDecimal db)
Converts a BigDecimal to a Variant. This is done by using the SWT Variants built in conversion via VariantChangeType. We convert the BigDecimal to a String and then rely on the remote component to use the Variants builtin conversion to convert the String to a VT_DECIMAL.

Parameters:
db - the BigDecimal to be converted to a Variant
Returns:
the converted Variant

IIDFromString

public static org.eclipse.swt.internal.ole.win32.GUID IIDFromString(java.lang.String lpsz)
This method was copied from org.eclipse.swt.internal.ole.win32.COM to make it public. This method creates a GUID from a string representation of that IID.

Parameters:
lpsz - the string IID representation.
Returns:
the GUID.