@@ -51,11 +51,6 @@ public void resetResult() {
5151 this .result = null ;
5252 }
5353
54- @ Override
55- public void writeNil () throws IOException {
56- put (ValueFactory .nilValue ());
57- }
58-
5954 @ Override
6055 public void writeBoolean (boolean v ) throws IOException {
6156 put (ValueFactory .booleanValue (v ));
@@ -112,7 +107,13 @@ public void writeString(String s) throws IOException {
112107 }
113108
114109 @ Override
115- public void writeArrayBegin (int size ) throws IOException {
110+ public Packer writeNil () throws IOException {
111+ put (ValueFactory .nilValue ());
112+ return this ;
113+ }
114+
115+ @ Override
116+ public Packer writeArrayBegin (int size ) throws IOException {
116117 if (size == 0 ) {
117118 Value [] array = new Value [size ];
118119 putContainer (ValueFactory .arrayValue ());
@@ -124,10 +125,11 @@ public void writeArrayBegin(int size) throws IOException {
124125 stack .pushArray (size );
125126 values [stack .getDepth ()] = array ;
126127 }
128+ return this ;
127129 }
128130
129131 @ Override
130- public void writeArrayEnd (boolean check ) throws IOException {
132+ public Packer writeArrayEnd (boolean check ) throws IOException {
131133 if (!stack .topIsArray ()) {
132134 throw new MessageTypeException ("writeArrayEnd() is called but writeArrayBegin() is not called" );
133135 }
@@ -145,10 +147,11 @@ public void writeArrayEnd(boolean check) throws IOException {
145147 if (stack .getDepth () <= 0 ) {
146148 this .result = (Value ) values [0 ];
147149 }
150+ return this ;
148151 }
149152
150153 @ Override
151- public void writeMapBegin (int size ) throws IOException {
154+ public Packer writeMapBegin (int size ) throws IOException {
152155 stack .checkCount ();
153156 if (size == 0 ) {
154157 putContainer (ValueFactory .mapValue ());
@@ -160,10 +163,11 @@ public void writeMapBegin(int size) throws IOException {
160163 stack .pushMap (size );
161164 values [stack .getDepth ()] = array ;
162165 }
166+ return this ;
163167 }
164168
165169 @ Override
166- public void writeMapEnd (boolean check ) throws IOException {
170+ public Packer writeMapEnd (boolean check ) throws IOException {
167171 if (!stack .topIsMap ()) {
168172 throw new MessageTypeException ("writeMapEnd() is called but writeMapBegin() is not called" );
169173 }
@@ -181,6 +185,7 @@ public void writeMapEnd(boolean check) throws IOException {
181185 if (stack .getDepth () <= 0 ) {
182186 this .result = (Value ) values [0 ];
183187 }
188+ return this ;
184189 }
185190
186191 @ Override
0 commit comments