@@ -54,34 +54,51 @@ object CopybookParser {
54
54
55
55
case class RecordBoundary (name : String , begin : Int , end : Int )
56
56
57
+
57
58
/**
58
59
* Tokenizes a Cobol Copybook contents and returns the AST.
59
60
*
60
61
* This method accepts arguments that affect only structure of the output AST.
61
62
*
62
- * FILLER fields renaming/removal scenarios can be seen in `ParseCopybookFeaturesSpec.scala`
63
+ * @param copyBookContents A string containing all lines of a copybook
64
+ * @param dropGroupFillers Drop GROUPs marked as fillers from the output AST
65
+ * (the name of this parameter is retained for compatibility, fields won't be actually removed from
66
+ * the AST unless dropFillersFromAst is set to true).
67
+ *
68
+ * When dropGroupFillers is set to true, FILLER fields will retain their names,
69
+ * and 'isFiller() = true' for FILLER GROUPs.
70
+ *
71
+ * When dropGroupFillers is set to false, FILLER fields will be renamed to 'FILLER_1, FILLER_2, ...'
72
+ * to retain uniqueness of names in the output schema.
73
+ *
74
+ * @param dropValueFillers Drop primitive fields marked as fillers from the output AST
75
+ * (the name of this parameter is retained for compatibility, fields won't be actually removed from
76
+ * the AST unless dropFillersFromAst is set to true).
77
+ *
78
+ * When dropValueFillers is set to true, FILLER fields will retain their names,
79
+ * and 'isFiller() = true' for FILLER primitive fields.
80
+ *
81
+ * When dropValueFillers is set to false, FILLER fields will be renamed to 'FILLER_P1, FILLER_P2, ...'
82
+ * to retain uniqueness of names in the output schema.
63
83
*
64
- * @param copyBookContents A string containing all lines of a copybook
65
- * @param giveUniqueNameToGroupFillers If true each FILLER GROUP field will have a unique name that helps retaining it in
66
- * target schemas where column names must be unique. FILLERs become FILLER_1, FILLER_2, etc.
67
- * @param giveUniqueNameToValueFillers If true each FILLER value field will have a unique name that helps retaining it in
68
- * target schemas where column names must be unique. FILLERs become FILLER_P1, FILLER_P2, etc.
69
- * @param dropFillersFromAst If true FILLER fields that are not renamed will be removed from the AST.
70
- * @param commentPolicy Specifies a policy for comments truncation inside a copybook
84
+ * @param commentPolicy Specifies a policy for comments truncation inside a copybook
85
+ * @param dropFillersFromAst If true, fillers are going to be dropped from AST according to dropGroupFillers and dropValueFillers.
86
+ * If false, fillers will remain in the AST, but still can be recognizable by 'isFiller()' method.
71
87
* @return Seq[Group] where a group is a record inside the copybook
72
88
*/
73
89
def parseSimple (copyBookContents : String ,
74
- giveUniqueNameToGroupFillers : Boolean = true ,
75
- giveUniqueNameToValueFillers : Boolean = false ,
76
- dropFillersFromAst : Boolean = false ,
77
- commentPolicy : CommentPolicy = CommentPolicy ()): Copybook = {
90
+ dropGroupFillers : Boolean = false ,
91
+ dropValueFillers : Boolean = true ,
92
+ commentPolicy : CommentPolicy = CommentPolicy (),
93
+ dropFillersFromAst : Boolean = false
94
+ ): Copybook = {
78
95
val copybook = parse(copyBookContents = copyBookContents,
79
- dropGroupFillers = ! giveUniqueNameToGroupFillers ,
80
- dropValueFillers = ! giveUniqueNameToValueFillers ,
96
+ dropGroupFillers = dropGroupFillers ,
97
+ dropValueFillers = dropValueFillers ,
81
98
commentPolicy = commentPolicy)
82
99
83
- if (dropFillersFromAst && (! giveUniqueNameToGroupFillers || ! giveUniqueNameToValueFillers )) {
84
- copybook.dropFillers(! giveUniqueNameToValueFillers, ! giveUniqueNameToGroupFillers )
100
+ if (dropFillersFromAst && (dropGroupFillers || dropValueFillers )) {
101
+ copybook.dropFillers(dropGroupFillers, dropValueFillers )
85
102
} else {
86
103
copybook
87
104
}
0 commit comments