Class ClassDefinition
- java.lang.Object
-
- org.eclipse.persistence.internal.codegen.CodeDefinition
-
- org.eclipse.persistence.internal.codegen.ClassDefinition
-
public class ClassDefinition extends CodeDefinition
INTERNAL:Purpose: Model a class for code generation purposes.
- Since:
- TopLink 3.0
- Author:
- James Sutherland
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Vectorattributesstatic intCLASS_TYPEprotected java.util.Vectorimportsprotected java.util.VectorinnerClassesstatic intINTERFACE_TYPEprotected java.util.Vectorinterfacesprotected java.util.Vectormethodsprotected java.lang.StringpackageNameprotected java.lang.StringsuperClassprotected inttype-
Fields inherited from class org.eclipse.persistence.internal.codegen.CodeDefinition
accessLevel, comment, JAVA_LANG_PACKAGE_NAME, JAVA_UTIL_PACKAGE_NAME, name, TOPLINK_INDIRECTION_PACKAGE_NAME
-
-
Constructor Summary
Constructors Constructor Description ClassDefinition()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(AttributeDefinition attribute)voidaddImport(java.lang.String importStatement)The importStatement should be of the form "{packageName}.{shortName or '*'}"voidaddInnerClass(ClassDefinition classDefinition)voidaddInterface(java.lang.String interfaceClassName)voidaddMethod(MethodDefinition method)voidcalculateImports()Parses the class definition, pulls out fully qualified class names, adds imports for them, and un-fully qualifies the class names.booleancontainsMethod(MethodDefinition method)protected java.util.VectorgetAttributes()protected java.util.VectorgetImports()protected java.util.VectorgetInnerClasses()protected java.util.VectorgetInterfaces()protected java.util.VectorgetMethods()java.lang.StringgetPackageName()java.lang.StringgetSuperClass()intgetType()booleanisInterface()protected voidreplaceInterface(java.lang.String oldInterfaceName, java.lang.String newInterfaceName)voidsetPackageName(java.lang.String packageName)voidsetSuperClass(java.lang.String superClass)If the class to be generated is an interface, do not use this method.voidsetType(int type)protected voidsortImports()protected voidsortMethods()voidwrite(CodeGenerator generator)Write the code out to the generator's stream.voidwriteBody(CodeGenerator generator)Write the code out to the generator's stream.-
Methods inherited from class org.eclipse.persistence.internal.codegen.CodeDefinition
adjustTypeName, getAccessLevel, getComment, getName, parseForTypeNames, putTypeNameInMap, setAccessLevel, setComment, setName, toString
-
-
-
-
Field Detail
-
packageName
protected java.lang.String packageName
-
imports
protected java.util.Vector imports
-
type
protected int type
-
CLASS_TYPE
public static final int CLASS_TYPE
- See Also:
- Constant Field Values
-
INTERFACE_TYPE
public static final int INTERFACE_TYPE
- See Also:
- Constant Field Values
-
superClass
protected java.lang.String superClass
-
interfaces
protected java.util.Vector interfaces
-
attributes
protected java.util.Vector attributes
-
methods
protected java.util.Vector methods
-
innerClasses
protected java.util.Vector innerClasses
-
-
Method Detail
-
addAttribute
public void addAttribute(AttributeDefinition attribute)
-
addImport
public void addImport(java.lang.String importStatement)
The importStatement should be of the form "{packageName}.{shortName or '*'}"
-
addInnerClass
public void addInnerClass(ClassDefinition classDefinition)
-
addInterface
public void addInterface(java.lang.String interfaceClassName)
-
addMethod
public void addMethod(MethodDefinition method)
-
calculateImports
public void calculateImports()
Parses the class definition, pulls out fully qualified class names, adds imports for them, and un-fully qualifies the class names. - Assumes that no imports have been previously added. - Assumes that all types have been fully qualified to start. - Will not unqualify ambiguous classes (java.util.Date and java.sql.Date). - Will not add imports for java.lang.* - Will not add imports for classes in the same package. - Will not parse method bodies, but will unqualify types it finds. ?? - Should unqualification occur during writing? That way, reflective definitions could take advantage.
-
containsMethod
public boolean containsMethod(MethodDefinition method)
-
getAttributes
protected java.util.Vector getAttributes()
-
getImports
protected java.util.Vector getImports()
-
getInnerClasses
protected java.util.Vector getInnerClasses()
-
getInterfaces
protected java.util.Vector getInterfaces()
-
getMethods
protected java.util.Vector getMethods()
-
getPackageName
public java.lang.String getPackageName()
-
getSuperClass
public java.lang.String getSuperClass()
-
getType
public int getType()
-
isInterface
public boolean isInterface()
-
replaceInterface
protected void replaceInterface(java.lang.String oldInterfaceName, java.lang.String newInterfaceName)
-
setPackageName
public void setPackageName(java.lang.String packageName)
-
setSuperClass
public void setSuperClass(java.lang.String superClass)
If the class to be generated is an interface, do not use this method. Instead, use addInterface(String) for each interface superclass.
-
setType
public void setType(int type)
-
sortImports
protected void sortImports()
-
sortMethods
protected void sortMethods()
-
write
public void write(CodeGenerator generator)
Write the code out to the generator's stream.- Overrides:
writein classCodeDefinition
-
writeBody
public void writeBody(CodeGenerator generator)
Write the code out to the generator's stream.- Specified by:
writeBodyin classCodeDefinition
-
-