01: package org.jvnet.mimepull;
02:
03: import java.nio.ByteBuffer;
04:
05: /**
06: * @author Kohsuke Kawaguchi
07: * @author Jitendra Kotamraju
08: */
09: interface Data {
10:
11: /**
12: * size of the chunk given by the parser
13: *
14: * @return size of the chunk
15: */
16: int size();
17:
18: /**
19: * TODO: should the return type be ByteBuffer ??
20: * Return part's partial data. The data is read only.
21: *
22: * @return a byte array which contains {#size()} bytes. The returned
23: * array may be larger than {#size()} bytes and contains data
24: * from offset 0.
25: */
26: byte[] read();
27:
28: /**
29: * Write this partial data to a file
30: *
31: * @param file to which the data needs to be written
32: * @return file pointer before the write operation(at which the data is
33: * written from)
34: */
35: long writeTo(DataFile file);
36:
37: /**
38: * Factory method to create a Data. The implementation could
39: * be file based one or memory based one.
40: *
41: * @param dataHead start of the linked list of data objects
42: * @param buf contains partial content for a part
43: * @return Data
44: */
45: Data createNext(DataHead dataHead, ByteBuffer buf);
46: }
|