1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.sf.statcvs.model;
24
25 /**
26 * A concrete subdirectory in a directory tree. To create an instance of
27 * this class, call {@link Directory#createSubdirectory}.
28 *
29 * @author Richard Cyganiak <richard@cyganiak.de>
30 * @version $Id: DirectoryImpl.java,v 1.5 2008/04/02 11:22:16 benoitx Exp $
31 */
32 class DirectoryImpl extends Directory {
33 private final Directory parent;
34 private final String name;
35
36 /**
37 * Use {@link Directory#createSubdirectory} to create instances of
38 * this class!
39 * Creates a new <tt>Directory</tt> with the given parent and name
40 * @param parent the parent directory
41 * @param name the directory's name without path or slashes
42 */
43 DirectoryImpl(final Directory parent, final String name) {
44 this.parent = parent;
45 this.name = name;
46 }
47
48 /**
49 * @see net.sf.statcvs.model.Directory#getName()
50 */
51 public String getName() {
52 return name;
53 }
54
55 /**
56 * @see net.sf.statcvs.model.Directory#getPath()
57 */
58 public String getPath() {
59 return parent.getPath() + name + "/";
60 }
61
62 /**
63 * @see net.sf.statcvs.model.Directory#getParent()
64 */
65 public Directory getParent() {
66 return parent;
67 }
68
69 /**
70 * @see net.sf.statcvs.model.Directory#isRoot()
71 */
72 public boolean isRoot() {
73 return false;
74 }
75
76 /**
77 * @see java.lang.Object#toString()
78 */
79 public String toString() {
80 return "directory " + getPath();
81 }
82
83 /**
84 * @see net.sf.statcvs.model.Directory#getDepth()
85 */
86 public int getDepth() {
87 return parent.getDepth() + 1;
88 }
89 }