Module org.eclipse.persistence.core
Class ClassDefinition
java.lang.Object
org.eclipse.persistence.internal.codegen.CodeDefinition
org.eclipse.persistence.internal.codegen.ClassDefinition
INTERNAL:
Purpose: Model a class for code generation purposes.
- Since:
- TopLink 3.0
-
Field Summary
Modifier and TypeFieldDescriptionprotected Vector
<AttributeDefinition> static final int
protected Vector
<ClassDefinition> static final int
protected Vector
<MethodDefinition> protected String
protected String
protected int
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttribute
(AttributeDefinition attribute) void
The importStatement should be of the form "{packageName}.{shortName or '*'}"void
addInnerClass
(ClassDefinition classDefinition) void
addInterface
(String interfaceClassName) void
addMethod
(MethodDefinition method) void
Parses the class definition, pulls out fully qualified class names, adds imports for them, and un-fully qualifies the class names.boolean
containsMethod
(MethodDefinition method) protected Vector
<AttributeDefinition> protected Vector
<ClassDefinition> protected Vector
<MethodDefinition> int
getType()
boolean
protected void
replaceInterface
(String oldInterfaceName, String newInterfaceName) void
setPackageName
(String packageName) void
setSuperClass
(String superClass) If the class to be generated is an interface, do not use this method.void
setType
(int type) protected void
protected void
void
write
(CodeGenerator generator) Write the code out to the generator's stream.void
writeBody
(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 Details
-
packageName
-
imports
-
type
protected int type -
CLASS_TYPE
public static final int CLASS_TYPE- See Also:
-
INTERFACE_TYPE
public static final int INTERFACE_TYPE- See Also:
-
superClass
-
interfaces
-
attributes
-
methods
-
innerClasses
-
-
Constructor Details
-
ClassDefinition
public ClassDefinition()
-
-
Method Details
-
addAttribute
-
addImport
The importStatement should be of the form "{packageName}.{shortName or '*'}" -
addInnerClass
-
addInterface
-
addMethod
-
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
-
getAttributes
-
getImports
-
getInnerClasses
-
getInterfaces
-
getMethods
-
getPackageName
-
getSuperClass
-
getType
public int getType() -
isInterface
public boolean isInterface() -
replaceInterface
-
setPackageName
-
setSuperClass
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
Write the code out to the generator's stream.- Overrides:
write
in classCodeDefinition
-
writeBody
Write the code out to the generator's stream.- Specified by:
writeBody
in classCodeDefinition
-