Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.selesse.jxlint;
  
 
 import java.util.List;

Entry-point to the jxlint framework. This should be called only after customizing com.selesse.jxlint.report.Reporters (if desired). Pass your program's command line arguments to parseArgumentsAndDispatch(java.lang.String[])}, jxlint will do the rest! Sample implementation is shown below:
     public class MyApplication {
         public static void main (String[] args) {
             Jxlint jxlint = new Jxlint(new MyLintRules(), new MyProgramSettings());
             jxlint.parseArgumentsAndDispatch(args);
         
     }
     }
 
 
 public class Jxlint {
     private static final Logger LOGGER = LoggerFactory.getLogger(Jxlint.class);
 
     private final ProgramSettings programSettings;

    
Initializes jxlint with a set of rules (com.selesse.jxlint.model.rules.LintRules and program settings com.selesse.jxlint.settings.ProgramSettings). This will make the program call java.lang.System.exit(int) under circumstances described in com.selesse.jxlint.model.ExitType.
 
     public Jxlint(LintRules lintRulesProgramSettings programSettings) {
         this(lintRulesprogramSettingstrue);
     }

    
 
     public Jxlint(LintRules lintRulesProgramSettings programSettingsboolean exitAfterReporting) {
         this. = programSettings;
 
         LintRulesImpl.setInstance(lintRules);
         LintRulesImpl.setExitAfterReporting(exitAfterReporting);
         Profiler.setEnabled(false);
     }
 
     public void setCustomCategories(Class<? extends Enum<?>> categories) {
         .debug("Setting custom categories to {}"categories.getCanonicalName());
         Categories.setCategories(categories);
     }

    
Parses the command line arguments, and calls the Dispatcher to decide what to do next. Makes sure that there are no java.lang.Exceptions thrown when parsing the command line arguments.

Parameters:
args Your program's command line arguments.
 
     public void parseArgumentsAndDispatch(String[] args) {
         Profiler.setStartTime(System.currentTimeMillis());
         if (args.length == 0) {
             args = new String[] { "--help" };
         }
 
         // Turn the color on!
         AnsiConsole.systemInstall();
 
         CommandLineParser commandLineParser = new GnuParser();
         Options options = CommandLineOptions.generateJxlintOptions();
 
         try {
             CommandLine commandLine = commandLineParser.parse(optionsargs);
             ProgramOptions programOptions = ProgramOptionExtractor.extractProgramOptions(commandLine);
             .debug("Extracted {} from command line options"programOptions);
             Dispatcher.dispatch(programOptions);
         }
         catch (MissingArgumentException e) {
             ProgramExitter.exitProgramWithMessage("Missing argument for option '--" + e.getOption().getLongOpt() + "'" +
                     ".".);
         }
         catch (AlreadySelectedException e) {
             OptionGroup badOptionGroup = e.getOptionGroup();
            List<StringoptionNames = Lists.newArrayList();
            for (Object option : badOptionGroup.getOptions()) {
                optionNames.add("--" + ((Optionoption).getLongOpt());
            }
            Collections.sort(optionNames);
            ProgramExitter.exitProgramWithMessage("Only one of " + Joiner.on(", ").join(optionNames) +
                    " must be selected.".);
        }
        catch (UnrecognizedOptionException e) {
            ProgramExitter.exitProgramWithMessage("Unrecognized option: " + e.getOption(), .);
        }
        catch (ParseException e) {
            .error("Error parsing command line tokens"e);
            ProgramExitter.exitProgramWithMessage(CommandLineOptions.getHelpMessage(),
                    .);
        }
        // This is done both here, and in ProgramExitter#exitProgramWithMessage.
        // Why? Because we have two possible program flows: we exit with System.exit, or we don't.
        if (Profiler.isEnabled()) {
            Profiler.setStopTime(System.currentTimeMillis());
            Profiler.printProfileReport();
        }
    }
New to GrepCode? Check out our FAQ X