|
GWT 2.1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gwt.core.ext.typeinfo.TypeOracle
public class TypeOracle
Provides type-related information about a set of source files, including doc comment metadata.
All type objects exposed, such as
JClassType
and others, have a stable
identity relative to this type oracle instance. Consequently, you can
reliably compare object identity of any objects this type oracle produces.
For example, the following code relies on this stable identity guarantee:
JClassType o = typeOracle.getJavaLangObject(); JClassType s1 = typeOracle.getType("java.lang.String"); JClassType s2 = typeOracle.getType("java.lang.String"); assert(s1 == s2); assert(o == s1.getSuperclass()); JParameterizedType ls = typeOracle.parse("java.util.List<java.lang.String>"); assert(ls.getTypeArgs()[0] == s1);
Field Summary | |
---|---|
static java.lang.String |
TAG_TYPEARGS
Deprecated. gwt.typeArgs is not longer supported |
Constructor Summary | |
---|---|
TypeOracle()
|
Method Summary | |
---|---|
JPackage |
findPackage(java.lang.String pkgName)
Attempts to find a package by name. |
JClassType |
findType(java.lang.String name)
Finds a class or interface given its fully-qualified name. |
JClassType |
findType(java.lang.String pkgName,
java.lang.String typeName)
Finds a type given its package-relative name. |
JArrayType |
getArrayType(JType componentType)
Gets the type object that represents an array of the specified type. |
JClassType |
getJavaLangObject()
Gets a reference to the type object representing java.lang.Object . |
JPackage |
getOrCreatePackage(java.lang.String name)
Ensure that a package with the specified name exists as well as its parent packages. |
JPackage |
getPackage(java.lang.String pkgName)
Gets a package by name. |
JPackage[] |
getPackages()
Gets an array of all packages known to this type oracle. |
JParameterizedType |
getParameterizedType(JGenericType genericType,
JClassType[] typeArgs)
Gets the parameterized type object that represents the combination of a specified raw type and a set of type arguments. |
JParameterizedType |
getParameterizedType(JGenericType genericType,
JClassType enclosingType,
JClassType[] typeArgs)
Gets the parameterized type object that represents the combination of a specified raw type and a set of type arguments. |
long |
getReloadCount()
Deprecated. This method will always return 0 because a TypeOracle never gets reloaded anymore. Callers should not rely on this value to manage static state. |
JClassType |
getSingleJsoImpl(JClassType intf)
Returns the single implementation type for an interface returned via getSingleJsoImplInterfaces() or null if no JSO
implementation is defined. |
java.util.Set<JClassType> |
getSingleJsoImplInterfaces()
Returns an unmodifiable, live view of all interface types that are implemented by exactly one JSO subtype. |
JClassType |
getType(java.lang.String name)
Finds a type given its fully qualified name. |
JClassType |
getType(java.lang.String pkgName,
java.lang.String topLevelTypeSimpleName)
Finds a type given its package-relative name. |
JClassType[] |
getTypes()
Gets all types, both top-level and nested. |
JWildcardType |
getWildcardType(JWildcardType.BoundType boundType,
JClassType typeBound)
|
JType |
parse(java.lang.String type)
Parses the string form of a type to produce the corresponding type object. |
static void |
sort(JClassType[] types)
Convenience method to sort class types in a consistent way. |
static void |
sort(JConstructor[] ctors)
Convenience method to sort constructors in a consistent way. |
static void |
sort(JField[] fields)
Convenience method to sort fields in a consistent way. |
static void |
sort(JMethod[] methods)
Convenience method to sort methods in a consistent way. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
@Deprecated public static final java.lang.String TAG_TYPEARGS
Constructor Detail |
---|
public TypeOracle()
Method Detail |
---|
public static void sort(JClassType[] types)
public static void sort(JConstructor[] ctors)
public static void sort(JField[] fields)
public static void sort(JMethod[] methods)
public JPackage findPackage(java.lang.String pkgName)
null
if the package could not be foundpublic JClassType findType(java.lang.String name)
name
- fully-qualified class/interface name - for nested classes, use
its source name rather than its binary name (that is, use a "."
rather than a "$")
null
if the type is not foundpublic JClassType findType(java.lang.String pkgName, java.lang.String typeName)
null
if the type is not foundpublic JArrayType getArrayType(JType componentType)
componentType
- the component type of the array, which can itself be
an array type
public JClassType getJavaLangObject()
java.lang.Object
.
public JPackage getOrCreatePackage(java.lang.String name)
public JPackage getPackage(java.lang.String pkgName) throws NotFoundException
NotFoundException
public JPackage[] getPackages()
public JParameterizedType getParameterizedType(JGenericType genericType, JClassType enclosingType, JClassType[] typeArgs)
genericType
- a generic base classenclosingType
- typeArgs
- the type arguments bound to the specified generic type
java.lang.IllegalArgumentException
- if the parameterization of a non-static
member type does not specify an enclosing type or if not enough
arguments were specified to parameterize the generic type
java.lang.NullPointerException
- if genericType is null
public JParameterizedType getParameterizedType(JGenericType genericType, JClassType[] typeArgs)
genericType
- a generic base classtypeArgs
- the type arguments bound to the specified generic type
java.lang.IllegalArgumentException
- if the generic type is a non-static member
type or if not enough arguments were specified to parameterize
the generic type
java.lang.NullPointerException
- if genericType is null
public long getReloadCount()
public JClassType getSingleJsoImpl(JClassType intf)
getSingleJsoImplInterfaces()
or null
if no JSO
implementation is defined.
public java.util.Set<JClassType> getSingleJsoImplInterfaces()
public JClassType getType(java.lang.String name) throws NotFoundException
NotFoundException
public JClassType getType(java.lang.String pkgName, java.lang.String topLevelTypeSimpleName) throws NotFoundException
NotFoundException
public JClassType[] getTypes()
public JWildcardType getWildcardType(JWildcardType.BoundType boundType, JClassType typeBound)
public JType parse(java.lang.String type) throws TypeOracleException
Examples of types that can be parsed by this method.
int
java.lang.Object
java.lang.String[]
char[][]
void
List<Shape>
List<List<Shape>>
type
- a type signature to be parsed
TypeOracleException
|
GWT 2.1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |