Language

The Free and Open Productivity Suite
Released: Apache OpenOffice 4.1.15
UNO Java Runtime

com.sun.star.uno
Class AnyConverter

java.lang.Object
  |
  +--com.sun.star.uno.AnyConverter

public class AnyConverter
extends java.lang.Object

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.


Constructor Summary
AnyConverter()
           
 
Method Summary
static boolean isArray(java.lang.Object object)
          checks if the any contains UNO idl sequence value ( meaning a java array containing elements which are values of UNO idl types).
static boolean isBoolean(java.lang.Object object)
          checks if the any contains a value of the idl type boolean.
static boolean isByte(java.lang.Object object)
          checks if the any contains a value of the idl type byte.
static boolean isChar(java.lang.Object object)
          checks if the any contains a value of the idl type char.
static boolean isDouble(java.lang.Object object)
          checks if the any contains a value of the idl type double.
static boolean isFloat(java.lang.Object object)
          checks if the any contains a value of the idl type float.
static boolean isInt(java.lang.Object object)
          checks if the any contains a value of the idl type long (which maps to a java-int).
static boolean isLong(java.lang.Object object)
          checks if the any contains a value of the idl type hyper (which maps to a java-long).
static boolean isObject(java.lang.Object object)
          checks if the any contains a value which implements interfaces.
static boolean isShort(java.lang.Object object)
          checks if the any contains a value of the idl type short.
static boolean isString(java.lang.Object object)
          checks if the any contains a value of the idl type string.
static boolean isType(java.lang.Object object)
          checks if the any contains a value of the idl type type.
static boolean isVoid(java.lang.Object object)
          checks if the any contains the idl type void.
static java.lang.Object toArray(java.lang.Object object)
          converts an array or an any containing an array into an array.
static boolean toBoolean(java.lang.Object object)
          converts an Boolean object or an Any object containing a Boolean object into a simple boolean.
static byte toByte(java.lang.Object object)
          converts an Byte object or an Any object containing a Byte object into a simple byte.
static char toChar(java.lang.Object object)
          converts an Char object or an Any object containing a Char object into a simple char.
static double toDouble(java.lang.Object object)
          converts a number object into a simple double and allows widening conversions.
static float toFloat(java.lang.Object object)
          converts a number object into a simple float and allows widening conversions.
static int toInt(java.lang.Object object)
          converts a number object into a simple int and allows widening conversions.
static long toLong(java.lang.Object object)
          converts a number object into a simple long and allows widening conversions.
static java.lang.Object toObject(Type type, java.lang.Object object)
          converts a UNO object or an Any containing a UNO object into an UNO object of a specified type.
static short toShort(java.lang.Object object)
          converts a number object into a simple short and allows widening conversions.
static java.lang.String toString(java.lang.Object object)
          converts a string or an any containing a string into a string.
static Type toType(java.lang.Object object)
          converts a Type or an any containing a Type into a Type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnyConverter

public AnyConverter()
Method Detail

isVoid

public static boolean isVoid(java.lang.Object object)
checks if the any contains the idl type void.

Parameters:
object - the object to check
Returns:
true when the any is void, false otherwise

isChar

public static boolean isChar(java.lang.Object object)
checks if the any contains a value of the idl type char.

Parameters:
object - the object to check
Returns:
true when the any contains a char, false otherwise.

isBoolean

public static boolean isBoolean(java.lang.Object object)
checks if the any contains a value of the idl type boolean.

Parameters:
object - the object to check
Returns:
true when the any contains a boolean, false otherwise.

isByte

public static boolean isByte(java.lang.Object object)
checks if the any contains a value of the idl type byte.

Parameters:
object - the object to check
Returns:
true when the any contains a byte, false otherwise.

isShort

public static boolean isShort(java.lang.Object object)
checks if the any contains a value of the idl type short.

Parameters:
object - the object to check
Returns:
true when the any contains a short, false otherwise.

isInt

public static boolean isInt(java.lang.Object object)
checks if the any contains a value of the idl type long (which maps to a java-int).

Parameters:
object - the object to check
Returns:
true when the any contains a int, false otherwise.

isLong

public static boolean isLong(java.lang.Object object)
checks if the any contains a value of the idl type hyper (which maps to a java-long).

Parameters:
object - the object to check
Returns:
true when the any contains a long, false otherwise.

isFloat

public static boolean isFloat(java.lang.Object object)
checks if the any contains a value of the idl type float.

Parameters:
object - the object to check
Returns:
true when the any contains a float, false otherwise.

isDouble

public static boolean isDouble(java.lang.Object object)
checks if the any contains a value of the idl type double.

Parameters:
object - the object to check
Returns:
true when the any contains a double, false otherwise.

isString

