KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > spi > editor > hints > ErrorDescriptionFactory


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 package org.netbeans.spi.editor.hints;
20
21 import java.util.List JavaDoc;
22 import javax.swing.text.Document JavaDoc;
23 import javax.swing.text.Position JavaDoc;
24 import org.netbeans.modules.editor.hints.HintsControllerImpl;
25 import org.netbeans.modules.editor.hints.StaticFixList;
26 import org.openide.filesystems.FileObject;
27 import org.openide.loaders.DataObject;
28 import org.openide.text.Line;
29
30 /**
31  *
32  * @author Jan Lahoda
33  */

34 public class ErrorDescriptionFactory {
35
36     /** Creates a new instance of ErrorDescriptionFactory */
37     private ErrorDescriptionFactory() {
38     }
39
40     /**Should be called inside document read lock to assure consistency
41      */

42     public static ErrorDescription createErrorDescription(Severity severity, String JavaDoc description, Document JavaDoc doc, int lineNumber) {
43         return createErrorDescription(severity, description, new StaticFixList(), doc, lineNumber);
44     }
45     
46     /**Should be called inside document read lock to assure consistency
47      */

48     public static ErrorDescription createErrorDescription(Severity severity, String JavaDoc description, List JavaDoc<Fix> fixes, Document JavaDoc doc, int lineNumber) {
49         return createErrorDescription(severity, description, new StaticFixList(fixes), doc, lineNumber);
50     }
51     
52     /**Should be called inside document read lock to assure consistency
53      */

54     public static ErrorDescription createErrorDescription(Severity severity, String JavaDoc description, LazyFixList fixes, Document JavaDoc doc, int lineNumber) {
55         DataObject od = (DataObject) doc.getProperty(Document.StreamDescriptionProperty);
56         FileObject file = od != null ? od.getPrimaryFile() : null;
57         
58         return new ErrorDescription(file, description, severity, fixes, HintsControllerImpl.fullLine(doc, lineNumber));
59     }
60     
61     /**Acquires read lock on the provided document to assure consistency
62      */

63     public static ErrorDescription createErrorDescription(Severity severity, String JavaDoc description, Document JavaDoc doc, Position JavaDoc start, Position JavaDoc end) {
64         return createErrorDescription(severity, description, new StaticFixList(), doc, start, end);
65     }
66
67     /**Acquires read lock on the provided document to assure consistency
68      */

69     public static ErrorDescription createErrorDescription(Severity severity, String JavaDoc description, List JavaDoc<Fix> fixes, Document JavaDoc doc, Position JavaDoc start, Position JavaDoc end) {
70         return createErrorDescription(severity, description, new StaticFixList(fixes), doc, start, end);
71     }
72     
73     /**Acquires read lock on the provided document to assure consistency
74      */

75     public static ErrorDescription createErrorDescription(Severity severity, String JavaDoc description, LazyFixList fixes, Document JavaDoc doc, Position JavaDoc start, Position JavaDoc end) {
76         DataObject od = (DataObject) doc.getProperty(Document.StreamDescriptionProperty);
77         FileObject file = od != null ? od.getPrimaryFile() : null;
78         
79         return new ErrorDescription(file, description, severity, fixes, HintsControllerImpl.linePart(doc, start, end));
80     }
81
82     /**Should be called inside document read lock to assure consistency
83      */

84     public static ErrorDescription createErrorDescription(Severity severity, String JavaDoc description, FileObject file, int start, int end) {
85         return createErrorDescription(severity, description, new StaticFixList(), file, start, end);
86     }
87
88     /**Should be called inside document read lock to assure consistency
89      */

90     public static ErrorDescription createErrorDescription(Severity severity, String JavaDoc description, List JavaDoc<Fix> fixes, FileObject file, int start, int end) {
91         return createErrorDescription(severity, description, new StaticFixList(fixes), file, start, end);
92     }
93     
94     /**Should be called inside document read lock to assure consistency
95      */

96     public static ErrorDescription createErrorDescription(Severity severity, String JavaDoc description, LazyFixList fixes, FileObject file, int start, int end) {
97         return new ErrorDescription(file, description, severity, fixes, HintsControllerImpl.linePart(file, start, end));
98     }
99
100     public static LazyFixList lazyListForFixes(List JavaDoc<Fix> fixes) {
101         return new StaticFixList(fixes);
102     }
103     
104     public static LazyFixList lazyListForDelegates(List JavaDoc<LazyFixList> delegates) {
105         return new HintsControllerImpl.CompoundLazyFixList(delegates);
106     }
107 }
108
Popular Tags