1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.rat.document.impl;
21
22 import java.io.ByteArrayInputStream;
23 import java.io.InputStream;
24 import java.io.InputStreamReader;
25 import java.io.Reader;
26 import java.nio.charset.StandardCharsets;
27 import java.util.Collections;
28 import java.util.SortedSet;
29
30 import org.apache.rat.api.Document;
31
32
33
34
35 public class ArchiveEntryDocument extends Document {
36
37
38 private final byte[] contents;
39
40
41
42
43
44
45
46 public ArchiveEntryDocument(final DocumentName outerName, final byte[] contents, final DocumentNameMatcher nameMatcher) {
47 super(outerName, nameMatcher);
48 this.contents = contents;
49 }
50
51 @Override
52 public InputStream inputStream() {
53 return new ByteArrayInputStream(contents);
54 }
55
56 @Override
57 public boolean isDirectory() {
58 return false;
59 }
60
61 @Override
62 public SortedSet<Document> listChildren() {
63 return Collections.emptySortedSet();
64 }
65
66 @Override
67 public Reader reader() {
68 return new InputStreamReader(new ByteArrayInputStream(contents), StandardCharsets.UTF_8);
69 }
70 }