org.tentackle.annotations
Class AnalyzeInfo

java.lang.Object
  extended by org.tentackle.annotations.AnalyzeInfo

public class AnalyzeInfo
extends Object

Holds information gathered by the Analyze annotation.

The AnalyzeProcessor creates an info file in an apt run and wurblets pick up this information to generate code.

Author:
harald

Nested Class Summary
static class AnalyzeInfo.Parameter
          Abstraction of a method parameter.
 
Field Summary
static String INFO_FILE_EXTENSION
          all info files end with .info
static String INFO_FILE_VERSION
          Fileformat version
static String TYPE_CLASS
          Information type for a class.
static String TYPE_METHOD
          Information type for a method.
 
Constructor Summary
AnalyzeInfo(ProcessingEnvironment processingEnv, ExecutableElement methodElement)
          Creates an AnalyzeInfo from a method element.
AnalyzeInfo(String type)
          Creates an AnalyzeInfo for a given type.
 
Method Summary
 void addParameter(AnalyzeInfo.Parameter parameter)
          Adds a formal parameter
 String cleanTypeString(String type)
          Simplifies some classnames by removing package names.
 String getClassName()
          Gets the name of the class this analyze info is part of.
 String getMethodName()
          Gets the method name the annotation belongs to.
 Modifier[] getModifiers()
          Gets the modifiers for the method
 String getModifiersAsString()
          Gets the method's modifiers as a string
 AnalyzeInfo.Parameter[] getParameters()
          Gets the formal parameters of the method.
 String getReturnType()
          Gets the return type of the method
 String getSuperClassName()
          Gets the name of the superclass this analyze info is part of.
 String getType()
          Gets the type of this analyze info.
 boolean isModifierSet(Modifier modifier)
          Checks whether given modifier is set for the method
static boolean isModifierSet(Modifier modifier, Modifier[] modifierList)
          Checks if a modifier is in the set of modifiers
 boolean isReturningAppDbCursor()
          Checks whether the method is returning an AppDbCursor.
 boolean isReturningAppDbObject()
          Checks whether the method is returning an AppDbObject.
 boolean isReturningAppDbObjectCollection()
          Checks whether the method is returning a collection of AppDbObjects.
 boolean isReturningDbCursor()
          Checks whether the method is returning a DbCursors.
 boolean isReturningDbObject()
          Checks whether the method is returning a DbObject.
 boolean isReturningDbObjectCollection()
          Checks whether the method is returning a collection of DbObjects.
 boolean isVarArgsMethod()
          Returns whether the method has varargs.
static AnalyzeInfo readInfo(File infoFile)
          Reads info from an file.
static AnalyzeInfo readInfo(LineNumberReader reader)
          Reads info from an line reader.
 void setClassName(String className)
          Sets the classname and the packagename from a given classname.
 void setMethodName(String methodName)
          Sets the method name the annotation belongs to.
 void setModifiers(Modifier[] modifiers)
          Sets the modifiers for the method
 void setReturningAppDbCursor(boolean returningAppDbCursor)
          Sets whether the method is returning an AppDbCursor.
 void setReturningAppDbObject(boolean returningAppDbObject)
          Sets whether the method is returning an AppDbObject.
 void setReturningAppDbObjectCollection(boolean returningAppDbObjectCollection)
          Sets whether the method is returning a collection of AppDbObjects.
 void setReturningDbCursor(boolean returningDbCursor)
          Sets whether the method is returning a DbCursor.
 void setReturningDbObject(boolean returningDbObject)
          Sets whether the method is returning a DbObject.
 void setReturningDbObjectCollection(boolean returningDbObjectCollection)
          Sets whether the method is returning a collection of DbObjects.
 void setReturnType(String returnType)
          Sets the return type of the method
 void setSuperClassName(String superClassName)
          Sets the classname of the superclass.
 void setVarArgsMethod(boolean varArgsMethod)
          Sets whether the method has varargs.
 String toString()
          Gets the declaration string
 void write(PrintWriter writer)
          Writes this object to an info file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INFO_FILE_VERSION

public static final String INFO_FILE_VERSION
Fileformat version

See Also:
Constant Field Values

INFO_FILE_EXTENSION

public static final String INFO_FILE_EXTENSION
all info files end with .info

See Also:
Constant Field Values

TYPE_METHOD

public static final String TYPE_METHOD
Information type for a method.

See Also:
Constant Field Values

TYPE_CLASS

public static final String TYPE_CLASS
Information type for a class.

See Also:
Constant Field Values
Constructor Detail

AnalyzeInfo

public AnalyzeInfo(String type)
            throws IOException
Creates an AnalyzeInfo for a given type. Used when reading from infofile.

Parameters:
type - one of TYPE_...
Throws:
IOException - if unsupported TYPE_...

AnalyzeInfo

public AnalyzeInfo(ProcessingEnvironment processingEnv,
                   ExecutableElement methodElement)
            throws IOException
Creates an AnalyzeInfo from a method element. Used during apt processing.

Parameters:
processingEnv - the annotation processor's environment
methodElement - the ExecutableElement to create an info from
Throws:
IOException - if some I/O error occurs
Method Detail

getType

public String getType()
Gets the type of this analyze info.

Returns:
the type

getClassName

public String getClassName()
Gets the name of the class this analyze info is part of.

Returns:
the classname

setClassName

public void setClassName(String className)
Sets the classname and the packagename from a given classname.

Parameters:
className - the full class name

getSuperClassName

public String getSuperClassName()
Gets the name of the superclass this analyze info is part of.

