|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.emf.codegen.merge.java.facade.ast.ASTNodeConverter.Converter
org.eclipse.emf.codegen.merge.java.facade.ast.ASTNodeConverter.EnumToTypeConverter
protected class ASTNodeConverter.EnumToTypeConverter
Converter of enum to class.
convert()
Field Summary | |
---|---|
protected org.eclipse.jdt.core.dom.AST |
ast
AST of the source and converted node |
protected ASTJEnum |
astjEnum
Enum to convert to type |
protected java.util.List<JNode> |
enumChildren
List of children of the enum |
protected java.util.Map<ASTJField,java.lang.Integer> |
fieldIndexesMap
Map of fields to their index in the children list |
protected java.util.Map<java.lang.String,ASTJField> |
fieldInitializersMap
Map of initializer values of the fields to fields |
protected ASTJNode<?> |
lastFinalFieldUsed
Last field used in the initializer string of the fields converted from enum constants. |
Constructor Summary | |
---|---|
ASTNodeConverter.EnumToTypeConverter(ASTJEnum astjEnum)
|
Method Summary | |
---|---|
ASTJType |
convert()
Converts enum to the class declaration. |
protected ASTJNode<?> |
convertEnumConstToField(ASTJEnumConstant enumConstant)
Converts enum constant to field. |
protected void |
setFieldInitializer(ASTJField field,
ASTJEnumConstant enumConstant)
Sets field initializer based on arguments and body of enum constant. |
Methods inherited from class org.eclipse.emf.codegen.merge.java.facade.ast.ASTNodeConverter.Converter |
---|
moveChildren, replaceNode |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ASTJEnum astjEnum
protected org.eclipse.jdt.core.dom.AST ast
protected java.util.List<JNode> enumChildren
protected java.util.Map<java.lang.String,ASTJField> fieldInitializersMap
protected java.util.Map<ASTJField,java.lang.Integer> fieldIndexesMap
protected ASTJNode<?> lastFinalFieldUsed
Constructor Detail |
---|
public ASTNodeConverter.EnumToTypeConverter(ASTJEnum astjEnum)
astjEnum
- to convertMethod Detail |
---|
public ASTJType convert()
Name, flags, comment, super interfaces of the class declaration are set from the enum.
All children of the enum are added to the class declaration. Enum constants are converted to public static final fields with initializer value created from arguments and body of enum constant.
convert
in class ASTNodeConverter.Converter
null
if conversion not possiblesetFieldInitializer(ASTJField, ASTJEnumConstant)
protected ASTJNode<?> convertEnumConstToField(ASTJEnumConstant enumConstant)
Resulting field is public static final
. The type of the field is the name of the
enum. Comment of the field is copied from the enum constant.
Initializer value is a call to the constructor of the enum (or converted type) with arguments
taken from enum constant.
enumConstant
- to convert
setFieldInitializer(ASTJField, ASTJEnumConstant)
protected void setFieldInitializer(ASTJField field, ASTJEnumConstant enumConstant)
Initializer string is in the form
new Type ( ArgumentsList ) AnonymousClassDeclaration
where
Type
is the the type of the class
ArgumentsList
is the arguments of the enum constant with some arguments replaced by the names of static final fields.
Arguments that match the initializer value of any public static final field are replaced by the name of that field.
AnonymousClassDeclaration is the body of enum constant
field
- enumConstant
-
|
Copyright 2001-2006 IBM Corporation and others. All Rights Reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |