Package org.jlayer.impl
Class LayerWriter
java.lang.Object
org.jlayer.impl.LayerWriter
This class provides the method
writeFiles(),
which is used to create wrapper classes and the related interface and abstract classes.- Author:
- Gerd Kock
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enumprivate static enumprivate static classprivate static enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringBuilderprivate Filerprivate StringBuilderprivate StringBuilderprivate CharSequenceprivate CharSequenceprivate CharSequenceprivate CharSequenceprivate Unitprivate CharSequenceprivate String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidappendActionItemInits(StringBuilder srcCode, String tab, LayerWriter.ParamInfo paramInfo) private voidappendActionItemLocals(StringBuilder srcCode, String tab, LayerWriter.ParamInfo paramInfo) private voidappendALayerConstructors(StringBuilder srcCode, Unit unit, CharSequence unitType, CharSequence ilayerType, CharSequence alayerType, CharSequence layerType, LayerWriter.DimKind dimKind) private voidappendArrayDeclaration(StringBuilder srcCode, LayerWriter.DimKind dimKind, Unit.TypeDescriptor typeDescr) private voidappendChecksBeforeCall(StringBuilder srcCode, Unit.MethodDescriptor mDescr) private voidappendDxMethod(StringBuilder srcCode, Unit.MethodDescriptor mDescr, CharSequence unitType, LayerWriter.DimKind dimKind) private voidappendDxMethods(StringBuilder srcCode, Unit unit, CharSequence unitType, LayerWriter.DimKind dimKind) private voidappendFieldCodeD1(StringBuilder srcCode, Unit unit, CharSequence unitType) private voidappendFieldCodeD2(StringBuilder srcCode, Unit unit, CharSequence unitType) private voidappendFieldCodeD3(StringBuilder srcCode, Unit unit, CharSequence unitType) private voidappendFieldCodeNN(StringBuilder srcCode, Unit unit, CharSequence unitType, CharSequence layerType) private voidappendFieldItems(StringBuilder srcCode, Unit unit, CharSequence unitType, LayerWriter.DimKind dimKind) private voidappendImports(StringBuilder srcCode) private voidappendIndexCode(StringBuilder srcCode, List<String> indexNames, LayerWriter.DimKind dimKind, int no) private voidappendIndexDeclaration(StringBuilder srcCode, LayerWriter.DimKind dimKind) private voidappendLayerConstructors(StringBuilder srcCode, Unit unit, CharSequence unitType, CharSequence ilayerType, CharSequence alayerType, CharSequence layerType, LayerWriter.DimKind dimKind) private voidappendLayerItems(StringBuilder srcCode, LayerWriter.LevelKind levelKind, Unit unit, CharSequence unitType, CharSequence iLayerType, CharSequence aLayerType, CharSequence layerType) private voidappendNNMethods(StringBuilder srcCode, Unit unit, CharSequence unitType) private voidappendSignature(StringBuilder srcCode, CharSequence unitType, Unit.MethodDescriptor mDescr, LayerWriter.DimKind dimKind, String endChar) private voidcreateSourceCode(StringBuilder srcCode) private StringgetArrayType(LayerWriter.DimKind kind, String type) private StringgetDxCall(CharSequence unitType, Unit.MethodDescriptor mDescr, LayerWriter.DimKind dimKind) private StringgetDxCast(LayerWriter.DimKind dimKind) private StringgetLayerTypeName(CharSequence unitType, Unit.TypeDescriptor typeDescr, LayerWriter.DimKind dimKind, LayerWriter.TypeKind typeKind) generates the layer type name for a field, a return type or a parameterprivate Stringprivate StringgetModifiers0(Set<Modifier> modifiers) private StringgetModifiers1(Set<Modifier> modifiers) private StringgetModifiers1F(Set<Modifier> modifiers) private StringgetModifiers2(Set<Modifier> modifiers) private StringgetModifiers2F(Set<Modifier> modifiers) private StringgetModifiers3(Set<Modifier> modifiers) private StringgetParamCalls(String prefix, LayerWriter.ParamInfo paramInfo) private StringgetParamDecls(String prefix, LayerWriter.ParamInfo paramInfo) private LayerWriter.ParamInfogetParamInfo(CharSequence unitType, Unit.MethodDescriptor mDescr, LayerWriter.DimKind dimKind, boolean treatVP) private StringgetRightSide(String methodName, int noOfPars, List<String> paramCalls) private Stringtab(int x) (package private) voidwriteFiles(Element rootElem, Unit nextUnit) is used to write layer classes and corresponding interfaces and abstract classes.
-
Field Details
-
tab0
-
filer
-
packageName
-
rootUnit
-
rootUnitType
-
rootILayerType
-
rootALayerType
-
rootLayerType
-
interfaceCode
-
abstractCode
-
layerCode
-
-
Constructor Details
-
LayerWriter
LayerWriter(ProcessingEnvironment pe)
-
-
Method Details
-
tab
-
writeFiles
is used to write layer classes and corresponding interfaces and abstract classes.If
rootElemrepresents the layer unit classMyUnit.java, the three generated files are:- interface
ILayer_MyUnit_.java - abstract class
ALayer_MyUnit_.java - layer class
Layer_MyUnit_.java
- Parameters:
rootElem- thiselementrepresents a class objectnextUnit- thisunitcontains the results of visiting that class- Throws:
IOException- may be raised while creating the corresponding source file or getting a writer for that file object
- interface
-
createSourceCode
-
appendImports
-
appendLayerItems
private void appendLayerItems(StringBuilder srcCode, LayerWriter.LevelKind levelKind, Unit unit, CharSequence unitType, CharSequence iLayerType, CharSequence aLayerType, CharSequence layerType) -
appendALayerConstructors
private void appendALayerConstructors(StringBuilder srcCode, Unit unit, CharSequence unitType, CharSequence ilayerType, CharSequence alayerType, CharSequence layerType, LayerWriter.DimKind dimKind) -
appendLayerConstructors
private void appendLayerConstructors(StringBuilder srcCode, Unit unit, CharSequence unitType, CharSequence ilayerType, CharSequence alayerType, CharSequence layerType, LayerWriter.DimKind dimKind) -
appendIndexCode
private void appendIndexCode(StringBuilder srcCode, List<String> indexNames, LayerWriter.DimKind dimKind, int no) -
appendFieldCodeD1
-
appendFieldCodeD2
-
appendFieldCodeD3
-
appendFieldCodeNN
private void appendFieldCodeNN(StringBuilder srcCode, Unit unit, CharSequence unitType, CharSequence layerType) -
appendFieldItems
private void appendFieldItems(StringBuilder srcCode, Unit unit, CharSequence unitType, LayerWriter.DimKind dimKind) -
appendDxMethods
private void appendDxMethods(StringBuilder srcCode, Unit unit, CharSequence unitType, LayerWriter.DimKind dimKind) -
appendDxMethod
private void appendDxMethod(StringBuilder srcCode, Unit.MethodDescriptor mDescr, CharSequence unitType, LayerWriter.DimKind dimKind) -
appendNNMethods
-
getParamInfo
private LayerWriter.ParamInfo getParamInfo(CharSequence unitType, Unit.MethodDescriptor mDescr, LayerWriter.DimKind dimKind, boolean treatVP) -
appendSignature
private void appendSignature(StringBuilder srcCode, CharSequence unitType, Unit.MethodDescriptor mDescr, LayerWriter.DimKind dimKind, String endChar) -
appendActionItemInits
private void appendActionItemInits(StringBuilder srcCode, String tab, LayerWriter.ParamInfo paramInfo) -
appendActionItemLocals
private void appendActionItemLocals(StringBuilder srcCode, String tab, LayerWriter.ParamInfo paramInfo) -
appendArrayDeclaration
private void appendArrayDeclaration(StringBuilder srcCode, LayerWriter.DimKind dimKind, Unit.TypeDescriptor typeDescr) -
appendIndexDeclaration
-
appendChecksBeforeCall
-
getModifiers0
-
getModifiers1
-
getModifiers1F
-
getModifiers2
-
getModifiers2F
-
getModifiers3
-
getArrayType
-
getParamDecls
-
getParamCalls
-
getRightSide
-
getLeftSide
-
getDxCast
-
getDxCall
private String getDxCall(CharSequence unitType, Unit.MethodDescriptor mDescr, LayerWriter.DimKind dimKind) -
getLayerTypeName
private String getLayerTypeName(CharSequence unitType, Unit.TypeDescriptor typeDescr, LayerWriter.DimKind dimKind, LayerWriter.TypeKind typeKind) generates the layer type name for a field, a return type or a parameter- Parameters:
unitType- the name of the current unit typetypeDescr- the type of the field, return type or parameter under considerationdimKind- the dimensionality of the current layer type to be generated (D1, D2, D3, NN)typeKind- the kind of type to be generated- Returns:
- the generated layer type
-