Top Description Fields Constructors Methods
com.sun.star.uno

public Class AnyConverter

extends Object
Class Inheritance

This class provides static methods which aim at exploring the contents of an Any and extracting its value.

All public methods take an Object argument that either is the immediate object, such as Boolean, Type, interface implementation, or an Any that contains an object.

The methods which extract the value do a widening conversion. See the method comments for the respective conversions.

Field Summary

Modifier and TypeField and Description
private static final Type

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static boolean
containsType(com.sun.star.uno.TypeClass what, Object object)

Examines the argument object if is correspond to the type in argument what.

private static Object
convertSimple(com.sun.star.uno.TypeClass destTClass, Type destType, Object object_)

public static Type

Returns:

type object.
getType
(Object
any object.
object
)

Determines the type of an Any object.

public static boolean

Returns:

true when the any contains an object which implements interfaces, false otherwise.
isArray
(Object
the object to check.
object
)

Checks if the any contains UNO idl sequence value (meaning a java array containing elements which are values of UNO idl types).

public static boolean

Returns:

true when the any contains a boolean, false otherwise.
isBoolean
(Object
the object to check.
object
)

Checks if the any contains a value of the idl type boolean.

public static boolean

Returns:

true when the any contains a byte, false otherwise.
isByte
(Object
the object to check.
object
)

Checks if the any contains a value of the idl type byte.

public static boolean

Returns:

true when the any contains a char, false otherwise.
isChar
(Object
the object to check.
object
)

Checks if the any contains a value of the idl type char.

public static boolean

Returns:

true when the any contains a double, false otherwise.
isDouble
(Object
the object to check.
object
)

Checks if the any contains a value of the idl type double.

public static boolean

Returns:

true if the any contains an enum, false otherwise.
isEnum
(Object
the object to check.
object
)

Checks if the any contains a value of the idl type enum.

public static boolean

Returns:

true when the any contains a float, false otherwise.
isFloat
(Object
the object to check.
object
)

Checks if the any contains a value of the idl type float.

public static boolean

Returns:

true when the any contains a int, false otherwise.
isInt
(Object
the object to check.
object
)

Checks if the any contains a value of the idl type long (which maps to a java-int).

public static boolean

Returns:

true when the any contains a long, false otherwise.
isLong
(Object
the object to check.
object
)

Checks if the any contains a value of the idl type hyper (which maps to a java-long).

public static boolean

Returns:

true if the any contains an object.
isObject
(Object
the object to check.
object
)

Checks if the any contains an interface, struct, exception, sequence or enum.

public static boolean

Returns:

true when the any contains a short, false otherwise.
isShort
(Object
the object to check.
object
)

Checks if the any contains a value of the idl type short.

public static boolean

Returns:

true when the any contains a string, false otherwise.
isString
(Object
the object to check.
object
)

Checks if the any contains a value of the idl type string.

public static boolean

Returns:

true when the any contains a type, false otherwise.
isType
(Object
the object to check.
object
)

Checks if the any contains a value of the idl type type.

public static boolean

Returns:

true when the any is void, false otherwise.
isVoid
(Object
the object to check.
object
)

Checks if the any contains the idl type void.

public static Object

Returns:

the array contained within the object.
toArray
(Object
the object to convert.
object
)

Converts an array or an any containing an array into an array.

public static boolean

Returns:

the boolean contained within the object
toBoolean
(Object
the object to convert.
object
)

Converts a Boolean object or an Any object containing a Boolean object into a simple boolean.

public static byte

Returns:

the boolean contained within the object.
toByte
(Object
the object to convert.
object
)

Converts a Byte object or an Any object containing a Byte object into a simple byte.

public static char

Returns:

the char contained within the object.
toChar
(Object
the object to convert.
object
)

Converts a Char object or an Any object containing a Char object into a simple char.

public static double

Returns:

the double contained within the object.
toDouble
(Object
the object to convert.
object
)

Converts a number object into a simple double and allows widening conversions.

public static float

Returns:

the float contained within the object.
toFloat
(Object
the object to convert.
object
)

Converts a number object into a simple float and allows widening conversions.

public static int

Returns:

the int contained within the object.
toInt
(Object
the object to convert.
object
)

Converts a number object into a simple int and allows widening conversions.

public static long

Returns:

the long contained within the object.
toLong
(Object
the object to convert.
object
)

Converts a number object into a simple long and allows widening conversions.

public static Object

Returns:

destination object.
toObject
(Type
type of the returned value.
type
,
Object
the object that is to be converted.
object
)

Converts a UNO object (struct, exception, sequence, enum or interface) or an Any containing these types into a UNO object of a specified destination type.

public static Object

Returns:

destination object.
toObject
(Class<?>
class of the returned value.
clazz
,
Object
the object that is to be converted.
object
)

Converts a UNO object (struct, exception, sequence, enum or interface) or an Any containing these types into a UNO object of a specified destination type.

public static short

Returns:

the short contained within the object.
toShort
(Object
the object to convert.
object
)

Converts a number object into a simple short and allows widening conversions.

public static String

Returns:

the string contained within the object.
toString
(Object
the object to convert.
object
)

Converts a string or an any containing a string into a string.

public static Type

Returns:

the type contained within the object.
toType
(Object
the object to convert.
object
)

Converts a Type or an any containing a Type into a Type.

public static int

Returns:

an (unsigned) int.
toUnsignedInt
(Object
the object to convert.
object
)

Converts a number object into an idl unsigned long and allows widening conversions.

public static long

Returns:

an (unsigned) long.
toUnsignedLong
(Object
the object to convert.
object
)

Converts a number object into an idl unsigned hyper and allows widening conversions.

public static short

Returns:

an (unsigned) short.
toUnsignedShort
(Object
the object to convert.
object
)

Converts a number object into an idl unsigned short and allows widening conversions.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

m_XInterface_typeback to summary
private static final Type m_XInterface_type

Constructor Detail

AnyConverterback to summary
public AnyConverter()

Method Detail

containsTypeback to summary
private static boolean containsType(com.sun.star.uno.TypeClass what, Object object)

Examines the argument object if is correspond to the type in argument what.

object is either matched directly against the type or if it is an any then the contained object is matched against the type.

convertSimpleback to summary
private static Object convertSimple(com.sun.star.uno.TypeClass destTClass, Type destType, Object object_) throws com.sun.star.lang.IllegalArgumentException
getTypeback to summary
public static Type getType(Object object)

Determines the type of an Any object.

Parameters
object:Object

any object.

Returns:Type

type object.

isArrayback to summary
public static boolean isArray(Object object)

Checks if the any contains UNO idl sequence value (meaning a java array containing elements which are values of UNO idl types).

Parameters
object:Object

the object to check.

Returns:boolean

true when the any contains an object which implements interfaces, false otherwise.

isBooleanback to summary
public static boolean isBoolean(Object object)

Checks if the any contains a value of the idl type boolean.

Parameters
object:Object

the object to check.

Returns:boolean

true when the any contains a boolean, false otherwise.

isByteback to summary
public static boolean isByte(Object object)

Checks if the any contains a value of the idl type byte.

Parameters
object:Object

the object to check.

Returns:boolean

true when the any contains a byte, false otherwise.

isCharback to summary
public static boolean isChar(Object object)

Checks if the any contains a value of the idl type char.

Parameters
object:Object

the object to check.

Returns:boolean

true when the any contains a char, false otherwise.

isDoubleback to summary
public static boolean isDouble(Object object)

Checks if the any contains a value of the idl type double.

Parameters
object:Object

the object to check.

Returns:boolean

true when the any contains a double, false otherwise.

isEnumback to summary
public static boolean isEnum(Object object)

Checks if the any contains a value of the idl type enum.

Parameters
object:Object

the object to check.

Returns:boolean

true if the any contains an enum, false otherwise.

isFloatback to summary
public static boolean isFloat(Object object)

Checks if the any contains a value of the idl type float.

Parameters
object:Object

the object to check.

Returns:boolean

true when the any contains a float, false otherwise.

isIntback to summary
public static boolean isInt(Object object)

Checks if the any contains a value of the idl type long (which maps to a java-int).

Parameters
object:Object

the object to check.

Returns:boolean

true when the any contains a int, false otherwise.

isLongback to summary
public static boolean isLong(Object object)

Checks if the any contains a value of the idl type hyper (which maps to a java-long).

Parameters
object:Object

the object to check.

Returns:boolean

true when the any contains a long, false otherwise.

isObjectback to summary
public static boolean isObject(Object object)

Checks if the any contains an interface, struct, exception, sequence or enum.

If object is an any with an interface type, then true is also returned if the any contains a null reference. This is because interfaces are allowed to have a null value contrary to other UNO types.

Parameters
object:Object

the object to check.

Returns:boolean

true if the any contains an object.

isShortback to summary
public static boolean isShort(Object object)

Checks if the any contains a value of the idl type short.

Parameters
object:Object

the object to check.

Returns:boolean

true when the any contains a short, false otherwise.

isStringback to summary
public static boolean isString(Object object)

Checks if the any contains a value of the idl type string.

Parameters
object:Object

the object to check.

Returns:boolean

true when the any contains a string, false otherwise.

isTypeback to summary
public static boolean isType(Object object)

Checks if the any contains a value of the idl type type.

Parameters
object:Object

the object to check.

Returns:boolean

true when the any contains a type, false otherwise.

isVoidback to summary
public static boolean isVoid(Object object)

Checks if the any contains the idl type void.

Parameters
object:Object

the object to check.

Returns:boolean

true when the any is void, false otherwise.

toArrayback to summary
public static Object toArray(Object object) throws com.sun.star.lang.IllegalArgumentException

Converts an array or an any containing an array into an array.

Parameters
object:Object

the object to convert.

Returns:Object

the array contained within the object.

Exceptions
IllegalArgumentException:
in case no array is contained within object.
toBooleanback to summary
public static boolean toBoolean(Object object) throws com.sun.star.lang.IllegalArgumentException

Converts a Boolean object or an Any object containing a Boolean object into a simple boolean.

Parameters
object:Object

the object to convert.

Returns:boolean

the boolean contained within the object

Exceptions
IllegalArgumentException:
in case no boolean is contained within object
See Also
isBoolean
toByteback to summary
public static byte toByte(Object object) throws com.sun.star.lang.IllegalArgumentException

Converts a Byte object or an Any object containing a Byte object into a simple byte.

Parameters
object:Object

the object to convert.

Returns:byte

the boolean contained within the object.

Exceptions
IllegalArgumentException:
in case no byte is contained within object.
See Also
isBoolean
toCharback to summary
public static char toChar(Object object) throws com.sun.star.lang.IllegalArgumentException

Converts a Char object or an Any object containing a Char object into a simple char.

Parameters
object:Object

the object to convert.

Returns:char

the char contained within the object.

Exceptions
IllegalArgumentException:
in case no char is contained within object.
See Also
isChar
toDoubleback to summary
public static double toDouble(Object object) throws com.sun.star.lang.IllegalArgumentException

Converts a number object into a simple double and allows widening conversions.

Allowed argument types are Byte, Short, Int, Float, Double or Any containing these types.

Parameters
object:Object

the object to convert.

Returns:double

the double contained within the object.

Exceptions
IllegalArgumentException:
in case no byte, short, int, float or double is contained within object.
toFloatback to summary
public static float toFloat(Object object) throws com.sun.star.lang.IllegalArgumentException

Converts a number object into a simple float and allows widening conversions.

Allowed argument types are Byte, Short, Float or Any containing these types.

Parameters
object:Object

the object to convert.

Returns:float

the float contained within the object.

Exceptions
IllegalArgumentException:
in case no byte, short or float is contained within object.
toIntback to summary
public static int toInt(Object object) throws com.sun.star.lang.IllegalArgumentException

Converts a number object into a simple int and allows widening conversions.

Allowed argument types are Byte, Short, Integer or Any containing these types.

Parameters
object:Object

the object to convert.

Returns:int

the int contained within the object.

