public class CodeGenerator extends Object
Constructor and Description |
---|
CodeGenerator(ClassMetaData meta)
Constructor.
|
CodeGenerator(OpenJPAConfiguration conf,
Class type)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
closeClassBrace(CodeFormat code)
Append the closing code-level brace to the code; this can be
overridden to add code to the bottom of the class.
|
void |
generateCode()
Writes the generated code to the proper directory.
|
protected List |
getClassAnnotations()
Return class-level annotations.
|
protected String |
getClassCode()
Return a code template for the given class, or null to use the standard
system-generated Java code.
|
String |
getCode()
Return the generated code, or null if
generateCode() has not
been called. |
File |
getCodeDirectory()
The directory to write source to.
|
CodeFormat |
getCodeFormat()
The code formatter for the generated Java code.
|
protected String |
getDeclaration(FieldMetaData field)
Return a code template for the declaration of the given field, or null
to use the system-generated default Java code.
|
protected List |
getFieldAnnotations(FieldMetaData field)
Return field-level annotations.
|
protected String |
getFieldCode(FieldMetaData field)
Return a code template for the get/set methods of the given field, or
null to use the system-generated default Java code.
|
File |
getFile()
Return Java file to write to.
|
Set |
getImportPackages()
Returns the set of packages that needs to be imported for this code.
|
protected String |
getInitialValue(FieldMetaData field)
Return code for the initial value for the given field, or null to use
the default generated by the system.
|
ClassMetaData |
getMetaData()
Return metadata for the type being generated.
|
Class |
getType()
Return the type being generated.
|
protected CodeFormat |
newCodeFormat()
Return a copy of the internal code format.
|
protected void |
openClassBrace(CodeFormat code)
Append the opening code-level brace to the code; this can be
overridden to add code to the top of the class.
|
void |
setCodeFormat(CodeFormat format)
Set the code formatter for the generated Java code.
|
void |
setDirectory(File dir)
The directory to write source to.
|
protected boolean |
useGenericCollections()
Whether to use generic collections on one-to-many and many-to-many
relations instead of untyped collections.
|
protected boolean |
usePropertyBasedAccess()
Whether to use property-based access on generated code.
|
void |
writeCode()
Write the generated code to the proper file.
|
void |
writeCode(Writer out)
Write the code to the specified
Writer . |
public CodeGenerator(OpenJPAConfiguration conf, Class type)
public CodeGenerator(ClassMetaData meta)
public File getCodeDirectory()
public void setDirectory(File dir)
public CodeFormat getCodeFormat()
public void setCodeFormat(CodeFormat format)
public Class getType()
public ClassMetaData getMetaData()
public String getCode()
generateCode()
has not
been called.public void generateCode()
public void writeCode() throws IOException
IOException
public void writeCode(Writer out) throws IOException
Writer
.IOException
public Set getImportPackages()
protected void openClassBrace(CodeFormat code)
protected void closeClassBrace(CodeFormat code)
public File getFile()
protected CodeFormat newCodeFormat()
protected String getClassCode()
protected String getInitialValue(FieldMetaData field)
protected String getDeclaration(FieldMetaData field)
protected String getFieldCode(FieldMetaData field)
protected boolean usePropertyBasedAccess()
protected List getClassAnnotations()
protected List getFieldAnnotations(FieldMetaData field)
protected boolean useGenericCollections()
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.