This project has retired. For details please refer to its
Attic page.
ContentStreamImpl xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.chemistry.opencmis.commons.impl.dataobjects;
20
21 import java.io.ByteArrayInputStream;
22 import java.io.InputStream;
23 import java.io.UnsupportedEncodingException;
24 import java.math.BigInteger;
25
26 import org.apache.chemistry.opencmis.commons.data.ContentStream;
27
28
29
30
31 public class ContentStreamImpl extends AbstractExtensionData implements ContentStream {
32
33 private static final long serialVersionUID = 1L;
34
35 private String filename;
36 private BigInteger length;
37 private String mimeType;
38 private transient InputStream stream;
39
40
41
42
43 public ContentStreamImpl() {
44 }
45
46
47
48
49 public ContentStreamImpl(String filename, BigInteger length, String mimetype, InputStream stream) {
50 setLength(length);
51 setMimeType(mimetype);
52 setFileName(filename);
53 setStream(stream);
54 }
55
56
57
58
59 public ContentStreamImpl(String filename, String mimetype, String string) {
60 byte[] bytes;
61 try {
62 bytes = string.getBytes("UTF-8");
63 } catch (UnsupportedEncodingException e) {
64
65 bytes = string.getBytes();
66 }
67 setLength(BigInteger.valueOf(bytes.length));
68 setMimeType(mimetype);
69 setFileName(filename);
70 setStream(new ByteArrayInputStream(bytes));
71 }
72
73 public String getFileName() {
74 return filename;
75 }
76
77 public void setFileName(String filename) {
78 this.filename = filename;
79 }
80
81 public long getLength() {
82 return length == null ? -1 : length.longValue();
83 }
84
85 public BigInteger getBigLength() {
86 return length;
87 }
88
89 public void setLength(BigInteger length) {
90 this.length = length;
91 }
92
93 public String getMimeType() {
94 return mimeType;
95 }
96
97 public void setMimeType(String mimeType) {
98 this.mimeType = mimeType;
99 }
100
101 public InputStream getStream() {
102 return stream;
103 }
104
105 public void setStream(InputStream stream) {
106 this.stream = stream;
107 }
108
109 @Override
110 public String toString() {
111 return "ContentStream [filename=" + filename + ", length=" + length + ", MIME type=" + mimeType
112 + ", has stream=" + (stream != null) + "]" + super.toString();
113 }
114 }