Class Type
- java.lang.Object
-
- com.sun.star.uno.Type
-
public class Type extends Object
Represents the UNO built-in typeTYPE.The UNO type is not directly mapped to
java.lang.Classfor at least two reasons. For one, some UNO types (likeUNSIGNED 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
Typeis uniquely determined by its type class (aTypeClass) and its type name (aString); these two will never benull. ATypemay have an additional "z class" (ajava.lang.Class), giving a Java class type that corresponds to the UNO type. Also, aTypecan cache a type description (acom.sun.star.uno.typedesc.TypeDescription), which can be computed and set byTypeDescription.getTypeDescription.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeANYstatic TypeBOOLEANstatic TypeBYTEstatic TypeCHARstatic TypeDOUBLEstatic TypeFLOATstatic TypeHYPERstatic TypeLONGstatic TypeSHORTstatic TypeSTRINGstatic TypeTYPEstatic TypeUNSIGNED_HYPERstatic TypeUNSIGNED_LONGstatic TypeUNSIGNED_SHORTstatic TypeVOID
-
Constructor Summary
Constructors Constructor Description Type()Constructs a newTypewhich defaults toVOID.Type(com.sun.star.lib.uno.typedesc.TypeDescription typeDescription)Constructs a newTypefrom the given type description.Type(TypeClass typeClass)Constructs a newTypewith the given type class.Type(Class<?> zClass)Constructs a newTypefrom the givenjava.lang.Class.Type(Class<?> zClass, boolean alternative)Constructs a newTypefrom the givenjava.lang.Class, handling ambiguous cases.Type(String typeName)Constructs a newTypewith the given type name.Type(String typeName, TypeClass typeClass)Constructs a newTypewith the given type class and type name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)Indicates whether some other object is equal to this one.TypeClassgetTypeClass()Gets the type class.com.sun.star.lib.uno.typedesc.TypeDescriptiongetTypeDescription()Gives the type description of this type.StringgetTypeName()Gets the type name.Class<?>getZClass()Gets the Java class.inthashCode()Returns a hash code value for the object.booleanisSupertypeOf(Type type)Determines whether this UNO type is a supertype of another UNO type.voidsetTypeDescription(com.sun.star.lib.uno.typedesc.TypeDescription typeDescription)Sets the type description for this type.StringtoString()Returns a string representation of the object.
-
-
-
Field Detail
-
VOID
public static final Type VOID
-
CHAR
public static final Type CHAR
-
BOOLEAN
public static final Type BOOLEAN
-
BYTE
public static final Type BYTE
-
SHORT
public static final Type SHORT
-
UNSIGNED_SHORT
public static final Type UNSIGNED_SHORT
-
LONG
public static final Type LONG
-
UNSIGNED_LONG
public static final Type UNSIGNED_LONG
-
HYPER
public static final Type HYPER
-
UNSIGNED_HYPER
public static final Type UNSIGNED_HYPER
-
FLOAT
public static final Type FLOAT
-
DOUBLE
public static final Type DOUBLE
-
STRING
public static final Type STRING
-
TYPE
public static final Type TYPE
-
ANY
public static final Type ANY
-
-
Constructor Detail
-
Type
public Type()
Constructs a newTypewhich defaults toVOID.
-
Type
public Type(String typeName, TypeClass typeClass)
Constructs a newTypewith the given type class and type name.- Parameters:
typeName- the type name. Must not benull.typeClass- the type class. Must not benull, and must match thetypeName(for example, it is illegal to combine atypeNameof"void"with atypeClassofBOOLEAN).
-
Type
public Type(Class<?> zClass)
Constructs a newTypefrom the givenjava.lang.Class.This is equivalent to
Type(zClass, false).- Parameters:
zClass- the Java class of this type. Must not benull.
-
Type
public Type(Class<?> zClass, boolean alternative)
Constructs a newTypefrom the givenjava.lang.Class, handling ambiguous cases.In certain cases, one Java class corresponds to two UNO types (e.g., the Java class
short[].classcorresponds to both a sequence ofSHORTand a sequence ofUNSIGNED SHORTin UNO). In such ambiguous cases, the parameteralternativecontrols which UNO type is chosen:- If the Java type is (an array type with element type)
shortorjava.lang.Short: Ifalternativeisfalse, the chosen UNO type is (a sequence type with element type)SHORT. Ifalternativeistrue, the chosen UNO type is (a sequence type with element type)UNSIGNED SHORT. - If the Java type is (an array type with element type)
intorjava.lang.Integer: Ifalternativeisfalse, the chosen UNO type is (a sequence type with element type)LONG. Ifalternativeistrue, the chosen UNO type is (a sequence type with element type)UNSIGNED LONG. - If the Java type is (an array type with element type)
longorjava.lang.Long: Ifalternativeisfalse, the chosen UNO type is (a sequence type with element type)HYPER. Ifalternativeistrue, the chosen UNO type is (a sequence type with element type)UNSIGNED HYPER. - If the Java type is (an array type with element type)
java.lang.Object: Ifalternativeisfalse, the chosen UNO type is (a sequence type with element type)ANY. Ifalternativeistrue, the chosen UNO type is (a sequence type with element type)com.sun.star.uno.XInterface.
In all other cases, the value of
alternativeis ignored.This constructor cannot be used to create
Typeinstances that represent (sequences of) instantiated polymorphic struct types.- Parameters:
zClass- the Java class of this type; must not benullalternative- controls which UNO type to choose in case of ambiguities- Since:
- UDK 3.2.0
- If the Java type is (an array type with element type)
-
Type
public Type(com.sun.star.lib.uno.typedesc.TypeDescription typeDescription)
Constructs a newTypefrom the given type description. For internal URE use only. Not to be used by client code.- Parameters:
typeDescription- a type description. Must not benull.
-
Type
public Type(String typeName)
Constructs a newTypewith the given type name.- Parameters:
typeName- the name of this type; must not benull.
-
Type
public Type(TypeClass typeClass)
Constructs a newTypewith the given type class.- Parameters:
typeClass- the type class of this type; must not benull. Only type classes for simple types are allowed here.- Throws:
IllegalArgumentException- if the giventypeClassis 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
-
getTypeClass
public TypeClass getTypeClass()
Gets the type class.- Returns:
- the type class. Will never be
null, but might beUNKNOWN.
-
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
nullin extreme situations (inconsistentTypeClass, error loading a class)
-
getTypeDescription
public com.sun.star.lib.uno.typedesc.TypeDescription getTypeDescription()
Gives the type description of this type. For internal URE use only. Not to be used by client code.- Returns:
- the type description; may be
null
-
setTypeDescription
public void setTypeDescription(com.sun.star.lib.uno.typedesc.TypeDescription typeDescription)
Sets the type description for this type. For internal URE use only. Not to be used by client code.- Parameters:
typeDescription- the type description
-
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
-
equals
public boolean equals(Object obj)
Indicates whether some other object is equal to this one.- Overrides:
equalsin classObject- Parameters:
obj- the reference object with which to compare.- Returns:
trueif this object is the same as the obj argument;falseotherwise.- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
Returns a hash code value for the object.- Overrides:
hashCodein classObject- Returns:
- a hash code value for this object.
- See Also:
Object.hashCode()
-
toString
public String toString()
Returns a string representation of the object.- Overrides:
toStringin classObject- Returns:
- a string representation of the object.
- See Also:
Object.toString()
-
-