|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ideanest.attributes.dev.TypeResolver
Resolves type names found in Java source files, according to Java type resolution rules. Normally this algorithm is implemented by a Java compiler, but sometimes we want to know what fully qualified typename a typename mentioned locally corresponds to.
Instances of this class are not thread-safe.
Constructor Summary | |
TypeResolver()
|
Method Summary | |
void |
addImport(java.lang.String importName)
Register an import declaration, either fully qualified or wildcard. |
void |
addPackage(java.lang.String packageName)
Set the package name for the source file being parsed. |
java.lang.String |
beginClass(com.thoughtworks.qdox.parser.structs.ClassDef def)
Mark the beginning of a class definition. |
java.lang.String |
endClass()
Mark the end of a class definition. |
java.lang.String |
getCurrentClassName()
Get the fully qualified name of the class currently being defined. |
boolean |
isTopContext()
Check whether we are currently defining a class. |
void |
reset()
Reset this type resolver to a virgin state, as if though newly instantiated. |
java.lang.Class |
resolve(java.lang.String typeName)
Resolve a local type name to a type. |
java.lang.Class |
resolve(java.lang.String typeName,
int dimensions)
Resolve an array type, with the given base type name and number of dimensions. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TypeResolver()
Method Detail |
public void addImport(java.lang.String importName)
importName
- the name of the imported type or package (including ".*" if wildcard)public void addPackage(java.lang.String packageName)
packageName
- the package name of the current source file
java.lang.IllegalStateException
- if the package name was already setpublic java.lang.String beginClass(com.thoughtworks.qdox.parser.structs.ClassDef def)
def
- the class header, giving its name and other details
public java.lang.String endClass()
java.lang.IllegalStateException
- if no class is currently being definedpublic java.lang.String getCurrentClassName()
java.lang.IllegalStateException
- if there is no class currently being definedpublic boolean isTopContext()
true
if there is no class definition currently under way, false
otherwisepublic void reset()
public java.lang.Class resolve(java.lang.String typeName) throws java.lang.ClassNotFoundException
typeName
- a type name, qualified or not, primitive or not
java.lang.ClassNotFoundException
- if the type name could not be resolvedresolve(String,int)
public java.lang.Class resolve(java.lang.String typeName, int dimensions) throws java.lang.ClassNotFoundException
resolve(String)
.
typeName
- a type name, qualified or not, nested or notdimensions
- the number of dimensions for the array type
java.lang.ClassNotFoundException
- if the base type cannot be resolved
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |