public class AnyConverter extends Object
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 and Description |
---|
AnyConverter() |
Modifier and Type | Method and Description |
---|---|
static Type |
getType(Object object)
Determines the type of an any object.
|
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).
|
static boolean |
isBoolean(Object object)
Checks if the any contains a value of the idl type
boolean . |
static boolean |
isByte(Object object)
Checks if the any contains a value of the idl type
byte . |
static boolean |
isChar(Object object)
Checks if the any contains a value of the idl type
char . |
static boolean |
isDouble(Object object)
Checks if the any contains a value of the idl type
double . |
static boolean |
isEnum(Object object)
Checks if the any contains a value of the idl type
enum . |
static boolean |
isFloat(Object object)
Checks if the any contains a value of the idl type
float . |
static boolean |
isInt(Object object)
Checks if the any contains a value of the idl type
long
(which maps to a java-int). |
static boolean |
isLong(Object object)
Checks if the any contains a value of the idl type
hyper
(which maps to a java-long). |
static boolean |
isObject(Object object)
Checks if the any contains an interface, struct, exception, sequence or enum.
|
static boolean |
isShort(Object object)
Checks if the any contains a value of the idl type
short . |
static boolean |
isString(Object object)
Checks if the any contains a value of the idl type
string . |
static boolean |
isType(Object object)
Checks if the any contains a value of the idl type
type . |
static boolean |
isVoid(Object object)
Checks if the any contains the idl type
void . |
static Object |
toArray(Object object)
Converts an array or an any containing an array into an array.
|
static boolean |
toBoolean(Object object)
Converts an Boolean object or an Any object containing a Boolean object
into a simple boolean.
|
static byte |
toByte(Object object)
Converts an Byte object or an Any object containing a Byte object into a
simple byte.
|
static char |
toChar(Object object)
Converts an Char object or an Any object containing a Char object into a
simple char.
|
static double |
toDouble(Object object)
Converts a number object into a simple double and allows widening conversions.
|
static float |
toFloat(Object object)
Converts a number object into a simple float and allows widening conversions.
|
static int |
toInt(Object object)
Converts a number object into a simple int and allows widening conversions.
|
static long |
toLong(Object object)
Converts a number object into a simple long and allows widening conversions.
|
static Object |
toObject(Class<?> clazz,
Object object)
Converts a UNO object (struct, exception, sequence, enum or interface) or
an Any containing these types into an UNO object of a specified destination
type.
|
static Object |
toObject(Type type,
Object object)
Converts a UNO object (struct, exception, sequence, enum or interface) or
an Any containing these types into an UNO object of a specified destination
type.
|
static short |
toShort(Object object)
Converts a number object into a simple short and allows widening conversions.
|
static String |
toString(Object object)
Converts a string or an any containing a string into a string.
|
static Type |
toType(Object object)
Converts a Type or an any containing a Type into a Type.
|
static int |
toUnsignedInt(Object object)
Converts a number object into an idl unsigned long and allows widening
conversions.
|
static long |
toUnsignedLong(Object object)
Converts a number object into an idl unsigned hyper and allows widening
conversions.
|
static short |
toUnsignedShort(Object object)
Converts a number object into an idl unsigned short and allows widening
conversions.
|
public static Type getType(Object object)
object
- any object.public static boolean isVoid(Object object)
void
.object
- the object to check.public static boolean isChar(Object object)
char
.object
- the object to check.public static boolean isBoolean(Object object)
boolean
.object
- the object to check.public static boolean isByte(Object object)
byte
.object
- the object to check.public static boolean isShort(Object object)
short
.object
- the object to check.public static boolean isInt(Object object)
long
(which maps to a java-int).object
- the object to check.public static boolean isLong(Object object)
hyper
(which maps to a java-long).object
- the object to check.public static boolean isFloat(Object object)
float
.object
- the object to check.public static boolean isDouble(Object object)
double
.object
- the object to check.public static boolean isString(Object object)
string
.object
- the object to check.public static boolean isEnum(Object object)
enum
.object
- the object to check.public static boolean isType(Object object)
type
.object
- the object to check.public static boolean isObject(Object object)
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.
object
- the object to check.public static boolean isArray(Object object)
object
- the object to check.public static char toChar(Object object) throws IllegalArgumentException
object
- the object to convert.IllegalArgumentException
- in case no char is
contained within object.isChar(java.lang.Object)
public static boolean toBoolean(Object object) throws IllegalArgumentException
object
- the object to convert.IllegalArgumentException
- in case no boolean is
contained within objectisBoolean(java.lang.Object)
public static byte toByte(Object object) throws IllegalArgumentException
object
- the object to convert.IllegalArgumentException
- in case no byte is
contained within object.isBoolean(java.lang.Object)
public static short toShort(Object object) throws IllegalArgumentException
Allowed argument types are Byte, Short or Any containing these types.
object
- the object to convert.IllegalArgumentException
- in case no short or
byte is contained within object.public static short toUnsignedShort(Object object) throws IllegalArgumentException
Allowed argument types are Anies containing idl unsigned short values.
object
- the object to convert.IllegalArgumentException
- in case no idl unsigned
short is contained within Any.public static int toInt(Object object) throws IllegalArgumentException
Allowed argument types are Byte, Short, Integer or Any containing these types.
object
- the object to convert.IllegalArgumentException
- in case no short, byte
or int is contained within object.public static int toUnsignedInt(Object object) throws IllegalArgumentException
Allowed argument types are Anies containing idl unsigned short or unsigned long values.
object
- the object to convert.IllegalArgumentException
- in case no idl unsigned
short nor unsigned long is contained within Any.public static long toLong(Object object) throws IllegalArgumentException
Allowed argument types are Byte, Short, Integer, Long or Any containing these types.
object
- the object to convert.IllegalArgumentException
- in case no short, byte,
int or long is contained within object.public static long toUnsignedLong(Object object) throws IllegalArgumentException
Allowed argument types are Anies containing idl unsigned short, unsigned long or unsigned hyper values.
object
- the object to convert.IllegalArgumentException
- in case no idl unsigned
short, nor unsigned long nor unsigned hyper is contained within object.public static float toFloat(Object object) throws IllegalArgumentException
Allowed argument types are Byte, Short, Float or Any containing these types.
object
- the object to convert.IllegalArgumentException
- in case no byte, short
or float is contained within object.public static double toDouble(Object object) throws IllegalArgumentException
Allowed argument types are Byte, Short, Int, Float, Double or Any containing these types.
object
- the object to convert.IllegalArgumentException
- in case no byte, short,
int, float or double is contained within object.public static String toString(Object object) throws IllegalArgumentException
object
- the object to convert.IllegalArgumentException
- in case no string is
contained within object.public static Type toType(Object object) throws IllegalArgumentException
object
- the object to convert.IllegalArgumentException
- in case no type is
contained within object.public static Object toObject(Type type, Object object) throws IllegalArgumentException
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.
type
- type of the returned value.object
- the object that is to be converted.IllegalArgumentException
- in case conversion is
not possible.public static Object toObject(Class<?> clazz, Object object) throws IllegalArgumentException
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.
clazz
- class of the returned value.object
- the object that is to be converted.IllegalArgumentException
- in case conversion is
not possible.public static Object toArray(Object object) throws IllegalArgumentException
object
- the object to convert.IllegalArgumentException
- in case no array is
contained within object.