@@ -58,3 +58,49 @@ for (AsterixDataBlock asterixDataBlock : dataBlocks) {
58
58
}
59
59
}
60
60
```
61
+
62
+ ## How to implement a custom Reserved Field
63
+
64
+ In order to implement a custom reserved AsterixField, you first need to create
65
+ a new class and inherit ReservedAsterixField. Then, you have to add implementations
66
+ for the encode and decode methods, like in the example bellow.
67
+
68
+ ``` java
69
+ public class SomeCustomReservedFiled extends ReservedAsterixField {
70
+ @Override
71
+ public int decode (byte [] input , int offset , int inputLength ) {
72
+ // TODO: add custom logic
73
+ }
74
+
75
+ @Override
76
+ public byte [] encode () {
77
+ // TODO: add custom logic
78
+ }
79
+ }
80
+
81
+ ```
82
+
83
+ Then, you need to create a custom factory for the new custom fields.
84
+
85
+ ``` java
86
+ public class SomeCustomAsterixFieldFactory implements ReservedFieldFactory {
87
+ @Override
88
+ public ReservedAsterixField createSpField () {
89
+ // The SP field will contain the new custom field
90
+ return new SomeCustomReservedFiled ();
91
+ }
92
+
93
+ @Override
94
+ public ReservedAsterixField createReField () {
95
+ // We leave the default implementation
96
+ return new ReservedAsterixField ();
97
+ }
98
+ }
99
+ ```
100
+
101
+ Finally, we have to attach the custom factory to our Cat062Record.
102
+
103
+ ``` java
104
+ ReservedFieldFactory customFieldFactory = new SomeCustomAsterixFieldFactory ();
105
+ Cat062Record cat062Record = new Cat062Record (customFieldFactory);
106
+ ```
0 commit comments