1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.vfs2;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22
23
24
25 public class FileInfo {
26
27 String baseName;
28 FileType type;
29 String content;
30 Map<String, FileInfo> children = new HashMap<>();
31 FileInfo parent;
32
33 public FileInfo(final String name, final FileType type) {
34 baseName = name;
35 this.type = type;
36 this.content = null;
37 }
38
39 public FileInfo(final String name, final FileType type, final String content) {
40 baseName = name;
41 this.type = type;
42 this.content = content;
43 }
44
45
46
47
48 public void addChild(final FileInfo child) {
49 children.put(child.baseName, child);
50 child.parent = this;
51 }
52
53
54
55
56 public FileInfo addFile(final String baseName, final String content) {
57 final FileInfonfo.html#FileInfo">FileInfo child = new FileInfo(baseName, FileType.FILE, content);
58 addChild(child);
59 return child;
60 }
61
62
63
64
65 public FileInfo addFolder(final String baseName) {
66 final FileInfonfo.html#FileInfo">FileInfo child = new FileInfo(baseName, FileType.FOLDER, null);
67 addChild(child);
68 return child;
69 }
70
71
72
73
74
75
76 public String getBaseName() {
77 return baseName;
78 }
79
80
81
82
83
84 public Map<String, FileInfo> getChildren() {
85 return children;
86 }
87
88
89
90
91
92
93 public String getContent() {
94 return content;
95 }
96
97 public FileInfo getParent() {
98 return parent;
99 }
100
101
102
103
104
105
106 public FileType getType() {
107 return type;
108 }
109 }