/Users/lyon/j4p/src/net/rmi/rmiSynth/lex/LexModif.java
|
1 /**
2 * Class LexModif - class, method, or field modifier
3 * @author Roman Yedokov
4 */
5
6 package net.rmi.rmiSynth.lex;
7
8 public class LexModif {
9 public final int DEFAULT = 0;
10 public final int PUBLIC = 1;
11 public final int PRIVATE = 2;
12 public final int PROTECTED = 3;
13
14 private int visibility;
15 private boolean stat;
16
17 /**
18 * Constructor
19 */
20 public LexModif() {
21 setVisibility(DEFAULT);
22 }
23
24 /**
25 * Set visibility
26 *
27 * @param _visibility default, public, private,
28 * or protected
29 */
30 public void setVisibility(int _visibility) {
31 visibility = _visibility;
32 }
33
34 /**
35 * Get visibility
36 *
37 * @return visibility default, public,
38 * private, or protected
39 */
40 public int getVisibility() {
41 return visibility;
42 }
43
44 /**
45 * If visivility==0
46 *
47 * @return true else return false
48 */
49 public boolean isDefault() {
50 return visibility == DEFAULT ?
51 true :
52 false;
53 }
54
55 /**
56 * If visivility==1
57 *
58 * @return true else return false
59 */
60 public boolean isPublic() {
61 return visibility == PUBLIC ?
62 true :
63 false;
64 }
65
66 /**
67 * If visivility==2
68 *
69 * @return true else return false
70 */
71 public boolean isPrivate() {
72 return visibility == PRIVATE ?
73 true :
74 false;
75 }
76
77 /**
78 * If visivility==3
79 *
80 * @return true else return false
81 */
82 public boolean isProtected() {
83 return visibility == PROTECTED ?
84 true :
85 false;
86 }
87
88 /**
89 * Set static
90 *
91 * @param _static true or false
92 */
93 public void setStatic(boolean _stat) {
94 stat = _stat;
95 }
96
97 /**
98 * If static
99 *
100 * @return stat
101 */
102 public boolean isStatic() {
103 return stat;
104 }
105
106 /**
107 * Returns structure visibility 0-"" 1-public
108 * 2-private 3-protected
109 */
110 public String visibilityToString() {
111 String s;
112 switch (visibility) {
113 case PUBLIC:
114 s = "public ";
115 break;
116 case PRIVATE:
117 s = "private ";
118 break;
119 case PROTECTED:
120 s = "protected ";
121 break;
122 default:
123 s = "";
124 break;
125 }
126 return s;
127 }
128
129 /**
130 * Staticity to string
131 *
132 * @return "static" or empty string
133 */
134 public String statToString() {
135 return isStatic() ?
136 "static " :
137 "";
138 }
139
140 /**
141 * Modifier to string
142 */
143 public String toString() {
144 return visibilityToString() +
145 statToString();
146 }
147 }
148