public static boolean isString(java.lang.Object object)
checks if the any contains a value of the idl type string.

Parameters:
object - the object to check
Returns:
true when the any contains a string, false otherwise.

isType

public static boolean isType(java.lang.Object object)
checks if the any contains a value of the idl type type.

Parameters:
object - the object to check
Returns:
true when the any contains a type, false otherwise.

isObject

public static boolean isObject(java.lang.Object object)
checks if the any contains a value which implements interfaces.

Parameters:
object - the object to check
Returns:
true when the any contains an object which implements interfaces, false otherwise.

isArray

public static boolean isArray(java.lang.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 - the object to check
Returns:
true when the any contains an object which implements interfaces, false otherwise.

toChar

public static char toChar(java.lang.Object object)
                   throws com.sun.star.lang.IllegalArgumentException
converts an Char object or an Any object containing a Char object into a simple char.

Parameters:
object - the object to convert
Returns:
the char contained within the object
Throws:
com.sun.star.lang.IllegalArgumentException - in case no char is contained within object
See Also:
isChar(java.lang.Object)

toBoolean

public static boolean toBoolean(java.lang.Object object)
                         throws com.sun.star.lang.IllegalArgumentException
converts an Boolean object or an Any object containing a Boolean object into a simple boolean.

Parameters:
object - the object to convert
Returns:
the boolean contained within the object
Throws:
com.sun.star.lang.IllegalArgumentException - in case no boolean is contained within object
See Also:
isBoolean(java.lang.Object)

toByte

public static byte toByte(java.lang.Object object)
                   throws com.sun.star.lang.IllegalArgumentException
converts an Byte object or an Any object containing a Byte object into a simple byte.

Parameters:
object - the object to convert
Returns:
the boolean contained within the object
Throws:
com.sun.star.lang.IllegalArgumentException - in case no byte is contained within object
See Also:
isBoolean(java.lang.Object)

toShort

public static short toShort(java.lang.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 - the object to convert
Returns:
the short contained within the object
Throws:
com.sun.star.lang.IllegalArgumentException - in case no short or byte is contained within object

toInt

public static int toInt(java.lang.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 - the object to convert
Returns:
the int contained within the object
Throws:
com.sun.star.lang.IllegalArgumentException - in case no short, byte or int is contained within object.

toLong

public static long toLong(java.lang.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 - the object to convert
Returns:
the long contained within the object
Throws:
com.sun.star.lang.IllegalArgumentException - in case no short, byte, int or long is contained within object.

toFloat

public static float toFloat(java.lang.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 - the object to convert
Returns:
the float contained within the object
Throws:
com.sun.star.lang.IllegalArgumentException - in case no byte, short or float is contained within object.

toDouble

public static double toDouble(java.lang.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 - the object to convert
Returns:
the double contained within the object
Throws:
com.sun.star.lang.IllegalArgumentException - in case no byte, short, int, float or double is contained within object.

toString

public static java.lang.String toString(java.lang.Object object)
                                 throws com.sun.star.lang.IllegalArgumentException
converts a string or an any containing a string into a string.

Parameters:
object - the object to convert
Returns:
the string contained within the object
Throws:
com.sun.star.lang.IllegalArgumentException - in case no string is contained within object.

toType

public static Type toType(java.lang.Object object)
                   throws com.sun.star.lang.IllegalArgumentException
converts a Type or an any containing a Type into a Type.

Parameters:
object - the object to convert
Returns:
the type contained within the object
Throws:
com.sun.star.lang.IllegalArgumentException - in case no type is contained within object.

toObject

public static java.lang.Object toObject(Type type,
                                        java.lang.Object object)
                                 throws com.sun.star.lang.IllegalArgumentException
converts a UNO object or an Any containing a UNO object into an UNO object of a specified type. The argument object is examined for implemented interfaces. If it has implemented interfaces then the method attempts to query for the interface specified by the type argument. That query (UnoRuntime.queryInterface) might return null, if the interface is not implemented.

Parameters:
type - the Type of the returned value
object - the object that is to be converted
Returns:
the object contained within the object
Throws:
com.sun.star.lang.IllegalArgumentException - in case no UNO object is contained within object.

toArray

public static java.lang.Object toArray(java.lang.Object object)
                                throws com.sun.star.lang.IllegalArgumentException
converts an array or an any containing an array into an array.

Parameters:
object - the object to convert
Returns:
the array contained within the object
Throws:
com.sun.star.lang.IllegalArgumentException - in case no array is contained within object.

UNO Java Runtime

Apache Software Foundation

Copyright & License | Privacy | Contact Us | Donate | Thanks

Apache, OpenOffice, OpenOffice.org and the seagull logo are registered trademarks of The Apache Software Foundation. The Apache feather logo is a trademark of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.