improved PHP parser
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / obfuscator / PHPIdentifier.java
1 package net.sourceforge.phpeclipse.obfuscator;
2
3 /**
4  * Object which holds an PHP identifier name (i.e. class, function, variable,...)
5  *  
6  */
7 public class PHPIdentifier {
8
9   public final static int CLASS = 1;
10   public final static int FUNCTION = 2;
11   public final static int VARIABLE = 3;
12   public final static int METHOD = 4;
13   public final static int DEFINE = 5;
14   public final static int CONSTRUCTOR = 6;
15   public final static int GLOBAL_VARIABLE = 7;
16   public final static int EXTENDS = 8;
17   public final static int IMPLEMENTS = 9;
18
19   private String fIdentifier;
20
21   private int fType;
22
23   public PHPIdentifier(String identifier, int type) {
24     fType = type;
25     fIdentifier = identifier;
26   }
27
28   /*
29    * (non-Javadoc)
30    * 
31    * @see java.lang.Object#equals(java.lang.Object)
32    */
33   public boolean equals(Object obj) {
34     if (!(obj instanceof PHPIdentifier)) {
35       return false;
36     }
37     return ((PHPIdentifier) obj).fType == fType && ((PHPIdentifier) obj).fIdentifier.equals(fIdentifier);
38   }
39
40   public String getIdentifier() {
41     return fIdentifier;
42   }
43
44   public int getType() {
45     return fType;
46   }
47
48   public boolean isClass() {
49     return fType == CLASS;
50   }
51
52   public boolean isFunction() {
53     return fType == FUNCTION;
54   }
55
56   public boolean isVariable() {
57     return fType == VARIABLE;
58   }
59
60   public boolean isMethod() {
61     return fType == METHOD;
62   }
63
64   public boolean isDefine() {
65     return fType == DEFINE;
66   }
67
68   public boolean isGlobalVariable() {
69     return fType == GLOBAL_VARIABLE;
70   }
71   
72   public boolean isConstructor() {
73     return fType == CONSTRUCTOR;
74   }
75
76   public void setIdentifier(String fIdentifier) {
77     this.fIdentifier = fIdentifier;
78   }
79
80   public void setType(int fType) {
81     this.fType = fType;
82   }
83
84   /*
85    * (non-Javadoc)
86    * 
87    * @see java.lang.Object#toString()
88    */
89   public String toString() {
90     switch (fType) {
91       case CLASS :
92         return "class - ";
93       case CONSTRUCTOR :
94         return "constructor - ";
95       case DEFINE :
96         return "define - ";
97       case FUNCTION :
98         return "function - ";
99       case GLOBAL_VARIABLE :
100         return "global variable - ";
101       case METHOD :
102         return "method - ";
103       case VARIABLE :
104         return "variable - ";
105     }
106     return "";
107   }
108
109 }