View Javadoc

1   /*
2   	StatCvs - CVS statistics generation 
3   	Copyright (C) 2002  Lukasz Pekacki <lukasz@pekacki.de>
4   	http://statcvs.sf.net/
5       
6   	This library is free software; you can redistribute it and/or
7   	modify it under the terms of the GNU Lesser General Public
8   	License as published by the Free Software Foundation; either
9   	version 2.1 of the License, or (at your option) any later version.
10  
11  	This library is distributed in the hope that it will be useful,
12  	but WITHOUT ANY WARRANTY; without even the implied warranty of
13  	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  	Lesser General Public License for more details.
15  
16  	You should have received a copy of the GNU Lesser General Public
17  	License along with this library; if not, write to the Free Software
18  	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19      
20  	$RCSfile: DirectoryImpl.java,v $
21  	$Date: 2008/04/02 11:22:16 $
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  }