Returns:
the classname

setSuperClassName

public void setSuperClassName(String superClassName)
Sets the classname of the superclass.

Parameters:
superClassName - the full class name

getMethodName

public String getMethodName()
Gets the method name the annotation belongs to.

Returns:
the method name

setMethodName

public void setMethodName(String methodName)
Sets the method name the annotation belongs to.

Parameters:
methodName - the method name

getReturnType

public String getReturnType()
Gets the return type of the method

Returns:
the return type

setReturnType

public void setReturnType(String returnType)
Sets the return type of the method

Parameters:
returnType - the return type

getParameters

public AnalyzeInfo.Parameter[] getParameters()
Gets the formal parameters of the method.

Returns:
the array of parameters

addParameter

public void addParameter(AnalyzeInfo.Parameter parameter)
Adds a formal parameter

Parameters:
parameter - the formal parameter to add

isVarArgsMethod

public boolean isVarArgsMethod()
Returns whether the method has varargs.

Returns:
true if varargs method

setVarArgsMethod

public void setVarArgsMethod(boolean varArgsMethod)
Sets whether the method has varargs.

Parameters:
varArgsMethod - true if varargs method

getModifiers

public Modifier[] getModifiers()
Gets the modifiers for the method

Returns:
the array of modifiers

getModifiersAsString

public String getModifiersAsString()
Gets the method's modifiers as a string

Returns:
the modifiers as a string

isModifierSet

public boolean isModifierSet(Modifier modifier)
Checks whether given modifier is set for the method

Parameters:
modifier - the modifier to test
Returns:
true if modifier set

setModifiers

public void setModifiers(Modifier[] modifiers)
Sets the modifiers for the method

Parameters:
modifiers - for the method

isReturningDbObject

public boolean isReturningDbObject()
Checks whether the method is returning a DbObject.

Returns:
true if method returns a DbObject.

setReturningDbObject

public void setReturningDbObject(boolean returningDbObject)
Sets whether the method is returning a DbObject.

Parameters:
returningDbObject - true if method returns a DbObject.

isReturningDbObjectCollection

public boolean isReturningDbObjectCollection()
Checks whether the method is returning a collection of DbObjects.

Returns:
true if method returns a collection of DbObjects.

setReturningDbObjectCollection

public void setReturningDbObjectCollection(boolean returningDbObjectCollection)
Sets whether the method is returning a collection of DbObjects.

Parameters:
returningDbObjectCollection - true if method returns a collection of DbObjects.

isReturningDbCursor

public boolean isReturningDbCursor()
Checks whether the method is returning a DbCursors.

Returns:
true if method returns a collection of DbCursor.

setReturningDbCursor

public void setReturningDbCursor(boolean returningDbCursor)
Sets whether the method is returning a DbCursor.

Parameters:
returningDbCursor - true if method returns a collection of DbCursor.

isReturningAppDbObject

public boolean isReturningAppDbObject()
Checks whether the method is returning an AppDbObject.

Returns:
true if method returns an AppDbObject.

setReturningAppDbObject

public void setReturningAppDbObject(boolean returningAppDbObject)
Sets whether the method is returning an AppDbObject.

Parameters:
returningAppDbObject - true if method returns an AppDbObject.

isReturningAppDbObjectCollection

public boolean isReturningAppDbObjectCollection()
Checks whether the method is returning a collection of AppDbObjects.

Returns:
true if method returns a collection of AppDbObjects.

setReturningAppDbObjectCollection

public void setReturningAppDbObjectCollection(boolean returningAppDbObjectCollection)
Sets whether the method is returning a collection of AppDbObjects.

Parameters:
returningAppDbObjectCollection - true if method returns a collection of AppDbObjects.

isReturningAppDbCursor

public boolean isReturningAppDbCursor()
Checks whether the method is returning an AppDbCursor.

Returns:
true if method returns an AppDbCursor.

setReturningAppDbCursor

public void setReturningAppDbCursor(boolean returningAppDbCursor)
Sets whether the method is returning an AppDbCursor.

Parameters:
returningAppDbCursor - true if method returns an AppDbCursor.

toString

public String toString()
Gets the declaration string

Overrides:
toString in class Object
Returns:
a string representation of the object.

write

public void write(PrintWriter writer)
           throws IOException
Writes this object to an info file.

Parameters:
writer - is the PrintWriter object
Throws:
IOException - if write failed

readInfo

public static AnalyzeInfo readInfo(File infoFile)
                            throws FileNotFoundException,
                                   IOException
Reads info from an file.

Parameters:
infoFile - the file to read from
Returns:
an AnalyzeInfo object, null if file is empty or does not contain an AnalyzeInfo-text
Throws:
FileNotFoundException
IOException

readInfo

public static AnalyzeInfo readInfo(LineNumberReader reader)
                            throws IOException
Reads info from an line reader.

Parameters:
reader - is the LineNumberReader
Returns:
an AnalyzeInfo object, null if file is empty or does not contain an AnalyzeInfo-text
Throws:
IOException

isModifierSet

public static boolean isModifierSet(Modifier modifier,
                                    Modifier[] modifierList)
Checks if a modifier is in the set of modifiers

Parameters:
modifier - the modifier to check
modifierList - the list of modifiers
Returns:
true if modifier is in the list of modifiers

cleanTypeString

public String cleanTypeString(String type)
Simplifies some classnames by removing package names. Makes generated code better readable. Can be used by wurblets.

Parameters:
type - the full type
Returns:
the shortened type


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de