Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.selesse.jxlint.report;
  
  
  import java.io.*;
 import java.util.List;
 import java.util.Map;

Manager of Reporters.

Keeps a mapping of com.selesse.jxlint.model.OutputType and Reporter classes. Can be configured to overwrite reporters, or queried to create a reporter.

To overwrite a reporter, extend a Reporter, implement the appropriate methods, and call this function:

Reporters.setCustomReporter(OutputType.HTML, MyPrettyHtmlReporter.class);
     
This should be done before calling com.selesse.jxlint.Jxlint.parseArgumentsAndDispatch(java.lang.String[]).
 
 public class Reporters {
     private static Map<OutputTypeClass<? extends Reporter>> outputTypeReporterMap = Maps.newHashMap();
     static {
     }
 
     @SuppressWarnings("UnusedDeclaration")
    
Add a custom com.selesse.jxlint.report.Reporter for a particular com.selesse.jxlint.model.OutputType. It will be instantiated using reflection.
 
     public static void setCustomReporter(OutputType outputTypeClass<? extends Reporterreporter) {
         .put(outputTypereporter);
     }

    
Creates the appropriate Reporter given the OutputType.
 
     public static Reporter createReporter(List<LintErrorlintErrorsProgramSettings settingsOutputType outputType,
                                           String outputPaththrows UnableToCreateReportException {
         Reporter reporter = new DefaultReporter(.settingslintErrors);
 
         if (outputType == null) {
             return reporter;
         }
 
         PrintStream out = .;
 
         if (outputType == .) {
             try {
                 out = new PrintStream(new OutputStream() {
                     @Override
                     public void write(int bthrows IOException {
                         // my own little /dev/null
                     }
                 }, false..displayName());
             }
             catch (UnsupportedEncodingException e) {
                 // nothing to do here, why wouldn't UTF-8 be available?
             }
         }
         else {
             if (outputPath != null) {
                 try {
                     out = new PrintStream(new FileOutputStream(outputPath), true..displayName());
                 }
                 catch (FileNotFoundException e) {
                     throw new UnableToCreateReportException(new File(outputPath));
                 }
                 catch (UnsupportedEncodingException e) {
                     // nothing to do here, why wouldn't UTF-8 be available?
                 }
             }
         }
 
         try {
             switch (outputType) {
                 case :
                 case :
                     Class<? extends ReporterreporterType = .get(outputType);
                     Constructor<?> reporterTypeConstructor = reporterType.getConstructor(PrintStream.class,
                             ProgramSettings.classList.class);
                    return (ReporterreporterTypeConstructor.newInstance(outsettingslintErrors);
                case :
                case :
                    return new DefaultReporter(outsettingslintErrors);
            }
        }
        // If there any any exceptions, we default to System.out
        catch (InvocationTargetException ignored) { }
        catch (NoSuchMethodException ignored) { }
        catch (InstantiationException ignored) { }
        catch (IllegalAccessException ignored) { }
        return reporter;
    }
New to GrepCode? Check out our FAQ X