KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > incava > java > ItemUtil


1 package org.incava.java;
2
3 import java.io.*;
4 import java.util.*;
5 import net.sourceforge.pmd.ast.*;
6
7
8 /**
9  * Miscellaneous routines for Items.
10  */

11 public class ItemUtil extends SimpleNodeUtil
12 {
13     protected static final int[] ACCESSES = new int[] {
14         JavaParserConstants.PUBLIC,
15         JavaParserConstants.PROTECTED,
16         JavaParserConstants.PRIVATE
17     };
18
19     /**
20      * Returns the access type, as a string. "package" is the default.
21      */

22     public static String JavaDoc getAccessString(SimpleNode node)
23     {
24         Token tk = getAccess(node);
25         return tk == null ? "package" : tk.image;
26     }
27
28     /**
29      * Returns the access type, as a token.
30      */

31     public static Token getAccess(SimpleNode node)
32     {
33         for (int ai = 0; ai < ACCESSES.length; ++ai) {
34             int acc = ACCESSES[ai];
35             Token tk = getLeadingToken(node, acc);
36             if (tk != null) {
37                 return tk;
38             }
39         }
40         return null;
41     }
42
43 }
44
Popular Tags