View Javadoc

1   /***
2    * Fractal Task Codegen Framework
3    * Copyright (C) 2006-2007 STMicroelectronics
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 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   * Contact: fractal@objectweb.org
20   *
21   * Author: Matthieu Leclercq
22   */
23  
24  package org.objectweb.fractal.cecilia.adl.file;
25  
26  import java.io.File;
27  
28  /**
29   * A <code>SourceFile</code> is identified by a signature and contains the
30   * {@link File} object.
31   */
32  public class SourceFile {
33  
34    private final String  signature;
35    private final File    file;
36    private final boolean assemblyFile;
37  
38    /**
39     * Creates a {@link SourceFile}. The created source file is not an assembly
40     * file.
41     * 
42     * @param signature the name of the implementation.
43     * @param sourceFile the source file.
44     */
45    public SourceFile(final String signature, final File sourceFile) {
46      this(signature, sourceFile, false);
47    }
48  
49    /**
50     * Creates a {@link SourceFile}.
51     * 
52     * @param signature the name of the implementation.
53     * @param sourceFile the source file.
54     * @param assemblyFile indicate if the source file is an assembly file.
55     */
56    public SourceFile(final String signature, final File sourceFile,
57        final boolean assemblyFile) {
58      this.signature = signature;
59      this.file = sourceFile;
60      this.assemblyFile = assemblyFile;
61    }
62  
63    /**
64     * @return the signature of this source file.
65     */
66    public String getSignature() {
67      return signature;
68    }
69  
70    /**
71     * @return the file object of this source file.
72     */
73    public File getFile() {
74      return file;
75    }
76  
77    /**
78     * @return <code>true</code> if this source file is an assembly file.
79     */
80    public boolean isAssemblyFile() {
81      return assemblyFile;
82    }
83  
84    @Override
85    public int hashCode() {
86      return signature.hashCode() * file.hashCode();
87    }
88  
89    @Override
90    public boolean equals(final Object obj) {
91      if (!(obj instanceof SourceFile)) return false;
92      return signature.equals(((SourceFile) obj).signature)
93          && file.equals(((SourceFile) obj).file);
94    }
95  
96  }