19 package org.sleuthkit.autopsy.keywordsearch;
21 import java.io.ByteArrayInputStream;
22 import java.io.IOException;
23 import java.io.InputStream;
24 import java.io.InputStreamReader;
25 import java.io.Reader;
26 import java.nio.charset.Charset;
28 import org.openide.util.NbBundle;
30 import org.apache.solr.common.util.ContentStream;
37 class ByteContentStream
implements ContentStream {
41 private byte[] content;
42 private long contentSize;
43 private AbstractContent aContent;
44 private Charset charset;
46 private InputStream stream;
48 private static Logger logger = Logger.getLogger(ByteContentStream.class.getName());
50 public ByteContentStream(byte [] content,
long contentSize, AbstractContent aContent, Charset charset) {
51 this.content = content;
52 this.aContent = aContent;
53 this.charset = charset;
54 stream =
new ByteArrayInputStream(content, 0, (
int)contentSize);
57 public byte[] getByteContent() {
61 public AbstractContent getSourceContent() {
67 public String getContentType() {
68 return "text/plain;charset=" + charset.name();
72 public String getName() {
73 return aContent.getName();
77 public Reader getReader() throws IOException {
78 return new InputStreamReader(stream);
83 public Long getSize() {
88 public String getSourceInfo() {
89 return NbBundle.getMessage(this.getClass(),
"ByteContentStream.getSrcInfo.text", aContent.getId());
93 public InputStream getStream() throws IOException {
98 protected void finalize() throws Throwable {