File tree Expand file tree Collapse file tree
main/java/org/msgpack/core
test/scala/org/msgpack/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package org .msgpack .core ;
22
3+ import java .io .IOException ;
4+
35/**
4- *
6+ * Provides a sequence of MessageBuffers that contains message packed data.
57 */
68public interface MessageBufferInput {
79
10+ /**
11+ * Get a next buffer to read
12+ * @return
13+ * @throws IOException
14+ */
15+ public MessageBuffer next () throws IOException ;
16+
17+ /**
18+ * Close this buffer input
19+ * @throws IOException
20+ */
21+ public void close () throws IOException ;
22+
823
924}
Original file line number Diff line number Diff line change 11package org .msgpack .core ;
22
3+ import java .io .IOException ;
34
45/**
5- *
6+ * Provides a sequence of MessageBuffers for packing the input data
67 */
78public interface MessageBufferOutput {
89
10+ /**
11+ * Retrieves the next buffer for writing message packed data
12+ * @return
13+ * @throws IOException
14+ */
15+ public MessageBuffer next () throws IOException ;
916
17+ /**
18+ * Flush and close this buffer.
19+ * @throws IOException
20+ */
21+ public void close () throws IOException ;
1022
1123
1224}
Original file line number Diff line number Diff line change 11package org .msgpack .core ;
22
3+ import java .io .*;
4+ import java .nio .channels .ReadableByteChannel ;
5+ import java .nio .channels .WritableByteChannel ;
6+ import java .nio .file .Path ;
7+
38/**
4- * Created on 2014/05/05.
9+ * Entry point for creating MessagePacker and MessageUnpacker
510 */
611public class MessagePack {
712
@@ -22,4 +27,44 @@ public int getLength() {
2227 }
2328 }
2429
30+ /**
31+ * Create a new MessagePacker that writes the message packed data to a file
32+ * @param outputFile
33+ * @return MessagePacker
34+ * @throws IOException if the target file cannot be created or opened
35+ */
36+ public static MessagePacker newPacker (File outputFile ) throws IOException {
37+ return newPacker (new FileOutputStream (outputFile ));
38+ }
39+
40+ public static MessagePacker newPacker (OutputStream out ) {
41+ // TODO
42+ return null ;
43+ }
44+
45+ public static MessagePacker newPacker (WritableByteChannel out ) {
46+ // TODO
47+ return null ;
48+ }
49+
50+ /**
51+ * Create a new MessageUnpacker that decodes the message packed data in a file
52+ * @param inputFile
53+ * @return MessageUnpacker
54+ * @throws IOException if the input file is not found
55+ */
56+ public static MessageUnpacker newUnpacker (File inputFile ) throws IOException {
57+ return newUnpacker (new FileInputStream (inputFile ));
58+ }
59+
60+ public static MessageUnpacker newUnpacker (InputStream in ) {
61+ // TODO
62+ return null ;
63+ }
64+
65+ public static MessageUnpacker newUnpacker (ReadableByteChannel in ) {
66+ // TODO
67+ return null ;
68+ }
69+
2570}
Original file line number Diff line number Diff line change @@ -4,13 +4,6 @@ import java.nio.ByteBuffer
44import xerial .core .log .LogLevel
55import scala .util .Random
66
7- object Test {
8- val b = ByteBuffer .allocate(10 )
9- b.getInt(0 )
10-
11- val m = MessageBuffer .newBuffer(10 )
12- m.getInt(0 )
13- }
147
158/**
169 * Created on 2014/05/01.
You can’t perform that action at this time.
0 commit comments