Autopsy  4.1
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-2016 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;
28 import org.apache.solr.common.util.ContentStream;
29 import org.sleuthkit.datamodel.AbstractContent;
30 import org.sleuthkit.datamodel.AbstractFile;
31 
35 class AbstractFileStringContentStream implements ContentStream {
36  //input
37 
38  private final AbstractFile content;
39  private final Charset charset;
40  //converted
41  private final InputStream stream;
42 
43  public AbstractFileStringContentStream(AbstractFile content, Charset charset, InputStream inputStream) {
44  this.content = content;
45  this.charset = charset;
46  this.stream = inputStream;
47  }
48 
49  public AbstractContent getSourceContent() {
50  return content;
51  }
52 
53  @Override
54  public String getContentType() {
55  return "text/plain;charset=" + charset.name(); //NON-NLS
56  }
57 
58  @Override
59  public String getName() {
60  return content.getName();
61  }
62 
63  @Override
64  public Reader getReader() throws IOException {
65  return new InputStreamReader(stream);
66 
67  }
68 
69  @Override
70  public Long getSize() {
71  //return convertedLength;
72  throw new UnsupportedOperationException(
73  NbBundle.getMessage(this.getClass(), "AbstractFileStringContentStream.getSize.exception.msg"));
74  }
75 
76  @Override
77  public String getSourceInfo() {
78  return NbBundle.getMessage(this.getClass(), "AbstractFileStringContentStream.getSrcInfo.text", content.getId());
79  }
80 
81  @Override
82  public InputStream getStream() throws IOException {
83  return stream;
84  }
85 
86  @Override
87  protected void finalize() throws Throwable {
88  super.finalize();
89 
90  stream.close();
91  }
92 }

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.