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
Modifier and TypeClassDescriptionprivate static enum
private static enum
private static class
private static enum
-
Field Summary
Modifier and TypeFieldDescriptionprivate StringBuilder
private Filer
private StringBuilder
private StringBuilder
private CharSequence
private CharSequence
private CharSequence
private CharSequence
private Unit
private CharSequence
private String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
appendActionItemInits
(StringBuilder srcCode, String tab, LayerWriter.ParamInfo paramInfo) private void
appendActionItemLocals
(StringBuilder srcCode, String tab, LayerWriter.ParamInfo paramInfo) private void
appendALayerConstructors
(StringBuilder srcCode, Unit unit, CharSequence unitType, CharSequence ilayerType, CharSequence alayerType, CharSequence layerType, LayerWriter.DimKind dimKind) private void
appendArrayDeclaration
(StringBuilder srcCode, LayerWriter.DimKind dimKind, Unit.TypeDescriptor typeDescr) private void
appendChecksBeforeCall
(StringBuilder srcCode, Unit.MethodDescriptor mDescr) private void
appendDxMethod
(StringBuilder srcCode, Unit.MethodDescriptor mDescr, CharSequence unitType, LayerWriter.DimKind dimKind) private void
appendDxMethods
(StringBuilder srcCode, Unit unit, CharSequence unitType, LayerWriter.DimKind dimKind) private void
appendFieldCodeD1
(StringBuilder srcCode, Unit unit, CharSequence unitType) private void
appendFieldCodeD2
(StringBuilder srcCode, Unit unit, CharSequence unitType) private void
appendFieldCodeD3
(StringBuilder srcCode, Unit unit, CharSequence unitType) private void
appendFieldCodeNN
(StringBuilder srcCode, Unit unit, CharSequence unitType, CharSequence layerType) private void
appendFieldItems
(StringBuilder srcCode, Unit unit, CharSequence unitType, LayerWriter.DimKind dimKind) private void
appendImports
(StringBuilder srcCode) private void
appendIndexCode
(StringBuilder srcCode, List<String> indexNames, LayerWriter.DimKind dimKind, int no) private void
appendIndexDeclaration
(StringBuilder srcCode, LayerWriter.DimKind dimKind) private void
appendLayerConstructors
(StringBuilder srcCode, Unit unit, CharSequence unitType, CharSequence ilayerType, CharSequence alayerType, CharSequence layerType, LayerWriter.DimKind dimKind) private void
appendLayerItems
(StringBuilder srcCode, LayerWriter.LevelKind levelKind, Unit unit, CharSequence unitType, CharSequence iLayerType, CharSequence aLayerType, CharSequence layerType) private void
appendNNMethods
(StringBuilder srcCode, Unit unit, CharSequence unitType) private void
appendSignature
(StringBuilder srcCode, CharSequence unitType, Unit.MethodDescriptor mDescr, LayerWriter.DimKind dimKind, String endChar) private void
createSourceCode
(StringBuilder srcCode) private String
getArrayType
(LayerWriter.DimKind kind, String type) private String
getDxCall
(CharSequence unitType, Unit.MethodDescriptor mDescr, LayerWriter.DimKind dimKind) private String
getDxCast
(LayerWriter.DimKind dimKind) 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 parameterprivate String
private String
getModifiers0
(Set<Modifier> modifiers) private String
getModifiers1
(Set<Modifier> modifiers) private String
getModifiers1F
(Set<Modifier> modifiers) private String
getModifiers2
(Set<Modifier> modifiers) private String
getModifiers2F
(Set<Modifier> modifiers) private String
getModifiers3
(Set<Modifier> modifiers) private String
getParamCalls
(String prefix, LayerWriter.ParamInfo paramInfo) private String
getParamDecls
(String prefix, LayerWriter.ParamInfo paramInfo) private LayerWriter.ParamInfo
getParamInfo
(CharSequence unitType, Unit.MethodDescriptor mDescr, LayerWriter.DimKind dimKind, boolean treatVP) private String
getRightSide
(String methodName, int noOfPars, List<String> paramCalls) private String
tab
(int x) (package private) void
writeFiles
(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
rootElem
represents 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
- thiselement
represents a class objectnextUnit
- thisunit
contains 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
-