|
|||||||||
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
A reserved metadata tag to indicates that a field type, method return type or method parameter type is intended to be parameterized. |
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. |
JType |
getParameterizedType(JClassType rawType,
JType[] typeArgs)
Gets the parameterized type object that represents the combination of a specified raw type and a set of type arguments. |
long |
getReloadCount()
|
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. |
JClassType[] |
getTypesInCompilationUnit(CompilationUnitProvider cup)
|
JType |
parse(java.lang.String type)
Parses the string form of a type to produce the corresponding type object. |
void |
sort(JClassType[] types)
Convenience method to sort class types in a consistent way. |
void |
sort(JConstructor[] ctors)
Convenience method to sort constructors in a consistent way. |
void |
sort(JField[] fields)
Convenience method to sort fields in a consistent way. |
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 |
---|
public static final java.lang.String TAG_TYPEARGS
Constructor Detail |
---|
public TypeOracle()
Method Detail |
---|
public JPackage findPackage(java.lang.String pkgName)
null
if the package could not be foundpublic JClassType findType(java.lang.String name)
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 JType getParameterizedType(JClassType rawType, JType[] typeArgs)
rawType
- the raw type of the array, which must be a class or
interface type and cannot be a primitive, array, or another
parameterized typetypeArgs
- the type arguments bound to the specified raw type
public long getReloadCount()
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 JClassType[] getTypesInCompilationUnit(CompilationUnitProvider cup)
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
public void sort(JClassType[] types)
public void sort(JConstructor[] ctors)
public void sort(JField[] fields)
public void sort(JMethod[] methods)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |