KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2005 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  * jgarms@bea.com - initial API and implementation
10  *
11  *******************************************************************************/

12 package org.eclipse.jdt.apt.core.internal.env;
13
14 import org.eclipse.core.resources.IMarker;
15 import org.eclipse.core.runtime.CoreException;
16 import org.eclipse.jdt.apt.core.internal.env.MessagerImpl.Severity;
17
18 /**
19  * Simple container class for attributes of IMarker
20  *
21  */

22 public class MarkerInfo {
23
24     private final int start;
25     private final int end;
26     private final Severity severity;
27     private final String JavaDoc msg;
28     private final int line;
29     
30     
31     public MarkerInfo(final int start,
32                             final int end,
33                             final Severity severity,
34                             final String JavaDoc msg,
35                             final int line)
36     {
37         this.start = start;
38         this.end = end;
39         this.severity = severity;
40         this.msg = msg;
41         this.line = line;
42     }
43     
44     private int getSeverity() {
45         switch (severity) {
46         case ERROR :
47             return IMarker.SEVERITY_ERROR;
48         case WARNING :
49             return IMarker.SEVERITY_WARNING;
50         case INFO :
51             return IMarker.SEVERITY_INFO;
52         }
53         throw new IllegalStateException JavaDoc("Unhandled severity level: " + severity); //$NON-NLS-1$
54
}
55     
56     public boolean isError(){
57         return severity == Severity.ERROR;
58     }
59     
60     /**
61      * Copy this info into the provided marker
62      */

63     public void copyIntoMarker(IMarker marker) throws CoreException {
64         marker.setAttribute(IMarker.CHAR_START, start);
65         marker.setAttribute(IMarker.CHAR_END, end);
66         marker.setAttribute(IMarker.SEVERITY, getSeverity());
67         marker.setAttribute(IMarker.MESSAGE, msg);
68         marker.setAttribute(IMarker.LINE_NUMBER, line);
69     }
70 }
71
Popular Tags