|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nuiton.eugene.Template<I>
org.nuiton.eugene.Transformer<ObjectModel,O>
org.nuiton.eugene.models.object.ObjectModelTransformer<ObjectModel>
org.nuiton.eugene.java.ObjectModelTransformerToJava
public abstract class ObjectModelTransformerToJava
Created: 28 oct. 2009
| Field Summary | |
|---|---|
protected JavaBuilder |
builder
internal builder |
| Fields inherited from class org.nuiton.eugene.Transformer |
|---|
outputModel, outputProperties, outputTemplate, previousTransformer |
| Fields inherited from class org.nuiton.eugene.Template |
|---|
configuration, excludeTemplates, generatedPackages, model |
| Fields inherited from interface org.nuiton.eugene.TemplateConfiguration |
|---|
PROP_CLASS_LOADER, PROP_DEFAULT_PACKAGE, PROP_ENCODING, PROP_EXCLUDE_TEMPLATES, PROP_GENERATED_PACKAGES, PROP_LAST_MODIFIED_SOURCE, PROP_OVERWRITE, PROP_VERBOSE, PROP_WRITER_REPORT |
| Constructor Summary | |
|---|---|
ObjectModelTransformerToJava()
|
|
| Method Summary | |
|---|---|
void |
addAnnotation(ObjectModelClassifier classifier,
ObjectModelElement element,
String annotation)
|
protected ObjectModelAttribute |
addAttribute(ObjectModelClassifier classifier,
ObjectModelAttribute attribute)
|
protected ObjectModelAttribute |
addAttribute(ObjectModelClassifier classifier,
String name,
Class<?> type,
String value,
ObjectModelModifier... modifiers)
|
ObjectModelAttribute |
addAttribute(ObjectModelClassifier classifier,
String name,
String type)
|
protected ObjectModelAttribute |
addAttribute(ObjectModelClassifier classifier,
String name,
String type,
String value,
ObjectModelModifier... modifiers)
|
ObjectModelOperation |
addBlock(ObjectModelClassifier classifier,
ObjectModelModifier... modifiers)
add an operation to the classifier with the form of a simple block of code. |
void |
addComment(ObjectModelElement element,
String comment)
Adds a comment to the given element. |
protected ObjectModelAttribute |
addConstant(ObjectModelClassifier classifier,
String name,
Class<?> type,
String value,
ObjectModelModifier visibility)
|
protected ObjectModelAttribute |
addConstant(ObjectModelClassifier classifier,
String name,
String type,
String value,
ObjectModelModifier visibility)
|
protected Set<String> |
addConstantsFromDependency(ObjectModelClassifier input,
ObjectModelClassifier output)
Search in input model, for a enumeration dependency named
JavaGeneratorUtil.DEPENDENCIES_CONSTANTS. |
protected ObjectModelOperation |
addConstructor(ObjectModelClass clazz,
ObjectModelModifier visibility)
|
protected ObjectModelOperation |
addConstructor(ObjectModelEnumeration clazz,
ObjectModelModifier visibility)
|
protected void |
addException(ObjectModelOperation operation,
Class<?> exception)
|
protected void |
addException(ObjectModelOperation operation,
String exception)
|
protected void |
addI18n(StringBuilder buffer,
String i18nPrefix,
String suffix)
|
protected void |
addImport(ObjectModelClassifier classifier,
Class<?> imports)
|
protected void |
addImport(ObjectModelClassifier classifier,
ObjectModelClass imports)
|
protected void |
addImport(ObjectModelClassifier classifier,
String imports)
|
ObjectModelClassifier |
addInnerClassifier(ObjectModelClass clazz,
ObjectModelType type,
String name,
ObjectModelModifier... modifiers)
|
protected void |
addInterface(ObjectModelClassifier classifier,
Class<?> interfaceQualifiedName)
|
protected void |
addInterface(ObjectModelClassifier classifier,
String interfaceQualifiedName)
|
protected void |
addLiteral(ObjectModelEnumeration classifier,
String name)
|
protected ObjectModelOperation |
addOperation(ObjectModelClassifier classifier,
ObjectModelOperation operation)
Adds an operation to the given classifier. |
protected ObjectModelOperation |
addOperation(ObjectModelClassifier classifier,
String name,
Class<?> type,
ObjectModelModifier... modifiers)
|
protected ObjectModelOperation |
addOperation(ObjectModelClassifier classifier,
String name,
String type,
ObjectModelModifier... modifiers)
|
protected ObjectModelParameter |
addParameter(ObjectModelOperation operation,
Class<?> type,
String name)
|
protected ObjectModelParameter |
addParameter(ObjectModelOperation operation,
String type,
String name)
|
void |
addStereotype(ObjectModelElement element,
String stereotype)
Add a stereotype to the given element. |
void |
addTagValue(ObjectModelElement element,
String name,
String value)
Adds a tag value to the given element. |
void |
addTagValue(String name,
String value)
Adds a tag value to the model. |
protected ObjectModelAttribute |
cloneAttribute(ObjectModelAttribute source,
ObjectModelClassifier destination,
boolean cloneDocumentation,
ObjectModelModifier... modifiers)
clone a given attribute into a classifier of the output model |
ObjectModelClass |
cloneClass(ObjectModelClass source,
boolean cloneDocumentation)
creates a clone of the given source class in the output model
and clones attributes, inheritence declarations and operations into the
clone |
ObjectModelClassifier |
cloneClassifier(ObjectModelClassifier source,
boolean cloneDocumentation)
creates a clone of the given source classifier in the output
model and clones attributes, inheritence declaration and operations
class-specific, enumeration-specific and interface-specific features
of the given classifier will be present in the clone |
protected void |
cloneClassifier(ObjectModelClassifier source,
ObjectModelClassifier destination,
boolean copyDocumentation)
copy attributes, interfaces declartion and operation of a given classifier into another classifier. |
ObjectModelEnumeration |
cloneEnumeration(ObjectModelEnumeration source,
boolean cloneDocumentation)
creates a clone of the given source enumeration in the output
model and clones attributes, inheritence declaration, operations and
literals into the clone |
ObjectModelInterface |
cloneInterface(ObjectModelInterface source,
boolean cloneDocumentation)
creates a clone of the given source interface in the output model
and clones attributes, inheritence declaration and operations into the
clone |
ObjectModelOperation |
cloneOperation(ObjectModelOperation source,
ObjectModelClassifier destination,
boolean cloneDocumentation,
ObjectModelModifier... modifiers)
Clone the source operation into the destination classifier. |
ObjectModelOperation |
cloneOperationSignature(ObjectModelOperation source,
ObjectModelClassifier destination,
boolean cloneDocumentation,
ObjectModelModifier... modifiers)
Clone the source operation into the destination classifier. |
protected void |
cloneStereotypes(ObjectModelClassifier source,
ObjectModelClassifier destination)
|
protected void |
cloneTagValues(ObjectModelElement source,
ObjectModelElement destination)
Copy all tag values fro the given source to the given
destination. |
protected void |
copyClassifier(ObjectModelClassifier source,
ObjectModelClassifier destination,
boolean copyDocumentation)
Deprecated. since 2.3, prefer use the cloneClass(ObjectModelClass, boolean) method |
protected ObjectModelClass |
createAbstractClass(String name,
String packageName)
|
protected ObjectModelClass |
createClass(String name,
String packageName)
|
ObjectModelEnumeration |
createEnumeration(String name,
String packageName)
|
protected ObjectModelInterface |
createInterface(String name,
String packageName)
|
protected void |
debugOutputModel()
|
protected void |
generateI18nBlock(ObjectModelClassifier input,
ObjectModelClassifier output,
String i18nPrefix)
Generates a static block with I18n keys for each navigable attributes prefixed by the given i18nPrefix. |
String |
getConstantName(String propertyName)
|
String |
getConstantPrefix()
|
protected String |
getConstantPrefix(ObjectModelClassifier input,
String defaultPrefix)
|
protected URL |
getFileInClassPath(String fqn)
|
protected String |
getJavaBeanMethodName(String methodPrefix,
String propertyName)
|
void |
initConstantPrefixFromModel()
Used to initialize constant prefix depends on model tagvalue EugeneTagValues.TAG_CONSTANT_PREFIX. |
protected ObjectModel |
initOutputModel()
Initialization of the Output model. |
protected Template<ObjectModel> |
initOutputTemplate()
Initialization of the Output generator. |
protected boolean |
isInClassPath(ObjectModelClassifier classifier)
Checks if the classifier fully qualified name is in class-path and log a message that fqn will not generated if found |
protected boolean |
isInClassPath(String fqn)
Checks if the given fully qualified name is in class-path and log a message that fqn will not generated if found. |
void |
setConstantPrefix(String constantPrefix)
|
void |
setDocumentation(ObjectModelElement element,
String documentation)
|
void |
setMaxMultiplicity(ObjectModelAttribute attribute,
int multiplicity)
Adds a max multiplicity to the given attribute. |
void |
setMinMultiplicity(ObjectModelAttribute attribute,
int multiplicity)
Adds a min multiplicity to the given attribute. |
void |
setNavigable(ObjectModelAttribute attribute,
boolean navigable)
Adds a navigable flag to the given attribute. |
protected void |
setOperationBody(ObjectModelOperation operation,
String body)
|
protected void |
setSuperClass(ObjectModelClass classifier,
Class<?> superclassQualifiedName)
|
protected void |
setSuperClass(ObjectModelClass classifier,
String superclassQualifiedName)
|
| Methods inherited from class org.nuiton.eugene.models.object.ObjectModelTransformer |
|---|
transform, transformFromClass, transformFromClassifier, transformFromElement, transformFromEnumeration, transformFromInterface, transformFromModel |
| Methods inherited from class org.nuiton.eugene.Transformer |
|---|
applyTemplate, getOutputModel, getOutputProperties, getOutputTemplate, init, initPreviousTransformer, transform |
| Methods inherited from class org.nuiton.eugene.Template |
|---|
getClassLoader, getConfiguration, getEncoding, getExcludeTemplates, getGeneratedPackages, getLastModifiedSource, getModel, getOverwrite, getProperties, getProperty, getProperty, getWriterReport, isOverwrite, isVerbose, setConfiguration, setProperty |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected JavaBuilder builder
| Constructor Detail |
|---|
public ObjectModelTransformerToJava()
| Method Detail |
|---|
protected Template<ObjectModel> initOutputTemplate()
Transformer
initOutputTemplate in class Transformer<ObjectModel,ObjectModel>protected ObjectModel initOutputModel()
Transformer
initOutputModel in class Transformer<ObjectModel,ObjectModel>protected void debugOutputModel()
debugOutputModel in class ObjectModelTransformer<ObjectModel>
protected ObjectModelClass createClass(String name,
String packageName)
public ObjectModelEnumeration createEnumeration(String name,
String packageName)
protected ObjectModelClass createAbstractClass(String name,
String packageName)
protected ObjectModelInterface createInterface(String name,
String packageName)
protected void setSuperClass(ObjectModelClass classifier,
String superclassQualifiedName)
protected void setSuperClass(ObjectModelClass classifier,
Class<?> superclassQualifiedName)
protected void addInterface(ObjectModelClassifier classifier,
String interfaceQualifiedName)
protected void addInterface(ObjectModelClassifier classifier,
Class<?> interfaceQualifiedName)
protected void addImport(ObjectModelClassifier classifier,
String imports)
protected void addImport(ObjectModelClassifier classifier,
ObjectModelClass imports)
protected void addImport(ObjectModelClassifier classifier,
Class<?> imports)
public void addTagValue(String name,
String value)
name - name of the tag valuevalue - value of the tag value
public void addTagValue(ObjectModelElement element,
String name,
String value)
element.
element - the element on which the tag value is attached.name - the name of the tag valuevalue - the value of the tag valuepublic String getConstantName(String propertyName)
protected String getConstantPrefix(ObjectModelClassifier input,
String defaultPrefix)
protected ObjectModelAttribute addConstant(ObjectModelClassifier classifier,
String name,
String type,
String value,
ObjectModelModifier visibility)
throws IllegalArgumentException
IllegalArgumentException
protected ObjectModelAttribute addConstant(ObjectModelClassifier classifier,
String name,
Class<?> type,
String value,
ObjectModelModifier visibility)
throws IllegalArgumentException
IllegalArgumentException
protected ObjectModelAttribute addAttribute(ObjectModelClassifier classifier,
String name,
String type,
String value,
ObjectModelModifier... modifiers)
protected ObjectModelAttribute addAttribute(ObjectModelClassifier classifier,
String name,
Class<?> type,
String value,
ObjectModelModifier... modifiers)
protected ObjectModelAttribute addAttribute(ObjectModelClassifier classifier,
ObjectModelAttribute attribute)
public ObjectModelAttribute addAttribute(ObjectModelClassifier classifier,
String name,
String type)
protected ObjectModelOperation addConstructor(ObjectModelClass clazz,
ObjectModelModifier visibility)
throws IllegalArgumentException
IllegalArgumentException
protected ObjectModelOperation addConstructor(ObjectModelEnumeration clazz,
ObjectModelModifier visibility)
throws IllegalArgumentException
IllegalArgumentException
protected ObjectModelOperation addOperation(ObjectModelClassifier classifier,
String name,
String type,
ObjectModelModifier... modifiers)
protected ObjectModelOperation addOperation(ObjectModelClassifier classifier,
String name,
Class<?> type,
ObjectModelModifier... modifiers)
protected ObjectModelOperation addOperation(ObjectModelClassifier classifier,
ObjectModelOperation operation)
classifier - the classifier on which the operation will be addedoperation - the operation to add
protected void addLiteral(ObjectModelEnumeration classifier,
String name)
protected ObjectModelParameter addParameter(ObjectModelOperation operation,
String type,
String name)
protected ObjectModelParameter addParameter(ObjectModelOperation operation,
Class<?> type,
String name)
protected void addException(ObjectModelOperation operation,
String exception)
protected void addException(ObjectModelOperation operation,
Class<?> exception)
protected void setOperationBody(ObjectModelOperation operation,
String body)
throws IllegalArgumentException
IllegalArgumentException
public ObjectModelClassifier addInnerClassifier(ObjectModelClass clazz,
ObjectModelType type,
String name,
ObjectModelModifier... modifiers)
throws IllegalArgumentException
IllegalArgumentException
public void setDocumentation(ObjectModelElement element,
String documentation)
public void setMinMultiplicity(ObjectModelAttribute attribute,
int multiplicity)
attribute.
attribute - the attribute on which the min multiplicty will be settedmultiplicity - the multiplicity to set
public void setMaxMultiplicity(ObjectModelAttribute attribute,
int multiplicity)
attribute.
attribute - the attribute on which the min multiplicty will be settedmultiplicity - the multiplicity to set
public void setNavigable(ObjectModelAttribute attribute,
boolean navigable)
attribute.
attribute - the attribute on which the navigable flag will be settednavigable - the navigable flag to set
public void addComment(ObjectModelElement element,
String comment)
element.
element - the element on which the comment will be added.comment - the comment to add
public void addAnnotation(ObjectModelClassifier classifier,
ObjectModelElement element,
String annotation)
public ObjectModelOperation addBlock(ObjectModelClassifier classifier,
ObjectModelModifier... modifiers)
classifier - the classifier where the block will be addedmodifiers - modifiers for the block
public void addStereotype(ObjectModelElement element,
String stereotype)
element.
element - the element on which the stereotype will be addedstereotype - the stereotype to add
public ObjectModelOperation cloneOperationSignature(ObjectModelOperation source,
ObjectModelClassifier destination,
boolean cloneDocumentation,
ObjectModelModifier... modifiers)
source operation into the destination classifier.
name, returnType, parameters, exceptions and tagValues will be cloned.
You can specify modifiers for the result operation.
source - operation to clonedestination - classifier where result operation will be addedcloneDocumentation - flag to add documentation if some found in modelmodifiers - extra modifiers
public ObjectModelOperation cloneOperation(ObjectModelOperation source,
ObjectModelClassifier destination,
boolean cloneDocumentation,
ObjectModelModifier... modifiers)
source operation into the destination classifier.
whole signature, tagValues and body code will be cloned. You can specify
modifiers for the result operation.
source - operation to clonedestination - classifier where result operation will be addedcloneDocumentation - flag to add documentation if some found in modelmodifiers - extra modifiers
protected ObjectModelAttribute cloneAttribute(ObjectModelAttribute source,
ObjectModelClassifier destination,
boolean cloneDocumentation,
ObjectModelModifier... modifiers)
source - the original attributedestination - classifier where the clone will be addedcloneDocumentation - flag to add documentation if some found in modelmodifiers - extra modifiers
protected void cloneTagValues(ObjectModelElement source,
ObjectModelElement destination)
source to the given
destination.
source - the source elementdestination - the destination element
protected void cloneStereotypes(ObjectModelClassifier source,
ObjectModelClassifier destination)
source - destination -
@Deprecated
protected void copyClassifier(ObjectModelClassifier source,
ObjectModelClassifier destination,
boolean copyDocumentation)
cloneClass(ObjectModelClass, boolean) method
source - the classifier to clone from the source modeldestination - where to clone the given source onecopyDocumentation - flag to add documentation if some found in model
protected void cloneClassifier(ObjectModelClassifier source,
ObjectModelClassifier destination,
boolean copyDocumentation)
source - the classifier to clone from the source modeldestination - where to clone the given source onecopyDocumentation - flag to add documentation if some found in model
public ObjectModelClass cloneClass(ObjectModelClass source,
boolean cloneDocumentation)
source class in the output model
and clones attributes, inheritence declarations and operations into the
clone
source - the class to clone from the source modelcloneDocumentation - flag to add documentation if some found in model
public ObjectModelInterface cloneInterface(ObjectModelInterface source,
boolean cloneDocumentation)
source interface in the output model
and clones attributes, inheritence declaration and operations into the
clone
source - the interface to clone from the source modelcloneDocumentation - flag to add documentation if some found in model
public ObjectModelEnumeration cloneEnumeration(ObjectModelEnumeration source,
boolean cloneDocumentation)
source enumeration in the output
model and clones attributes, inheritence declaration, operations and
literals into the clone
source - the enumeration to clone from the source modelcloneDocumentation - flag to add documentation if some found in model
public ObjectModelClassifier cloneClassifier(ObjectModelClassifier source,
boolean cloneDocumentation)
source classifier in the output
model and clones attributes, inheritence declaration and operations
class-specific, enumeration-specific and interface-specific features
of the given classifier will be present in the clone
source - the classifier to clone from the source modelcloneDocumentation - flag to add documentation if some found in model
protected Set<String> addConstantsFromDependency(ObjectModelClassifier input,
ObjectModelClassifier output)
input model, for a enumeration dependency named
JavaGeneratorUtil.DEPENDENCIES_CONSTANTS.
If found, add all literals on output model as constants.
You can add a EugeneTagValues.TAG_CONSTANT_PREFIX to your
enumeration to prefix constant names.
input - the input modeloutput - the ouput model
public String getConstantPrefix()
public void setConstantPrefix(String constantPrefix)
protected String getJavaBeanMethodName(String methodPrefix,
String propertyName)
public void initConstantPrefixFromModel()
EugeneTagValues.TAG_CONSTANT_PREFIX. If no tagvalue found, the default
value will be an empty prefix.
protected URL getFileInClassPath(String fqn)
protected void generateI18nBlock(ObjectModelClassifier input,
ObjectModelClassifier output,
String i18nPrefix)
i18nPrefix.
input - the input classifieroutput - the output classifier (to generate)i18nPrefix - the i81n prefix to use
protected void addI18n(StringBuilder buffer,
String i18nPrefix,
String suffix)
protected boolean isInClassPath(ObjectModelClassifier classifier)
classifier - classifier to test
true if fqn of classifier was found in class-path,
false otherwise.protected boolean isInClassPath(String fqn)
fqn - fully qualified name to test
true if fqn was found in class-path,
false otherwise.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||