KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > editor > errorstripe > AnnotationTestUtilities


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.editor.errorstripe;
21 import java.util.HashMap JavaDoc;
22 import java.util.Map JavaDoc;
23 import javax.swing.text.BadLocationException JavaDoc;
24 import javax.swing.text.Position JavaDoc;
25 import junit.framework.*;
26 import org.netbeans.editor.AnnotationDesc;
27 import org.netbeans.editor.AnnotationType;
28 import org.netbeans.editor.AnnotationType.Severity;
29 import org.netbeans.editor.AnnotationTypes;
30 import org.netbeans.editor.AnnotationTypes.Loader;
31 import org.netbeans.editor.BaseDocument;
32 import org.netbeans.editor.Utilities;
33
34
35 /**
36  *
37  * @author Jan Lahoda
38  */

39 public class AnnotationTestUtilities extends TestCase {
40     
41     /*package private*/ static final String JavaDoc NAME_TEST_ANNOTATION_DESC1 = "test-annotation-1";
42     /*package private*/ static final String JavaDoc NAME_TEST_ANNOTATION_DESC2 = "test-annotation-2";
43     
44     /*package private*/ static final String JavaDoc SD_TEST_ANNOTATION_DESC1 = "Test1";
45     /*package private*/ static final String JavaDoc SD_TEST_ANNOTATION_DESC2 = "Test2";
46     
47     
48     /*package private*/ static class TestAnnotationDesc1 extends AnnotationDesc {
49         
50         private BaseDocument doc;
51         private Position JavaDoc position;
52         
53         public TestAnnotationDesc1(BaseDocument bd, Position JavaDoc position) {
54             super(position.getOffset(), -1);
55             this.doc = bd;
56             this.position = position;
57         }
58         
59         public String JavaDoc getShortDescription() {
60             return SD_TEST_ANNOTATION_DESC1;
61         }
62
63         public String JavaDoc getAnnotationType() {
64             return NAME_TEST_ANNOTATION_DESC1;
65         }
66
67         public int getOffset() {
68             return position.getOffset();
69         }
70
71         public int getLine() {
72             try {
73                 return Utilities.getLineOffset(doc, getOffset());
74             } catch (BadLocationException JavaDoc e) {
75                 IllegalStateException JavaDoc exc = new IllegalStateException JavaDoc();
76                 
77                 exc.initCause(e);
78                 
79                 throw exc;
80             }
81         }
82         
83     }
84     
85     /*package private*/ static class TestAnnotationDesc2 extends AnnotationDesc {
86         
87         private BaseDocument doc;
88         private Position JavaDoc position;
89         
90         public TestAnnotationDesc2(BaseDocument bd, Position JavaDoc position) {
91             super(position.getOffset(), -1);
92             this.doc = bd;
93             this.position = position;
94         }
95         
96         public String JavaDoc getShortDescription() {
97             return SD_TEST_ANNOTATION_DESC2;
98         }
99
100         public String JavaDoc getAnnotationType() {
101             return NAME_TEST_ANNOTATION_DESC2;
102         }
103
104         public int getOffset() {
105             return position.getOffset();
106         }
107
108         public int getLine() {
109             try {
110                 return Utilities.getLineOffset(doc, getOffset());
111             } catch (BadLocationException JavaDoc e) {
112                 IllegalStateException JavaDoc exc = new IllegalStateException JavaDoc();
113                 
114                 exc.initCause(e);
115                 
116                 throw exc;
117             }
118         }
119         
120     }
121     
122 }
123
Popular Tags