KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > apt > core > internal > env > APTProblem


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 BEA Systems, Inc.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * tyeung@bea.com - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.apt.core.internal.env;
12
13 import org.eclipse.core.resources.IFile;
14 import org.eclipse.jdt.apt.core.internal.AptPlugin;
15 import org.eclipse.jdt.apt.core.internal.env.MessagerImpl.Severity;
16 import org.eclipse.jdt.apt.core.util.EclipseMessager;
17 import org.eclipse.jdt.core.compiler.CategorizedProblem;
18 import org.eclipse.jdt.core.compiler.IProblem;
19
20 class APTProblem extends CategorizedProblem implements IProblem
21 {
22     private static final String JavaDoc[] NO_ARGS = new String JavaDoc[0];
23     private final Severity _severity;
24     private int _startingOffset;
25     private int _endingOffset;
26     private int _line;
27     private IFile _resource;
28     private final String JavaDoc _message;
29     
30     // May be null
31
private final String JavaDoc[] _arguments;
32     
33     APTProblem(final String JavaDoc msg,
34                final Severity severity,
35                final IFile file,
36                final int startingOffset,
37                final int endingOffset,
38                final int line,
39                final String JavaDoc[] arguments){
40         _message = msg;
41         _severity = severity;
42         _startingOffset = startingOffset;
43         _endingOffset = endingOffset;
44         _line = line;
45         _resource = file;
46         _arguments = arguments;
47     }
48
49     public int getID() {
50         // If we have arguments, then we're quick-fixable
51
if (_arguments != null) {
52             return EclipseMessager.APT_QUICK_FIX_PROBLEM_ID;
53         }
54         else {
55             return EclipseMessager.APT_PROBLEM_ID;
56         }
57     }
58     
59     public String JavaDoc[] getArguments() {
60         return _arguments == null ? NO_ARGS : (String JavaDoc[])_arguments.clone();
61     }
62     
63     public String JavaDoc getMessage() {
64         return _message;
65     }
66     
67     public char[] getOriginatingFileName() {
68         return _resource.getName().toCharArray();
69     }
70     
71     public int getSourceStart() {
72         return _startingOffset;
73     }
74     
75     public int getSourceEnd() {
76         return _endingOffset;
77     }
78     
79     public int getSourceLineNumber() {
80         return _line;
81     }
82     
83     public void setSourceStart(int sourceStart) {
84         _startingOffset = sourceStart;
85     }
86     
87     public void setSourceEnd(int sourceEnd) {
88         _endingOffset = sourceEnd;
89     }
90     
91     public void setSourceLineNumber(int lineNumber) {
92         _line = lineNumber;
93     }
94     
95     public boolean isError() {
96         return _severity == Severity.ERROR;
97     }
98     
99     public boolean isWarning() {
100         return _severity == Severity.WARNING;
101     }
102     
103     public String JavaDoc toString()
104     {
105         return _message == null ? "<null message>" : _message ; //$NON-NLS-1$
106
}
107     
108     @Override JavaDoc
109     public int getCategoryID() {
110         // TODO Auto-generated method stub
111
return 0;
112     }
113     
114     @Override JavaDoc
115     public String JavaDoc getMarkerType() {
116         return AptPlugin.APT_COMPILATION_PROBLEM_MARKER;
117     }
118 }
119
Popular Tags