KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > frontend > Source


1 package polyglot.frontend;
2
3 import java.util.Date JavaDoc;
4
5 /** A <code>Source</code> represents a source file. */
6 public class Source
7 {
8     protected String JavaDoc name;
9     protected String JavaDoc path;
10     protected Date JavaDoc lastModified;
11     
12     /**
13      * Indicates if this source was explicitly specified by the user,
14      * or if it a source that has been drawn in to the compilation process
15      * due to a dependency.
16      */

17     protected boolean userSpecified;
18
19     protected Source(String JavaDoc name) {
20         this(name, null, null, false);
21     }
22
23     protected Source(String JavaDoc name, boolean userSpecified) {
24         this(name, null, null, userSpecified);
25     }
26
27     public Source(String JavaDoc name, String JavaDoc path, Date JavaDoc lastModified) {
28         this(name, path, lastModified, false);
29     }
30     
31     public Source(String JavaDoc name, String JavaDoc path, Date JavaDoc lastModified, boolean userSpecified) {
32     this.name = name;
33         this.path = path;
34     this.lastModified = lastModified;
35         this.userSpecified = userSpecified;
36     }
37
38     public boolean equals(Object JavaDoc o) {
39     if (o instanceof Source) {
40         Source s = (Source) o;
41         return name.equals(s.name) && path.equals(s.path);
42     }
43
44     return false;
45     }
46
47     public int hashCode() {
48     return path.hashCode() + name.hashCode();
49     }
50
51     /** The name of the source file. */
52     public String JavaDoc name() {
53     return name;
54     }
55
56     /** The name of the source file. */
57     public String JavaDoc path() {
58     return path;
59     }
60
61     /** Return the date the source file was last modified. */
62     public Date JavaDoc lastModified() {
63     return lastModified;
64     }
65
66     public String JavaDoc toString() {
67     return path;
68     }
69     
70     public void setUserSpecified(boolean userSpecified) {
71         this.userSpecified = userSpecified;
72     }
73     
74     public boolean userSpecified() {
75         return userSpecified;
76     }
77 }
78
Popular Tags