Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AbstractFileStringContentStream.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.keywordsearch;
20 
21 import java.io.IOException;
22 import java.io.InputStream;
23 import java.io.InputStreamReader;
24 import java.io.Reader;
25 import java.nio.charset.Charset;
26 
27 import org.openide.util.NbBundle;
29 import org.apache.solr.common.util.ContentStream;
30 import org.sleuthkit.datamodel.AbstractContent;
31 import org.sleuthkit.datamodel.AbstractFile;
32 
36 class AbstractFileStringContentStream implements ContentStream {
37  //input
38 
39  private AbstractFile content;
40  private Charset charset;
41  //converted
42  private InputStream stream;
43  private static Logger logger = Logger.getLogger(AbstractFileStringContentStream.class.getName());
44 
45  public AbstractFileStringContentStream(AbstractFile content, Charset charset, InputStream inputStream) {
46  this.content = content;
47  this.charset = charset;
48  this.stream = inputStream;
49  }
50 
51  public AbstractContent getSourceContent() {
52  return content;
53  }
54 
55  @Override
56  public String getContentType() {
57  return "text/plain;charset=" + charset.name(); //NON-NLS
58  }
59 
60  @Override
61  public String getName() {
62  return content.getName();
63  }
64 
65  @Override
66  public Reader getReader() throws IOException {
67  return new InputStreamReader(stream);
68 
69  }
70 
71  @Override
72  public Long getSize() {
73  //return convertedLength;
74  throw new UnsupportedOperationException(
75  NbBundle.getMessage(this.getClass(), "AbstractFileStringContentStream.getSize.exception.msg"));
76  }
77 
78  @Override
79  public String getSourceInfo() {
80  return NbBundle.getMessage(this.getClass(), "AbstractFileStringContentStream.getSrcInfo.text", content.getId());
81  }
82 
83  @Override
84  public InputStream getStream() throws IOException {
85  return stream;
86  }
87 
88  @Override
89  protected void finalize() throws Throwable {
90  super.finalize();
91 
92  stream.close();
93  }
94 }

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.