View Javadoc
1   package org.codehaus.plexus.compiler.j2objc;
2   
3   import org.codehaus.plexus.compiler.CompilerMessage;
4   import org.codehaus.plexus.compiler.CompilerMessage.Kind;
5   
6   /**
7    * Handle the output of J2ObjC
8    * 
9    * @author lmaitre
10   */
11  public class DefaultJ2ObjCCompilerParser {
12  
13  	private static String ERROR_PREFIX = "error: ";
14  
15  	private static String CONVERT_PREFIX = "translating ";
16  
17  	private static String TRANSLATION_PREFIX = "Translated ";
18  
19  	/**
20  	 * Parse a line of log, reading the error and translating lines.
21  	 * 
22  	 * @param line
23  	 * @return The compiler message for this line or null if there is no need of
24  	 *         a message.
25  	 */
26  	public static CompilerMessage parseLine(String line) {
27  		String file = null;
28  		boolean error = false;
29  		int startline = -1;
30  		int startcolumn = -1;
31  		int endline = -1;
32  		int endcolumn = -1;
33  		String message;
34  
35  		if (line.startsWith(ERROR_PREFIX)) {
36  			message = line.substring(ERROR_PREFIX.length());
37  			error = true;
38  		} else if (line.startsWith(CONVERT_PREFIX)) {
39  			message = line;
40  		} else if (line.startsWith(TRANSLATION_PREFIX)) {
41  			message = line;
42  		} else {
43  			System.err.println("Unknown output: " + line);
44  
45  			return null;
46  		}
47  
48  		return new CompilerMessage(file, error ? Kind.ERROR : Kind.NOTE,
49  				startline, startcolumn, endline, endcolumn, message);
50  
51  	}
52  
53  }