@@ -86,34 +86,36 @@ class Copybook(val ast: CopybookAST) extends Logging with Serializable {
86
86
val ast = getFieldByName(fieldName)
87
87
ast match {
88
88
case s : Primitive => extractPrimitiveField(s, recordBytes, startOffset)
89
- case _ => throw new IllegalStateException (s " $fieldName is not a primitive field, cannot extract it's value. " )
89
+ case _ => throw new IllegalStateException (s " $fieldName is not a primitive field, cannot extract its value. " )
90
90
}
91
91
}
92
92
93
93
/**
94
- * Set value of a field of the copybook record by name
94
+ * Sets the value of a copybook record field specified by name.
95
95
*
96
96
* Nested field names can contain '.' to identify the exact field.
97
- * If the field name is unique '.' is not required.
97
+ * If the field name is unique, '.' is not required.
98
+ *
99
+ * This method modifies the record in place and does not return a value.
98
100
*
99
101
* @param fieldName A field name
100
102
* @param recordBytes Binary encoded data of the record
101
- * @param startOffset An offset where the record starts in the data (in bytes).
102
- * @return The value of the field
103
+ * @param value The value to set
104
+ * @param startOffset An offset where the record starts in the data (in bytes)
103
105
*/
104
- def setFieldValueByName (fieldName : String , recordBytes : Array [Byte ], value : Any , startOffset : Int = 0 ): Any = {
106
+ def setFieldValueByName (fieldName : String , recordBytes : Array [Byte ], value : Any , startOffset : Int = 0 ): Unit = {
105
107
val ast = getFieldByName(fieldName)
106
108
ast match {
107
109
case s : Primitive => setPrimitiveField(s, recordBytes, value, startOffset)
108
- case _ => throw new IllegalStateException (s " $fieldName is not a primitive field, cannot set it's value. " )
110
+ case _ => throw new IllegalStateException (s " $fieldName is not a primitive field, cannot set its value. " )
109
111
}
110
112
}
111
113
112
114
/**
113
115
* Get the AST object of a field by name.
114
116
*
115
117
* Nested field names can contain '.' to identify the exact field.
116
- * If the field name is unique '.' is not required.
118
+ * If the field name is unique, '.' is not required.
117
119
*
118
120
* @param fieldName A field name
119
121
* @return An AST object of the field. Throws an IllegalStateException if not found of found multiple.
0 commit comments