01: package org.incava.java;
02:
03: import java.io.*;
04: import java.util.*;
05: import net.sourceforge.pmd.ast.*;
06:
07: /**
08: * Miscellaneous routines for Items.
09: */
10: public class ItemUtil extends SimpleNodeUtil {
11: protected static final int[] ACCESSES = new int[] {
12: JavaParserConstants.PUBLIC, JavaParserConstants.PROTECTED,
13: JavaParserConstants.PRIVATE };
14:
15: /**
16: * Returns the access type, as a string. "package" is the default.
17: */
18: public static String getAccessString(SimpleNode node) {
19: Token tk = getAccess(node);
20: return tk == null ? "package" : tk.image;
21: }
22:
23: /**
24: * Returns the access type, as a token.
25: */
26: public static Token getAccess(SimpleNode node) {
27: for (int ai = 0; ai < ACCESSES.length; ++ai) {
28: int acc = ACCESSES[ai];
29: Token tk = getLeadingToken(node, acc);
30: if (tk != null) {
31: return tk;
32: }
33: }
34: return null;
35: }
36:
37: }
|