Exceptions
IllegalArgumentException:
in case no short, byte or int is contained within object.
toLongback to summary
public static long toLong(Object object) throws com.sun.star.lang.IllegalArgumentException

Converts a number object into a simple long and allows widening conversions.

Allowed argument types are Byte, Short, Integer, Long or Any containing these types.

Parameters
object:Object

the object to convert.

Returns:long

the long contained within the object.

Exceptions
IllegalArgumentException:
in case no short, byte, int or long is contained within object.
toObjectback to summary
public static Object toObject(Type type, Object object) throws com.sun.star.lang.IllegalArgumentException

Converts a UNO object (struct, exception, sequence, enum or interface) or an Any containing these types into a UNO object of a specified destination type.

For interfaces, the argument object is queried for the interface specified by the type argument.

That query (UnoRuntime.queryInterface) might return null, if the interface is not implemented or a null-ref or a VOID any is given.

Parameters
type:Type

type of the returned value.

object:Object

the object that is to be converted.

Returns:Object

destination object.

Exceptions
IllegalArgumentException:
in case conversion is not possible.
toObjectback to summary
public static Object toObject(Class<?> clazz, Object object) throws com.sun.star.lang.IllegalArgumentException

Converts a UNO object (struct, exception, sequence, enum or interface) or an Any containing these types into a UNO object of a specified destination type.

For interfaces, the argument object is queried for the interface specified by the type argument. That query (UnoRuntime.queryInterface) might return null, if the interface is not implemented or a null-ref or a VOID any is given.

Parameters
clazz:Class<?>

class of the returned value.

object:Object

the object that is to be converted.

Returns:Object

destination object.

Exceptions
IllegalArgumentException:
in case conversion is not possible.
toShortback to summary
public static short toShort(Object object) throws com.sun.star.lang.IllegalArgumentException

Converts a number object into a simple short and allows widening conversions.

Allowed argument types are Byte, Short or Any containing these types.

Parameters
object:Object

the object to convert.

Returns:short

the short contained within the object.

Exceptions
IllegalArgumentException:
in case no short or byte is contained within object.
toStringback to summary
public static String toString(Object object) throws com.sun.star.lang.IllegalArgumentException

Converts a string or an any containing a string into a string.

Parameters
object:Object

the object to convert.

Returns:String

the string contained within the object.

Exceptions
IllegalArgumentException:
in case no string is contained within object.
toTypeback to summary
public static Type toType(Object object) throws com.sun.star.lang.IllegalArgumentException

Converts a Type or an any containing a Type into a Type.

Parameters
object:Object

the object to convert.

Returns:Type

the type contained within the object.

Exceptions
IllegalArgumentException:
in case no type is contained within object.
toUnsignedIntback to summary
public static int toUnsignedInt(Object object) throws com.sun.star.lang.IllegalArgumentException

Converts a number object into an idl unsigned long and allows widening conversions.

Allowed argument types are Anies containing idl unsigned short or unsigned long values.

Parameters
object:Object

the object to convert.

Returns:int

an (unsigned) int.

Exceptions
IllegalArgumentException:
in case no idl unsigned short nor unsigned long is contained within Any.
toUnsignedLongback to summary
public static long toUnsignedLong(Object object) throws com.sun.star.lang.IllegalArgumentException

Converts a number object into an idl unsigned hyper and allows widening conversions.

Allowed argument types are Anies containing idl unsigned short, unsigned long or unsigned hyper values.

Parameters
object:Object

the object to convert.

Returns:long

an (unsigned) long.

Exceptions
IllegalArgumentException:
in case no idl unsigned short, nor unsigned long nor unsigned hyper is contained within object.
toUnsignedShortback to summary
public static short toUnsignedShort(Object object) throws com.sun.star.lang.IllegalArgumentException

Converts a number object into an idl unsigned short and allows widening conversions.

Allowed argument types are Anies containing idl unsigned short values.

Parameters
object:Object

the object to convert.

Returns:short

an (unsigned) short.

Exceptions
IllegalArgumentException:
in case no idl unsigned short is contained within Any.