1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.vfs.test;
18
19 import org.apache.commons.vfs.FileType;
20
21 import java.util.HashMap;
22 import java.util.Map;
23
24 /***
25 * Info about a file.
26 */
27 class FileInfo
28 {
29 String baseName;
30 FileType type;
31 String content;
32 Map children = new HashMap();
33 FileInfo parent;
34
35 public FileInfo(final String name, final FileType type)
36 {
37 baseName = name;
38 this.type = type;
39 this.content = null;
40 }
41
42 public FileInfo(final String name, final FileType type, final String content)
43 {
44 baseName = name;
45 this.type = type;
46 this.content = content;
47 }
48
49 public FileInfo getParent()
50 {
51 return parent;
52 }
53
54 /***
55 * Adds a child.
56 */
57 public void addChild(final FileInfo child)
58 {
59 children.put(child.baseName, child);
60 child.parent = this;
61 }
62
63 /***
64 * Adds a child file.
65 */
66 public FileInfo addFile(final String baseName, final String content)
67 {
68 final FileInfo child = new FileInfo(baseName, FileType.FILE, content);
69 addChild(child);
70 return child;
71 }
72
73 /***
74 * Adds a child folder.
75 */
76 public FileInfo addFolder(final String baseName)
77 {
78 final FileInfo child = new FileInfo(baseName, FileType.FOLDER, null);
79 addChild(child);
80 return child;
81 }
82 }