Search in sources :

Example 1 with SourceCode

use of nu.validator.source.SourceCode in project validator by validator.

the class SimpleCommandLineValidator method setErrorHandler.

private static void setErrorHandler() {
    SourceCode sourceCode = validator.getSourceCode();
    ImageCollector imageCollector = new ImageCollector(sourceCode);
    boolean showSource = false;
    if (outputFormat == OutputFormat.TEXT) {
        errorHandler = new MessageEmitterAdapter(filterPattern, sourceCode, showSource, imageCollector, lineOffset, true, new TextMessageEmitter(out, asciiQuotes));
    } else if (outputFormat == OutputFormat.GNU) {
        errorHandler = new MessageEmitterAdapter(filterPattern, sourceCode, showSource, imageCollector, lineOffset, true, new GnuMessageEmitter(out, asciiQuotes));
    } else if (outputFormat == OutputFormat.XML) {
        errorHandler = new MessageEmitterAdapter(filterPattern, sourceCode, showSource, imageCollector, lineOffset, true, new XmlMessageEmitter(new XmlSerializer(out)));
    } else if (outputFormat == OutputFormat.JSON) {
        String callback = null;
        errorHandler = new MessageEmitterAdapter(filterPattern, sourceCode, showSource, imageCollector, lineOffset, true, new JsonMessageEmitter(new nu.validator.json.Serializer(out), callback));
    } else {
        throw new RuntimeException("Bug. Should be unreachable.");
    }
    errorHandler.setErrorsOnly(errorsOnly);
}
Also used : SourceCode(nu.validator.source.SourceCode) MessageEmitterAdapter(nu.validator.messages.MessageEmitterAdapter) TextMessageEmitter(nu.validator.messages.TextMessageEmitter) GnuMessageEmitter(nu.validator.messages.GnuMessageEmitter) ImageCollector(nu.validator.servlet.imagereview.ImageCollector) XmlMessageEmitter(nu.validator.messages.XmlMessageEmitter) JsonMessageEmitter(nu.validator.messages.JsonMessageEmitter) XmlSerializer(nu.validator.htmlparser.sax.XmlSerializer) XmlSerializer(nu.validator.htmlparser.sax.XmlSerializer)

Aggregations

XmlSerializer (nu.validator.htmlparser.sax.XmlSerializer)1 GnuMessageEmitter (nu.validator.messages.GnuMessageEmitter)1 JsonMessageEmitter (nu.validator.messages.JsonMessageEmitter)1 MessageEmitterAdapter (nu.validator.messages.MessageEmitterAdapter)1 TextMessageEmitter (nu.validator.messages.TextMessageEmitter)1 XmlMessageEmitter (nu.validator.messages.XmlMessageEmitter)1 ImageCollector (nu.validator.servlet.imagereview.ImageCollector)1 SourceCode (nu.validator.source.SourceCode)1