Skip to content

Package: Data

Data

Coverage

1: /*
2: * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Distribution License v. 1.0, which is available at
6: * http://www.eclipse.org/org/documents/edl-v10.php.
7: *
8: * SPDX-License-Identifier: BSD-3-Clause
9: */
10:
11: package org.jvnet.mimepull;
12:
13: import java.nio.ByteBuffer;
14:
15: /**
16: * @author Kohsuke Kawaguchi
17: * @author Jitendra Kotamraju
18: */
19: interface Data {
20:
21: /**
22: * size of the chunk given by the parser
23: *
24: * @return size of the chunk
25: */
26: int size();
27:
28: /**
29: * TODO: should the return type be ByteBuffer ??
30: * Return part's partial data. The data is read only.
31: *
32: * @return a byte array which contains {#size()} bytes. The returned
33: * array may be larger than {#size()} bytes and contains data
34: * from offset 0.
35: */
36: byte[] read();
37:
38: /**
39: * Write this partial data to a file
40: *
41: * @param file to which the data needs to be written
42: * @return file pointer before the write operation(at which the data is
43: * written from)
44: */
45: long writeTo(DataFile file);
46:
47: /**
48: * Factory method to create a Data. The implementation could
49: * be file based one or memory based one.
50: *
51: * @param dataHead start of the linked list of data objects
52: * @param buf contains partial content for a part
53: * @return Data
54: */
55: Data createNext(DataHead dataHead, ByteBuffer buf);
56: }