public class Type
extends java.lang.Object
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
.
Modifier and Type | Field and Description |
---|---|
protected java.lang.Class |
_class |
protected ITypeDescription |
_iTypeDescription |
protected TypeClass |
_typeClass |
protected java.lang.String |
_typeName |
static Type |
ANY |
static Type |
BOOLEAN |
static Type |
BYTE |
static Type |
CHAR |
static Type |
DOUBLE |
static Type |
FLOAT |
static Type |
HYPER |
static Type |
LONG |
static Type |
SHORT |
static Type |
STRING |
static Type |
TYPE |
static Type |
UNSIGNED_HYPER |
static Type |
UNSIGNED_LONG |
static Type |
UNSIGNED_SHORT |
static Type |
VOID |
Constructor and Description |
---|
Type()
Constructs a new
Type which defaults to VOID . |
Type(java.lang.Class zClass)
Constructs a new
Type from the given
java.lang.Class . |
Type(java.lang.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(java.lang.String typeName)
Constructs a new
Type with the given type name. |
Type(java.lang.String typeName,
TypeClass typeClass)
Constructs a new
Type with the given type class and type
name. |
Type(TypeClass typeClass)
Constructs a new
Type with the given type class. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
TypeClass |
getTypeClass()
Gets the type class.
|
ITypeDescription |
getTypeDescription()
Gives the type description of this type.
|
java.lang.String |
getTypeName()
Gets the type name.
|
java.lang.Class |
getZClass()
Gets the Java class.
|
int |
hashCode() |
boolean |
isSupertypeOf(Type type)
Determines whether this UNO type is a supertype of another UNO type.
|
void |
setTypeDescription(ITypeDescription typeDescription)
Sets the type description for this type.
|
java.lang.String |
toString() |
public static final Type VOID
public static final Type CHAR
public static final Type BOOLEAN
public static final Type BYTE
public static final Type SHORT
public static final Type UNSIGNED_SHORT
public static final Type LONG
public static final Type UNSIGNED_LONG
public static final Type HYPER
public static final Type UNSIGNED_HYPER
public static final Type FLOAT
public static final Type DOUBLE
public static final Type STRING
public static final Type TYPE
public static final Type ANY
protected TypeClass _typeClass
protected java.lang.String _typeName
protected java.lang.Class _class
protected ITypeDescription _iTypeDescription
public Type()
Type
which defaults to VOID
.public Type(java.lang.String typeName, TypeClass typeClass)
Type
with the given type class and type
name.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
).public Type(java.lang.Class zClass)
Type
from the given
java.lang.Class
.
This is equivalent to Type(zClass, false)
.
zClass
- the Java class of this type. Must not be
null
.public Type(java.lang.Class zClass, boolean alternative)
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:
short
or java.lang.Short
: If
alternative
is false
, the chosen UNO type is
(a sequence type with element type) SHORT
. If
alternative
is true
, the chosen UNO type is
(a sequence type with element type) UNSIGNED SHORT
.int
or java.lang.Integer
: If
alternative
is false
, the chosen UNO type is
(a sequence type with element type) LONG
. If
alternative
is true
, the chosen UNO type is
(a sequence type with element type) UNSIGNED LONG
.long
or java.lang.Long
: If
alternative
is false
, the chosen UNO type is
(a sequence type with element type) HYPER
. If
alternative
is true
, the chosen UNO type is
(a sequence type with element type) UNSIGNED HYPER
.java.lang.Object
: If alternative
is
false
, the chosen UNO type is (a sequence type with
element type) ANY
. If alternative
is
true
, the chosen UNO type is (a sequence type with element
type) com.sun.star.uno.XInterface
.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.
zClass
- the Java class of this type; must not be null
alternative
- controls which UNO type to choose in case of
ambiguitiespublic Type(ITypeDescription typeDescription)
Type
from the given type description.typeDescription
- a type description. Must not be
null
.public Type(java.lang.String typeName)
Type
with the given type name.typeName
- the name of this type; must not be null
.public Type(TypeClass typeClass)
Type
with the given type class.typeClass
- the type class of this type; must not be
null
. Only type classes for simple types are allowed
here.java.lang.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.public TypeClass getTypeClass()
null
, but might be
UNKNOWN
.public java.lang.String getTypeName()
null
public java.lang.Class getZClass()
null
in extreme situations
(inconsistent TypeClass
, error loading a class)public ITypeDescription getTypeDescription()
null
public void setTypeDescription(ITypeDescription typeDescription)
typeDescription
- the type descriptionpublic boolean isSupertypeOf(Type type)
type
- some Typepublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object