1) Fixed issue #858: OpenPHPPerspectiveAction error when creating a new PHP project.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / builder / PHPIdentifierLocation.java
1 package net.sourceforge.phpeclipse.builder;
2
3 //import net.sourceforge.phpeclipse.obfuscator.PHPIdentifier;
4
5 /**
6  * 
7  */
8 public class PHPIdentifierLocation extends PHPIdentifier implements Comparable {
9         final public static int UNDEFINED_MATCH = 0;
10
11         final public static int PATTERN_MATCH = 1;
12
13         final public static int EXACT_MATCH = 2;
14
15         private int fMatch;
16
17         private String fClassname;
18
19         private String fFilename;
20
21         private int fOffset;
22
23         private int fPHPDocLength;
24
25         private int fPHPDocOffset;
26
27         private String fUsage;
28
29         public PHPIdentifierLocation(String identifier, int type, String filename) {
30                 this(identifier, type, filename, null);
31         }
32
33         public PHPIdentifierLocation(String identifier, int type, String filename,
34                         String classname) {
35                 super(identifier, type);
36                 fFilename = filename;
37                 fClassname = classname;
38                 fOffset = -1;
39                 fPHPDocLength = -1;
40                 fPHPDocOffset = -1;
41                 fUsage = null;
42         }
43
44         /*
45          * (non-Javadoc)
46          * 
47          * @see java.lang.Object#equals(java.lang.Object)
48          */
49         public boolean equals(Object obj) {
50                 if (!(obj instanceof PHPIdentifierLocation)) {
51                         return false;
52                 }
53                 return super.equals(obj)
54                                 && fFilename.equals(((PHPIdentifierLocation) obj).fFilename);
55         }
56
57         /**
58          * @return
59          */
60         public String getClassname() {
61                 return fClassname;
62         }
63
64         /**
65          * @return
66          */
67         public String getFilename() {
68                 return fFilename;
69         }
70
71         /**
72          * @return
73          */
74         public int getOffset() {
75                 return fOffset;
76         }
77
78         /**
79          * @return
80          */
81         public int getPHPDocLength() {
82                 return fPHPDocLength;
83         }
84
85         /**
86          * @return
87          */
88         public int getPHPDocOffset() {
89                 return fPHPDocOffset;
90         }
91
92         /**
93          * @return
94          */
95         public String getUsage() {
96                 return fUsage;
97         }
98
99         /**
100          * @param string
101          */
102         public void setClassname(String string) {
103                 fClassname = string;
104         }
105
106         /**
107          * @param string
108          */
109         public void setFilename(String string) {
110                 fFilename = string;
111         }
112
113         /**
114          * @param i
115          */
116         public void setOffset(int i) {
117                 fOffset = i;
118         }
119
120         /**
121          * @param i
122          */
123         public void setPHPDocLength(int i) {
124                 fPHPDocLength = i;
125         }
126
127         /**
128          * @param i
129          */
130         public void setPHPDocOffset(int i) {
131                 fPHPDocOffset = i;
132         }
133
134         /**
135          * @param string
136          */
137         public void setUsage(String string) {
138                 fUsage = string;
139         }
140
141         /*
142          * (non-Javadoc)
143          * 
144          * @see java.lang.Object#toString()
145          */
146         public String toString() {
147                 String result = null;
148                 switch (fMatch) {
149                 case UNDEFINED_MATCH:
150                         result = " [";
151                         break;
152                 case PATTERN_MATCH:
153                         result = " [pattern include][";
154                         break;
155                 case EXACT_MATCH:
156                         result = " [exact include][";
157                         break;
158                 default:
159                         result = "";
160                 }
161                 return super.toString() + result + fFilename + "]";
162         }
163
164         /*
165          * (non-Javadoc)
166          * 
167          * @see java.lang.Comparable#compareTo(java.lang.Object)
168          */
169         public int compareTo(Object o) {
170                 PHPIdentifierLocation i = (PHPIdentifierLocation) o;
171                 if (fMatch > i.fMatch) {
172                         return -1;
173                 } else if (fMatch < i.fMatch) {
174                         return 1;
175                 }
176                 return fFilename.compareTo(i.fFilename);
177         }
178
179         /**
180          * @return Returns the match.
181          */
182         public int getMatch() {
183                 return fMatch;
184         }
185
186         /**
187          * @param match
188          *            The match to set.
189          */
190         public void setMatch(int match) {
191                 fMatch = match;
192         }
193 }