2121import java .io .OutputStream ;
2222import java .io .IOException ;
2323import java .nio .ByteBuffer ;
24-
2524import org .msgpack .template .Template ;
2625import org .msgpack .template .TemplateRegistry ;
27- import org .msgpack .packer .StreamPacker ;
26+ import org .msgpack .packer .Packer ;
2827import org .msgpack .packer .BufferPacker ;
28+ import org .msgpack .packer .MessagePackPacker ;
29+ import org .msgpack .packer .MessagePackBufferPacker ;
2930import org .msgpack .packer .Unconverter ;
30- import org .msgpack .unpacker .StreamUnpacker ;
31+ import org .msgpack .unpacker .Unpacker ;
3132import org .msgpack .unpacker .BufferUnpacker ;
33+ import org .msgpack .unpacker .MessagePackUnpacker ;
34+ import org .msgpack .unpacker .MessagePackBufferUnpacker ;
3235import org .msgpack .unpacker .Converter ;
3336import org .msgpack .type .Value ;
3437
@@ -45,32 +48,36 @@ public MessagePack(MessagePack msgpack) {
4548 }
4649
4750
48- public StreamPacker createStreamPacker (OutputStream stream ) {
49- return new StreamPacker (this , stream );
51+ public Packer createPacker (OutputStream stream ) {
52+ return new MessagePackPacker (this , stream );
5053 }
5154
5255 public BufferPacker createBufferPacker () {
53- return new BufferPacker (this );
56+ return new MessagePackBufferPacker (this );
5457 }
5558
5659 public BufferPacker createBufferPacker (int bufferSize ) {
57- return new BufferPacker (this , bufferSize );
60+ return new MessagePackBufferPacker (this , bufferSize );
61+ }
62+
63+ public Unpacker createUnpacker (InputStream stream ) {
64+ return new MessagePackUnpacker (this , stream );
5865 }
5966
60- public StreamUnpacker createStreamUnpacker ( InputStream stream ) {
61- return new StreamUnpacker ( this , stream );
67+ public BufferUnpacker createBufferUnpacker ( ) {
68+ return new MessagePackBufferUnpacker ( );
6269 }
6370
6471 public BufferUnpacker createBufferUnpacker (byte [] b ) {
65- return new BufferUnpacker ( this ).wrap (b );
72+ return createBufferUnpacker ( ).wrap (b );
6673 }
6774
6875 public BufferUnpacker createBufferUnpacker (byte [] b , int off , int len ) {
69- return new BufferUnpacker ( this ).wrap (b , off , len );
76+ return createBufferUnpacker ( ).wrap (b , off , len );
7077 }
7178
7279 public BufferUnpacker createBufferUnpacker (ByteBuffer bb ) {
73- return new BufferUnpacker ( this ).wrap (bb );
80+ return createBufferUnpacker ( ).wrap (bb );
7481 }
7582
7683
@@ -89,7 +96,7 @@ public void write(OutputStream out, Object v) throws IOException {
8996 }
9097
9198 public <T > void write (OutputStream out , T v , Template <T > tmpl ) throws IOException {
92- StreamPacker pk = createStreamPacker (out );
99+ Packer pk = createPacker (out );
93100 tmpl .write (pk , v );
94101 }
95102
@@ -113,7 +120,7 @@ public Value read(ByteBuffer buf) throws IOException { // TODO IOException
113120 }
114121
115122 public Value read (InputStream in ) throws IOException {
116- return createStreamUnpacker (in ).readValue ();
123+ return createUnpacker (in ).readValue ();
117124 }
118125
119126 public <T > T read (byte [] b , T v ) throws IOException { // TODO IOException
@@ -143,12 +150,12 @@ public <T> T read(ByteBuffer b, Class<T> c) { // TODO IOException
143150
144151 public <T > T read (InputStream in , T v ) throws IOException {
145152 Template <T > tmpl = registry .lookup (v .getClass ());
146- return tmpl .read (createStreamUnpacker (in ), v );
153+ return tmpl .read (createUnpacker (in ), v );
147154 }
148155
149156 public <T > T read (InputStream in , Class <T > c ) throws IOException {
150157 Template <T > tmpl = registry .lookup (c );
151- return tmpl .read (createStreamUnpacker (in ), null );
158+ return tmpl .read (createUnpacker (in ), null );
152159 }
153160
154161 public <T > T convert (Value v , T to ) throws IOException { // TODO IOException
@@ -214,13 +221,13 @@ public static Value unpack(byte[] buffer) throws IOException {
214221
215222 @ Deprecated
216223 public static <T > T unpack (byte [] buffer , Template <T > tmpl ) throws IOException {
217- BufferUnpacker u = new BufferUnpacker (globalMessagePack ).wrap (buffer );
224+ BufferUnpacker u = new MessagePackBufferUnpacker (globalMessagePack ).wrap (buffer );
218225 return tmpl .read (u , null );
219226 }
220227
221228 @ Deprecated
222229 public static <T > T unpack (byte [] buffer , Template <T > tmpl , T to ) throws IOException {
223- BufferUnpacker u = new BufferUnpacker (globalMessagePack ).wrap (buffer );
230+ BufferUnpacker u = new MessagePackBufferUnpacker (globalMessagePack ).wrap (buffer );
224231 return tmpl .read (u , to );
225232 }
226233
@@ -241,12 +248,12 @@ public static Value unpack(InputStream in) throws IOException {
241248
242249 @ Deprecated
243250 public static <T > T unpack (InputStream in , Template <T > tmpl ) throws IOException , MessageTypeException {
244- return tmpl .read (new StreamUnpacker (globalMessagePack , in ), null );
251+ return tmpl .read (new MessagePackUnpacker (globalMessagePack , in ), null );
245252 }
246253
247254 @ Deprecated
248255 public static <T > T unpack (InputStream in , Template <T > tmpl , T to ) throws IOException , MessageTypeException {
249- return (T ) tmpl .read (new StreamUnpacker (globalMessagePack , in ), to );
256+ return (T ) tmpl .read (new MessagePackUnpacker (globalMessagePack , in ), to );
250257 }
251258
252259 @ Deprecated
0 commit comments