com.puppycrawl.tools.checkstyle.api.Check Java Examples

The following examples show how to use com.puppycrawl.tools.checkstyle.api.Check. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavadocCheckDefault.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void main(String[] args)
{        
    if (args.length < 2) {
        usage();
    }
    final String header =
        " * <p> By default the check will check the following "
            + args[1] + ":\n";
    final String footer = ".\n * </p>\n";
    final String prefix = " *  {@link TokenTypes#";

    try {
        final Class clazz = Class.forName(args[0]);
        final Check check = (Check) clazz.newInstance();            
        final int[] defaultTokens = check.getDefaultTokens();
        if (defaultTokens.length > 0) {
            final StringBuffer buf = new StringBuffer();
            buf.append(header);
            final ArrayList tokenNames = new ArrayList();
            for (int i = 0; i < defaultTokens.length; i++) {
                tokenNames.add(TokenTypes.getTokenName(defaultTokens[i]));
            }
            Collections.sort(tokenNames);
            final Iterator it = tokenNames.iterator();
            String token = (String) it.next();
            buf.append(prefix + token + " " + token + "}");
            while (it.hasNext()) {
                token = (String) it.next();
                buf.append(",\n" + prefix + token + " " + token + "}");
            }
            buf.append(footer);
            System.out.println(buf);
        }
    }
    catch (Exception ex) {
        ex.printStackTrace();
        System.exit(0);
    }
}
 
Example #2
Source File: JavadocCheckDefault.java    From contribution with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void main(String[] args)
{        
    if (args.length < 2) {
        usage();
    }
    final String header =
        " * <p> By default the check will check the following "
            + args[1] + ":\n";
    final String footer = ".\n * </p>\n";
    final String prefix = " *  {@link TokenTypes#";

    try {
        final Class clazz = Class.forName(args[0]);
        final Check check = (Check) clazz.newInstance();            
        final int[] defaultTokens = check.getDefaultTokens();
        if (defaultTokens.length > 0) {
            final StringBuffer buf = new StringBuffer();
            buf.append(header);
            final ArrayList tokenNames = new ArrayList();
            for (int i = 0; i < defaultTokens.length; i++) {
                tokenNames.add(TokenTypes.getTokenName(defaultTokens[i]));
            }
            Collections.sort(tokenNames);
            final Iterator it = tokenNames.iterator();
            String token = (String) it.next();
            buf.append(prefix + token + " " + token + "}");
            while (it.hasNext()) {
                token = (String) it.next();
                buf.append(",\n" + prefix + token + " " + token + "}");
            }
            buf.append(footer);
            System.out.println(buf);
        }
    }
    catch (Exception ex) {
        ex.printStackTrace();
        System.exit(0);
    }
}