1 /* Generated By:JJTree: Do not edit this line. JavaType.java */
2
3 package net.sourceforge.jane.jjtree;
4
5 import org.apache.commons.collections.Predicate;
6
7 public class JavaType extends SimpleNode
8 implements JavaParserConstants
9 {
10
11 private Token startToken;
12 private String arraySuffix;
13
14 public JavaType(int id) {
15 super(id);
16 }
17
18 public JavaType(JavaParser p, int id) {
19 super(p, id);
20 }
21
22 public void jjtOpen() {
23 startToken = parser.getToken(0);
24 }
25
26 public void jjtClose() {
27 TokenEnumeration tokens = new TokenEnumeration(startToken,
28 parser.getToken(0),
29 new Predicate() {
30 public boolean evaluate(Object obj) {
31 return ((Token) obj).kind == LBRACKET;
32 }
33 });
34 int count = 0;
35 while (tokens.hasMoreElements()) {
36 tokens.nextToken();
37 count++;
38 }
39 if (count > 0) {
40 StringBuffer buf = new StringBuffer();
41 for (int i=0; i<count; i++) {
42 buf.append(JJTreeUtils.getNormalizedTokenImage(LBRACKET))
43 .append(JJTreeUtils.getNormalizedTokenImage(RBRACKET));
44 }
45 arraySuffix = buf.toString();
46 } else {
47 arraySuffix = "";
48 }
49 startToken = null;
50 }
51
52 /*** Accept the visitor. **/
53 public Object jjtAccept(JavaParserVisitor visitor, Object data) {
54 return visitor.visit(this, data);
55 }
56
57 /***
58 * Returns <code>true</code> if this type is primitive.
59 */
60 public boolean isPrimitive() {
61 return jjtGetChild(0) instanceof JavaPrimitiveType;
62 }
63
64 /***
65 * Returns the type.
66 */
67 public String getValue()
68 {
69 String value = null;
70 if (isPrimitive())
71 value = ((JavaPrimitiveType) jjtGetChild(0)).getValue();
72 else
73 value = ((JavaName) jjtGetChild(0)).getValue();
74
75 return value + arraySuffix;
76 }
77
78 }
This page was automatically generated by Maven