01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.drools.commons.jci.compilers;
19:
20: import org.drools.commons.jci.problems.CompilationProblem;
21: import org.eclipse.jdt.core.compiler.IProblem;
22:
23: /**
24: * Wrapping an Eclipse compiler problem
25: *
26: * @author tcurdt
27: */
28: public final class EclipseCompilationProblem implements
29: CompilationProblem {
30:
31: private final IProblem problem;
32:
33: public EclipseCompilationProblem(final IProblem pProblem) {
34: problem = pProblem;
35: }
36:
37: public boolean isError() {
38: return problem.isError();
39: }
40:
41: public String getFileName() {
42: return new String(problem.getOriginatingFileName());
43: }
44:
45: public int getStartLine() {
46: return problem.getSourceLineNumber();
47: }
48:
49: public int getStartColumn() {
50: return problem.getSourceStart();
51: }
52:
53: public int getEndLine() {
54: return getStartLine();
55: }
56:
57: public int getEndColumn() {
58: return problem.getSourceEnd();
59: }
60:
61: public String getMessage() {
62: return problem.getMessage();
63: }
64:
65: public String toString() {
66: final StringBuffer sb = new StringBuffer();
67: sb.append(getFileName()).append(" (");
68: sb.append(getStartLine());
69: sb.append(":");
70: sb.append(getStartColumn());
71: sb.append(") : ");
72: sb.append(getMessage());
73: return sb.toString();
74: }
75:
76: public int getId() {
77: return problem.getID();
78: }
79:
80: }
|