View Javadoc

1   /*
2   Karma core - Core of the Karma application
3   Copyright (C) 2004  Toolforge <www.toolforge.nl>
4   
5   This library is free software; you can redistribute it and/or
6   modify it under the terms of the GNU Lesser General Public
7   License as published by the Free Software Foundation; either
8   version 2.1 of the License, or (at your option) any later version.
9   
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  Lesser General Public License for more details.
14  
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19  package nl.toolforge.karma.core.module.template;
20  
21  import java.io.File;
22  
23  /***
24   * Specifies the location of a template and the file where it should be copied to. These
25   * locations need to be absolute paths.
26   *
27   * @author W.H. Schraal
28   */
29  public class FileTemplate {
30  
31    static final String SOURCE_IS_NULL = "The source location of a template may not be null.";
32    static final String TARGET_IS_NULL = "The target location of a template may not be null.";
33  
34    /*** The relative location (including the file name) of the template. */
35    private File source;
36    /*** The absolute target location (including file name) of the template. */
37    private File target;
38  
39    /***
40     * Create a FileTemplate object that specifies the source and target location
41     * of a template. This information can be used to copy a template to a target location.
42     *
43     * @param source  Location of the template. May not be null.
44     * @param target  Target location of the template, relative. May not be null.
45     */
46    public FileTemplate(File source, File target) {
47      if (source == null) {
48        throw new IllegalArgumentException(SOURCE_IS_NULL);
49      }
50      if (target == null) {
51        throw new IllegalArgumentException(TARGET_IS_NULL);
52      }
53      this.source = source;
54      this.target = target;
55    }
56  
57    /***
58     * Retrieve the source location of the template.
59     * @return  Non-null and existing File
60     */
61    public File getSource() {
62      return this.source;
63    }
64  
65    /***
66     * Retrieve the target location of the template.
67     * @return  non-null, but not necessarily existing File.
68     */
69    public File getTarget() {
70      return this.target;
71    }
72  
73  }