01: package com.tagtraum.framework.compiler;
02:
03: import java.util.StringTokenizer;
04:
05: /**
06: *
07: * Date: 04.04.2002
08: * Time: 14:51:55
09: * @author <a href="mailto:hs@tagtraum.com">Hendrik Schreiber</a>
10: * @version 1.1beta1 $Id: SunCompilerErrorMessageParser.java,v 1.5 2005/01/02 22:02:30 hendriks73 Exp $
11: */
12: class SunCompilerErrorMessageParser {
13: public static ErrorMessage[] getErrorMessages(String compilerOutput) {
14: StringTokenizer st = new StringTokenizer(compilerOutput, "^");
15: int count = st.countTokens() - 1;
16: if (count < 0)
17: return new ErrorMessage[0];
18: ErrorMessage[] errorMessages = new ErrorMessage[count];
19: String line;
20: for (int i = 0; i < count; i++) {
21: line = st.nextToken() + "^";
22: int firstColon = line.indexOf(':', 4); // because of WINDOWS paths we start a little later
23: if (firstColon == -1)
24: break;
25: int secondColon = line.indexOf(':', firstColon + 1);
26: if (secondColon == -1)
27: break;
28: int lineNumber = Integer.parseInt(line.substring(
29: firstColon + 1, secondColon));
30: String file = line.substring(0, firstColon).trim();
31: String message = line.substring(secondColon + 2);
32: int pos = line.length() - line.lastIndexOf('\n'); // is this correct?
33: errorMessages[i] = new ErrorMessage(file, message,
34: lineNumber, pos);
35: }
36: return errorMessages;
37: }
38: }
|