org.openide.src 1.8.22

org.openide.src
Class Type

java.lang.Object
  extended by org.openide.src.Type
All Implemented Interfaces:
Serializable, Cloneable

public final class Type
extends Object
implements Cloneable, Serializable

Java types.

See Also:
Serialized Form

Field Summary
static Type BOOLEAN
          boolean primitive type.
static Type BYTE
          byte primitive type.
static Type CHAR
          char primitive type.
static Type DOUBLE
          double primitive type.
static Type FLOAT
          float primitive type.
static Type INT
          int primitive type.
static Type LONG
          long primitive type.
static Type SHORT
          short primitive type.
static Type VOID
          void primitive type.
 
Method Summary
 boolean compareTo(Type type, boolean source)
          Compare the specified Type with this Type for equality.
static Type createArray(Type elementType)
          Create an array type.
static Type createClass(Identifier id)
          Create a class type by name.
static Type createFromClass(Class cl)
          Create a type from an existing class.
 boolean equals(Object o)
          Compare the specified object with this Type for equality.
 Identifier getClassName()
          Get the (fully-qualified) name of this class type.
 Type getElementType()
          Get the element type of this array type.
 String getFullString()
          Get a form of this type usable in Java source.
 String getSignature()
          Deprecated. Use Type.getSignature (FileObject projectArtefact) method.
 String getSignature(FileObject projectArtefact)
          Returns a JVM-signature of the type.
 String getSourceString()
          Get a form of this type usable in Java source.
 Identifier getTypeIdentifier()
          Returns the identifier of a class for a class-type.
static String[] getTypesNames()
          Get the Java names of the primitive types.
 String getVMClassName()
          Deprecated. Use the Test.getVMClassName(final FileObject projectArtefact) method.
 String getVMClassName(FileObject projectArtefact)
          Constructs and returns name of a reference type that can be used for Class.forName().
 int hashCode()
           
 boolean isArray()
          Test if the type is an array.
 boolean isClass()
          Test if the type is a class or interface.
 boolean isPrimitive()
          Test if the type is primitive.
static Type parse(String text)
          Create a type from its string representation.
 Class toClass()
          Attempt to get the real class corresponding to this type, using the default class loader.
 Class toClass(ClassLoader loader)
          Attempt to get the real class corresponding to this type.
 String toString()
          Get a form of this type usable in Java source.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

VOID

public static final Type VOID
void primitive type.


BOOLEAN

public static final Type BOOLEAN
boolean primitive type.


INT

public static final Type INT
int primitive type.


CHAR

public static final Type CHAR
char primitive type.


BYTE

public static final Type BYTE
byte primitive type.


SHORT

public static final Type SHORT
short primitive type.


LONG

public static final Type LONG
long primitive type.


FLOAT

public static final Type FLOAT
float primitive type.


DOUBLE

public static final Type DOUBLE
double primitive type.

Method Detail

getTypesNames

public static String[] getTypesNames()
Get the Java names of the primitive types.

Returns:
the names

createArray

public static Type createArray(Type elementType)
Create an array type.

Parameters:
elementType - the element type
Returns:
the array type

createClass

public static Type createClass(Identifier id)
Create a class type by name.

Parameters:
id - the class name
Returns:
the class type

createFromClass

public static Type createFromClass(Class cl)
Create a type from an existing class.

Parameters:
cl - the class
Returns:
the type

parse

public static Type parse(String text)
                  throws IllegalArgumentException
Create a type from its string representation.

Parameters:
text - the string representation, e.g. "int[][]", "java.awt.Button", etc.
Returns:
the type
Throws:
InvalidArgumentException - if the text cannot be parsed
IllegalArgumentException

isPrimitive

public boolean isPrimitive()
Test if the type is primitive.

Returns:
true if so

isArray

public boolean isArray()
Test if the type is an array.

Returns:
true if so

isClass

public boolean isClass()
Test if the type is a class or interface.

Returns:
true if so, false if an array or primitive type

getElementType

public Type getElementType()
                    throws IllegalStateException
Get the element type of this array type.

Returns:
the element type
Throws:
IllegalStateException - if this type is not an array type

getClassName

public Identifier getClassName()
                        throws IllegalStateException
Get the (fully-qualified) name of this class type.

Returns:
the class name
Throws:
IllegalStateException - if this type is not a simple class or interface type

toClass

public Class toClass()
              throws ClassNotFoundException
Attempt to get the real class corresponding to this type, using the default class loader.

Returns:
the class
Throws:
ClassNotFoundException - if the class cannot be found

toClass

public Class toClass(ClassLoader loader)
              throws ClassNotFoundException
Attempt to get the real class corresponding to this type.

Parameters:
loader - class loader to use for loading classes
Returns:
the class
Throws:
ClassNotFoundException - if the class cannot be found

getSourceString

public String getSourceString()
Get a form of this type usable in Java source.

Returns:
the string representation

getFullString

public String getFullString()
Get a form of this type usable in Java source.

Returns:
the string representation

toString

public String toString()
Get a form of this type usable in Java source.

Overrides:
toString in class Object
Returns:
the string representation

getVMClassName

public final String getVMClassName()
                            throws UnsupportedOperationException
Deprecated. Use the Test.getVMClassName(final FileObject projectArtefact) method.

Constructs and returns name of a reference type that can be used for Class.forName(). If the type is a primitive one, the method raises UnsupportedOperationException since the operation is not supported for primitive types. If the type is an array, the returned signature will begin with one or more `[' chars (depending on the array depth), followed by LclassSignature; (L and ; are literals here; classSignature is obtained from ClassElement.getSignature()).

Returns:
name compatible with Class.forName()
Throws:
UnsupportedOperationException

getVMClassName

public final String getVMClassName(FileObject projectArtefact)
                            throws UnsupportedOperationException
Constructs and returns name of a reference type that can be used for Class.forName(). If the type is a primitive one, the method raises UnsupportedOperationException since the operation is not supported for primitive types. If the type is an array, the returned signature will begin with one or more `[' chars (depending on the array depth), followed by LclassSignature; (L and ; are literals here; classSignature is obtained from ClassElement.getSignature()).

Parameters:
projectArtefact - the FileObject which implies the project classpath to resolve the Type into ClassElement
Returns:
name compatible with Class.forName()
Throws:
UnsupportedOperationException - if the type is primitive.

getTypeIdentifier

public final Identifier getTypeIdentifier()
                                   throws UnsupportedOperationException
Returns the identifier of a class for a class-type. The operation is not supported for array types or primitive types.

Returns:
the identifier for the object type
Throws:
UnsupportedOperationException

getSignature

public final String getSignature()
Deprecated. Use Type.getSignature (FileObject projectArtefact) method.

Returns a JVM-signature of the type. This operation is supported even for primitive types for which it returns one-char type code. For reference types, dots in fully qualified class names are replaced by slashes (/). Constructed signatures will exactly match those found in a compiled .class file.

Returns:
signature of the type

getSignature

public final String getSignature(FileObject projectArtefact)
Returns a JVM-signature of the type. This operation is supported even for primitive types for which it returns one-char type code. For reference types, dots in fully qualified class names are replaced by slashes (/). Constructed signatures will exactly match those found in a compiled .class file.

Parameters:
projectArtefact - the FileObject which implies the project ClassPath
Returns:
signature of the type

compareTo

public boolean compareTo(Type type,
                         boolean source)
Compare the specified Type with this Type for equality.

Parameters:
type - Type to be compared with this
source - Determine if the source name (for class types) should be also compared. If false only fully qualified name is compared.
Returns:
true if the specified object equals to specified Identifier otherwise false.

equals

public boolean equals(Object o)
Compare the specified object with this Type for equality. There are tested only full qualified name if the type is Class

Overrides:
equals in class Object
Parameters:
o - Object to be compared with this
Returns:
true if the specified object represents the same type otherwise false.

hashCode

public int hashCode()
Overrides:
hashCode in class Object
Returns:
the hash code of full name String object.

org.openide.src 1.8.22

Built on July 11 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.