Top Description Fields Constructors Methods
org.eclipse.persistence.internal.codegen

public Class ClassDefinition

extends CodeDefinition
Class Inheritance
Imports
java.util.Arrays, .Comparator, .Enumeration, .HashMap, .Iterator, .Map, .Set, .TreeSet, .Vector

INTERNAL:

Purpose: Model a class for code generation purposes.

Author
James Sutherland
Since
TopLink 3.0

Field Summary

Modifier and TypeField and Description
protected Vector<AttributeDefinition>
public static final int
protected Vector<String>
protected Vector<ClassDefinition>
public static final int
protected Vector<String>
protected Vector<MethodDefinition>
protected String
protected String
protected int
Inherited from org.eclipse.persistence.internal.codegen.CodeDefinition:
accessLevelcommentJAVA_LANG_PACKAGE_NAMEJAVA_UTIL_PACKAGE_NAMEnameTOPLINK_INDIRECTION_PACKAGE_NAME

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
addImport(String importStatement)

The importStatement should be of the form "{packageName}.{shortName or '*'}"

private void
addImports(Map<String, Set<String>> typeNameMap)

public void
addInnerClass(ClassDefinition classDefinition)

public void
addInterface(String interfaceClassName)

public void
private void
private void
public void
calculateImports()

Parses the class definition, pulls out fully qualified class names, adds imports for them, and un-fully qualifies the class names.

public boolean
protected Vector<AttributeDefinition>
protected Vector<String>
protected Vector<ClassDefinition>
protected Vector<String>
protected Vector<MethodDefinition>
public String
public String
public int
public boolean
protected void
replaceInterface(String oldInterfaceName, String newInterfaceName)

private void
private void
public void
setPackageName(String packageName)

public void
setSuperClass(String superClass)

If the class to be generated is an interface, do not use this method.

public void
setType(int type)

protected void
protected void
public void
write(CodeGenerator generator)

Overrides org.eclipse.persistence.internal.codegen.CodeDefinition.write.

Write the code out to the generator's stream.
public void
writeBody(CodeGenerator generator)

Implements abstract org.eclipse.persistence.internal.codegen.CodeDefinition.writeBody.

Write the code out to the generator's stream.
Inherited from org.eclipse.persistence.internal.codegen.CodeDefinition:
adjustTypeNamegetAccessLevelgetCommentgetNameparseForTypeNamesputTypeNameInMapsetAccessLevelsetCommentsetNametoString

Field Detail

attributesback to summary
protected Vector<AttributeDefinition> attributes
CLASS_TYPEback to summary
public static final int CLASS_TYPE
importsback to summary
protected Vector<String> imports
innerClassesback to summary
protected Vector<ClassDefinition> innerClasses
INTERFACE_TYPEback to summary
public static final int INTERFACE_TYPE
interfacesback to summary
protected Vector<String> interfaces
methodsback to summary
protected Vector<MethodDefinition> methods
packageNameback to summary
protected String packageName
superClassback to summary
protected String superClass
typeback to summary
protected int type

Constructor Detail

ClassDefinitionback to summary
public ClassDefinition()

Method Detail

addAttributeback to summary
public void addAttribute(AttributeDefinition attribute)
addImportback to summary
public void addImport(String importStatement)

The importStatement should be of the form "{packageName}.{shortName or '*'}"

addImportsback to summary
private void addImports(Map<String, Set<String>> typeNameMap)
addInnerClassback to summary
public void addInnerClass(ClassDefinition classDefinition)
addInterfaceback to summary
public void addInterface(String interfaceClassName)
addMethodback to summary
public void addMethod(MethodDefinition method)
addTypeNamesToMapback to summary
private void addTypeNamesToMap(HashMap<String, Set<String>> typeNameMap)
adjustTypeNamesback to summary
private void adjustTypeNames(HashMap<String, Set<String>> typeNameMap)
calculateImportsback to summary
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.

containsMethodback to summary
public boolean containsMethod(MethodDefinition method)
getAttributesback to summary
protected Vector<AttributeDefinition> getAttributes()
getImportsback to summary
protected Vector<String> getImports()
getInnerClassesback to summary
protected Vector<ClassDefinition> getInnerClasses()
getInterfacesback to summary
protected Vector<String> getInterfaces()
getMethodsback to summary
protected Vector<MethodDefinition> getMethods()
getPackageNameback to summary
public String getPackageName()
getSuperClassback to summary
public String getSuperClass()
getTypeback to summary
public int getType()
isInterfaceback to summary
public boolean isInterface()
replaceInterfaceback to summary
protected void replaceInterface(String oldInterfaceName, String newInterfaceName)
setImportsback to summary
private void setImports(Vector<String> imports)
setMethodsback to summary
private void setMethods(Vector<MethodDefinition> methods)
setPackageNameback to summary
public void setPackageName(String packageName)
setSuperClassback to summary
public void setSuperClass(String superClass)

If the class to be generated is an interface, do not use this method. Instead, use addInterface(String) for each interface superclass.

setTypeback to summary
public void setType(int type)
sortImportsback to summary
protected void sortImports()
sortMethodsback to summary
protected void sortMethods()
writeback to summary
public void write(CodeGenerator generator)

Overrides org.eclipse.persistence.internal.codegen.CodeDefinition.write.

Write the code out to the generator's stream.

Annotations
@Override
writeBodyback to summary
public void writeBody(CodeGenerator generator)

Implements abstract org.eclipse.persistence.internal.codegen.CodeDefinition.writeBody.

Write the code out to the generator's stream.

Annotations
@Override