1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.commons.gui.tree;
21
22 import java.io.File;
23
24 public class FileNode extends File
25 {
26
27 boolean fullPath;
28 String label;
29
30 public FileNode(File f, boolean fullPath, String label)
31 {
32 super(f, "");
33 this.fullPath = fullPath;
34 this.label = (label == null) ? "" : label;
35 }
36
37 public FileNode(File f, boolean fullPath)
38 {
39 this(f, fullPath, "");
40 }
41
42 public FileNode(File f)
43 {
44 this(f, false, "");
45 }
46
47 @Override
48 public boolean equals(Object obj)
49 {
50 if (obj instanceof FileNode) {
51 FileNode f = (FileNode)obj;
52 return super.equals(obj) && label.equals(f.label);
53 }
54 else {
55 return super.equals(obj);
56 }
57 }
58
59 @Override
60 public int hashCode()
61 {
62 return label.hashCode() + 31 * super.hashCode();
63 }
64
65 public String getLabel()
66 {
67 return label;
68 }
69
70 public String toString()
71 {
72 if (fullPath) {
73 return getPath() + label;
74 }
75 else {
76 return getName() + label;
77 }
78 }
79 }