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  package net.sf.statsvn.input;
21  
22  import net.sf.statcvs.input.NoLineCountException;
23  import net.sf.statcvs.model.Author;
24  import net.sf.statcvs.model.Directory;
25  
26  /**
27   * Test dummy of {@link Builder} for use in
28   * {@link FileBuilderTest}. Returns authors, directories
29   * and LOC counts for a fixed set of arguments.
30   * 
31   * @author Richard Cyganiak <richard@cyganiak.de>
32   * @version $Id: DummyBuilder.java,v 1.3 2004/02/19 23:15:44 cyganiak Exp $
33   */
34  public class DummyBuilder extends Builder {
35  	private final Author author1 = new Author("author1");
36  
37  	private final Author author2 = new Author("author2");
38  
39  	private final Author author3 = new Author("author3");
40  
41  	private final Directory root = Directory.createRoot();
42  
43  	private final Directory dir1 = root.createSubdirectory("dir1");
44  
45  	private final Directory dir2 = root.createSubdirectory("dir2");
46  
47  	private final Directory subdir = dir1.createSubdirectory("subdir");
48  
49  	public DummyBuilder() {
50  		super(null, null, null, null);
51  	}
52  
53  	/* (non-Javadoc)
54  	 * @see net.sf.statsvn.input.Builder#getAuthor(java.lang.String)
55  	 */
56  	public Author getAuthor(final String name) {
57  		if ("author1".equals(name)) {
58  			return author1;
59  		} else if ("author2".equals(name)) {
60  			return author2;
61  		} else if ("author3".equals(name)) {
62  			return author3;
63  		}
64  		throw new IllegalArgumentException(name);
65  	}
66  
67  	/* (non-Javadoc)
68  	 * @see net.sf.statsvn.input.Builder#getDirectory(java.lang.String)
69  	 */
70  	public Directory getDirectory(final String filename) {
71  		if ("file".equals(filename) || "nolinecount".equals(filename)) {
72  			return root;
73  		} else if ("dir1/file".equals(filename)) {
74  			return dir1;
75  		} else if ("dir2/file".equals(filename)) {
76  			return dir2;
77  		} else if ("dir1/subdir/file".equals(filename)) {
78  			return subdir;
79  		}
80  		throw new IllegalArgumentException(filename);
81  	}
82  
83  	/* (non-Javadoc)
84  	 * @see net.sf.statsvn.input.Builder#getLOC(java.lang.String)
85  	 */
86  	public int getLOC(final String filename) throws NoLineCountException {
87  		if ("file".equals(filename)) {
88  			return 100;
89  		} else if ("nolinecount".equals(filename)) {
90  			throw new NoLineCountException();
91  		} else if ("dir1/file".equals(filename)) {
92  			return 10;
93  		} else if ("dir2/file".equals(filename)) {
94  			return 20;
95  		} else if ("dir1/subdir/file".equals(filename)) {
96  			return 500;
97  		}
98  		throw new IllegalArgumentException(filename);
99  	}
100 
101 }