FileDocCategorySizeDatePackage
JikesOutputParser.javaAPI DocApache Ant 1.705519Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.taskdefs

JikesOutputParser

public class JikesOutputParser extends Object implements ExecuteStreamHandler
Parses output from jikes and passes errors and warnings into the right logging channels of Project.

As of Ant 1.2, this class is considered to be dead code by the Ant developers and is unmaintained. Don't use it.

deprecated
since 1.2. Use Jikes' exit value to detect compilation failure.

Fields Summary
protected org.apache.tools.ant.Task
task
protected boolean
errorFlag
protected int
errors
protected int
warnings
protected boolean
error
protected boolean
emacsMode
protected BufferedReader
br
Constructors Summary
protected JikesOutputParser(org.apache.tools.ant.Task task, boolean emacsMode)
Construct a new Parser object

param
task task in which context we are called
param
emacsMode if true output in emacs mode

        super();

        System.err.println("As of Ant 1.2 released in October 2000, the "
            + "JikesOutputParser class");
        System.err.println("is considered to be dead code by the Ant "
            + "developers and is unmaintained.");
        System.err.println("Don\'t use it!");

        this.task = task;
        this.emacsMode = emacsMode;
    
Methods Summary
protected booleangetErrorFlag()
Indicate if there were errors during the compile

return
if errors occurred

        return errorFlag;
    
private voidlog(java.lang.String line)

       if (!emacsMode) {
           task.log("", (error ? Project.MSG_ERR : Project.MSG_WARN));
       }
       task.log(line, (error ? Project.MSG_ERR : Project.MSG_WARN));
    
private voidparseEmacsOutput(java.io.BufferedReader reader)

       // This may change, if we add advanced parsing capabilities.
       parseStandardOutput(reader);
    
protected voidparseOutput(java.io.BufferedReader reader)
Parse the output of a jikes compiler

param
reader - Reader used to read jikes's output
throws
IOException on error

       if (emacsMode) {
           parseEmacsOutput(reader);
       } else {
           parseStandardOutput(reader);
       }
    
private voidparseStandardOutput(java.io.BufferedReader reader)

        String line;
        String lower;
        // We assume, that every output, jikes does, stands for an error/warning
        // XXX
        // Is this correct?

        // TODO:
        // A warning line, that shows code, which contains a variable
        // error will cause some trouble. The parser should definitely
        // be much better.

        while ((line = reader.readLine()) != null) {
            lower = line.toLowerCase();
            if (line.trim().equals("")) {
                continue;
            }
            if (lower.indexOf("error") != -1) {
                setError(true);
            } else if (lower.indexOf("warning") != -1) {
                setError(false);
                   } else {
                // If we don't know the type of the line
                // and we are in emacs mode, it will be
                // an error, because in this mode, jikes won't
                // always print "error", but sometimes other
                // keywords like "Syntax". We should look for
                // all those keywords.
                if (emacsMode) {
                    setError(true);
                }
            }
            log(line);
        }
    
private voidsetError(boolean err)

        error = err;
        if (error) {
            errorFlag = true;
        }
    
public voidsetProcessErrorStream(java.io.InputStream is)
Ignore.

param
is ignored

    
public voidsetProcessInputStream(java.io.OutputStream os)
Ignore.

param
os ignored

    // CheckStyle:VisibilityModifier ON

             
        
    
public voidsetProcessOutputStream(java.io.InputStream is)
Set the inputstream

param
is the input stream
throws
IOException on error

        br = new BufferedReader(new InputStreamReader(is));
    
public voidstart()
Invokes parseOutput.

throws
IOException on error

        parseOutput(br);
    
public voidstop()
Ignore.