@@ -147,6 +147,10 @@ public static MessageUnpacker newDefaultUnpacker(byte[] contents, int offset, in
147147 */
148148 public static class PackerConfig
149149 {
150+ /**
151+ * Use String.getBytes() for converting Java Strings that are smaller than this threshold into UTF8.
152+ * Note that this parameter is subject to change.
153+ */
150154 public int smallStringOptimizationThreshold = 512 ;
151155
152156 /**
@@ -155,7 +159,8 @@ public static class PackerConfig
155159 * @param out
156160 * @return
157161 */
158- public MessagePacker newPacker (MessageBufferOutput out ) {
162+ public MessagePacker newPacker (MessageBufferOutput out )
163+ {
159164 return new MessagePacker (out , this );
160165 }
161166
@@ -165,7 +170,8 @@ public MessagePacker newPacker(MessageBufferOutput out) {
165170 * @param out
166171 * @return
167172 */
168- public MessagePacker newPacker (OutputStream out ) {
173+ public MessagePacker newPacker (OutputStream out )
174+ {
169175 return newPacker (new OutputStreamBufferOutput (out ));
170176 }
171177
@@ -175,7 +181,8 @@ public MessagePacker newPacker(OutputStream out) {
175181 * @param channel
176182 * @return
177183 */
178- public MessagePacker newPacker (WritableByteChannel channel ) {
184+ public MessagePacker newPacker (WritableByteChannel channel )
185+ {
179186 return newPacker (new ChannelBufferOutput (channel ));
180187 }
181188
@@ -184,7 +191,8 @@ public MessagePacker newPacker(WritableByteChannel channel) {
184191 *
185192 * @return
186193 */
187- public MessageBufferPacker newBufferPacker () {
194+ public MessageBufferPacker newBufferPacker ()
195+ {
188196 return new MessageBufferPacker (this );
189197 }
190198 }
@@ -194,11 +202,34 @@ public MessageBufferPacker newBufferPacker() {
194202 */
195203 public static class UnpackerConfig
196204 {
197- public boolean allowStringAsBinary = true ;
198- public boolean allowBinaryAsString = true ;
205+ /**
206+ * Allow unpackBinaryHeader to read str format family (default:true)
207+ */
208+ public boolean allowReadingStringAsBinary = true ;
209+
210+ /**
211+ * Allow unpackRawStringHeader and unpackString to read bin format family (default: true)
212+ */
213+ public boolean allowReadingBinaryAsString = true ;
214+
215+ /**
216+ * Action when encountered a malformed input
217+ */
199218 public CodingErrorAction actionOnMalformedString = CodingErrorAction .REPLACE ;
219+
220+ /**
221+ * Action when an unmappable character is found
222+ */
200223 public CodingErrorAction actionOnUnmappableString = CodingErrorAction .REPLACE ;
224+
225+ /**
226+ * unpackString size limit. (default: Integer.MAX_VALUE)
227+ */
201228 public int stringSizeLimit = Integer .MAX_VALUE ;
229+
230+ /**
231+ *
232+ */
202233 public int stringDecoderBufferSize = 8192 ;
203234
204235 /**
@@ -207,7 +238,8 @@ public static class UnpackerConfig
207238 * @param in
208239 * @return
209240 */
210- public MessageUnpacker newUnpacker (MessageBufferInput in ) {
241+ public MessageUnpacker newUnpacker (MessageBufferInput in )
242+ {
211243 return new MessageUnpacker (in , this );
212244 }
213245
@@ -217,7 +249,8 @@ public MessageUnpacker newUnpacker(MessageBufferInput in) {
217249 * @param in
218250 * @return
219251 */
220- public MessageUnpacker newUnpacker (InputStream in ) {
252+ public MessageUnpacker newUnpacker (InputStream in )
253+ {
221254 return newUnpacker (new InputStreamBufferInput (in ));
222255 }
223256
@@ -227,7 +260,8 @@ public MessageUnpacker newUnpacker(InputStream in) {
227260 * @param channel
228261 * @return
229262 */
230- public MessageUnpacker newUnpacker (ReadableByteChannel channel ) {
263+ public MessageUnpacker newUnpacker (ReadableByteChannel channel )
264+ {
231265 return newUnpacker (new ChannelBufferInput (channel ));
232266 }
233267
@@ -237,7 +271,8 @@ public MessageUnpacker newUnpacker(ReadableByteChannel channel) {
237271 * @param contents
238272 * @return
239273 */
240- public MessageUnpacker newUnpacker (byte [] contents ) {
274+ public MessageUnpacker newUnpacker (byte [] contents )
275+ {
241276 return newUnpacker (new ArrayBufferInput (contents ));
242277 }
243278
@@ -247,9 +282,9 @@ public MessageUnpacker newUnpacker(byte[] contents) {
247282 * @param contents
248283 * @return
249284 */
250- public MessageUnpacker newUnpacker (byte [] contents , int offset , int length ) {
285+ public MessageUnpacker newUnpacker (byte [] contents , int offset , int length )
286+ {
251287 return newUnpacker (new ArrayBufferInput (contents , offset , length ));
252288 }
253-
254289 }
255290}
0 commit comments