com.sun.star.uno

Class Type

public class Type extends Object

Represents the UNO built-in type TYPE.

The UNO type is not directly mapped to java.lang.Class for at least two reasons. For one, some UNO types (like UNSIGNED SHORT) do not have a matching Java class. For another, it can be necessary to describe a type which is unknown to the Java runtime system (for example, for delaying the need of a class, so that it is possible to generate it on the fly.)

A Type is uniquely determined by its type class (a TypeClass) and its type name (a String); these two will never be null. A Type may have an additional "z class" (a java.lang.Class), giving a Java class type that corresponds to the UNO type. Also, a Type can cache a type description (a com.sun.star.uno.ITypeDescription), which can be computed and set by TypeDescription.getTypeDescription.

Field Summary
static TypeANY
static TypeBOOLEAN
static TypeBYTE
static TypeCHAR
static TypeDOUBLE
static TypeFLOAT
static TypeHYPER
static TypeLONG
static TypeSHORT
static TypeSTRING
static TypeTYPE
static TypeUNSIGNED_HYPER
static TypeUNSIGNED_LONG
static TypeUNSIGNED_SHORT
static TypeVOID
protected Class_class
protected ITypeDescription_iTypeDescription
protected TypeClass_typeClass
protected String_typeName
Constructor Summary
Type()
Constructs a new Type which defaults to VOID.
Type(String typeName, TypeClass typeClass)
Constructs a new Type with the given type class and type name.
Type(Class zClass)
Constructs a new Type from the given java.lang.Class.
Type(Class zClass, boolean alternative)
Constructs a new Type from the given java.lang.Class, handling ambiguous cases.
Type(ITypeDescription typeDescription)
Constructs a new Type from the given type description.
Type(String typeName)
Constructs a new Type with the given type name.
Type(TypeClass typeClass)
Constructs a new Type with the given type class.
Method Summary
booleanequals(Object obj)
TypeClassgetTypeClass()
Gets the type class.
ITypeDescriptiongetTypeDescription()
Gives the type description of this type.
StringgetTypeName()
Gets the type name.
ClassgetZClass()
Gets the Java class.
inthashCode()
booleanisSupertypeOf(Type type)
Determines whether this UNO type is a supertype of another UNO type.
voidsetTypeDescription(ITypeDescription typeDescription)
Sets the type description for this type.
StringtoString()

Field Detail

ANY

public static final Type ANY

BOOLEAN

public static final Type BOOLEAN

BYTE

public static final Type BYTE

CHAR

public static final Type CHAR

DOUBLE

public static final Type DOUBLE

FLOAT

public static final Type FLOAT

HYPER

public static final Type HYPER

LONG

public static final Type LONG

SHORT

public static final Type SHORT

STRING

public static final Type STRING

TYPE

public static final Type TYPE

UNSIGNED_HYPER

public static final Type UNSIGNED_HYPER

UNSIGNED_LONG

public static final Type UNSIGNED_LONG

UNSIGNED_SHORT

public static final Type UNSIGNED_SHORT

VOID

public static final Type VOID

_class

protected Class _class

_iTypeDescription

protected ITypeDescription _iTypeDescription

_typeClass

protected TypeClass _typeClass

_typeName

protected String _typeName

Constructor Detail

Type

public Type()
Constructs a new Type which defaults to VOID.

Type

public Type(String typeName, TypeClass typeClass)
Constructs a new Type with the given type class and type name.

Parameters: typeName the type name. Must not be null. typeClass the type class. Must not be null, and must match the typeName (for example, it is illegal to combine a typeName of "void" with a typeClass of BOOLEAN).

Type

public Type(Class zClass)
Constructs a new Type from the given java.lang.Class.

This is equivalent to Type(zClass, false).

Parameters: zClass the Java class of this type. Must not be null.

Type

public Type(Class zClass, boolean alternative)
Constructs a new Type from the given java.lang.Class, handling ambiguous cases.

In certain cases, one Java class corresponds to two UNO types (e.g., the Java class short[].class corresponds to both a sequence of SHORT and a sequence of UNSIGNED SHORT in UNO). In such ambiguous cases, the parameter alternative controls which UNO type is chosen:

In all other cases, the value of alternative is ignored.

This constructor cannot be used to create Type instances that represent (sequences of) instantiated polymorphic struct types.

Parameters: zClass the Java class of this type; must not be null alternative controls which UNO type to choose in case of ambiguities

Since: UDK 3.2.0

Type

public Type(ITypeDescription typeDescription)
Constructs a new Type from the given type description.

Parameters: typeDescription a type description. Must not be null.

Type

public Type(String typeName)
Constructs a new Type with the given type name.

Parameters: typeName the name of this type; must not be null.

Type

public Type(TypeClass typeClass)
Constructs a new Type with the given type class.

Parameters: typeClass the type class of this type; must not be null. Only type classes for simple types are allowed here.

Throws: IllegalArgumentException if the given typeClass is not simple (for example, a struct or an interface type). This constructor could not find out the type name in such a case.

Method Detail

equals

public boolean equals(Object obj)

getTypeClass

public TypeClass getTypeClass()
Gets the type class.

Returns: the type class. Will never be null, but might be UNKNOWN.

getTypeDescription

public ITypeDescription getTypeDescription()
Gives the type description of this type.

Returns: the type description; may be null

getTypeName

public String getTypeName()
Gets the type name.

Returns: the type name; will never be null

getZClass

public Class getZClass()
Gets the Java class.

Returns: the type name; may be null in extreme situations (inconsistent TypeClass, error loading a class)

hashCode

public int hashCode()

isSupertypeOf

public boolean isSupertypeOf(Type type)
Determines whether this UNO type is a supertype of another UNO type. UNO only defines the following supertype relations: (1) A struct type t1 is a supertype of a struct type t2, if either t1 and t2 are the same, or t1 is a direct or indirect parent of t2. (2) An exception type t1 is a supertype of an exception type t2, if either t1 and t2 are the same, or t1 is a direct or indirect parent of t2. (3) An interface type t1 is a supertype of an interface type t2, if either t1 and t2 are the same, or t1 is a direct or indirect parent of t2. Following the conventions of the Java UNO language binding, com.sun.star.uno.Exception is not considered a supertype of com.sun.star.uno.RuntimeException or any exception type derived from com.sun.star.uno.RuntimeException.

Parameters: type some Type

Returns: true if this type is a supertype of the given type

Since: UDK 3.2.0

setTypeDescription

public void setTypeDescription(ITypeDescription typeDescription)
Sets the type description for this type.

Parameters: typeDescription the type description

toString

public String toString()