KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > editor > DocumentFinder


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.editor;
21
22 import java.util.Map JavaDoc;
23 import java.util.regex.Matcher JavaDoc;
24 import java.util.regex.Pattern JavaDoc;
25 import java.util.regex.PatternSyntaxException JavaDoc;
26 import javax.swing.text.BadLocationException JavaDoc;
27 import javax.swing.text.Document JavaDoc;
28 import org.netbeans.lib.editor.util.swing.DocumentUtilities;
29 import org.openide.DialogDisplayer;
30 import org.openide.ErrorManager;
31 import org.openide.NotifyDescriptor;
32 import org.openide.util.NbBundle;
33
34 /**
35  *
36  * @author Martin Roskanin
37  * @deprecated Without any replacement.
38  */

39 public class DocumentFinder
40 {
41     /**
42      * Finds in document
43      *
44      * @param doc document where to find
45      * @param startOffset offset in the document where the search will start
46      * @param endOffset offset where the search will end with reporting
47      * that nothing was found.
48      * @param props find properties
49      */

50     public static int[] find(
51         BaseDocument doc, int startOffset, int endOffset, Map JavaDoc props,
52         boolean oppositeDir
53     ) throws BadLocationException JavaDoc {
54         return org.netbeans.modules.editor.lib2.search.DocumentFinder.find(doc, startOffset, endOffset, props, oppositeDir);
55     }
56
57     public static int[] findBlocks(
58         BaseDocument doc, int startOffset, int endOffset,
59         Map JavaDoc props, int blocks[]
60     ) throws BadLocationException JavaDoc {
61         return org.netbeans.modules.editor.lib2.search.DocumentFinder.findBlocks(doc, startOffset, endOffset, props, blocks);
62     }
63     
64     /**
65      * Finds the searching string and substitute replace expression in case of
66      * regexp backreferences.
67      * @return FindReplaceResult, that contains positions of found string and substituted replace expression
68      */

69     public static FindReplaceResult findReplaceResult(
70         String JavaDoc replaceString, BaseDocument doc, int startOffset, int endOffset,
71         Map JavaDoc props, boolean oppositeDir
72     ) throws BadLocationException JavaDoc {
73         org.netbeans.modules.editor.lib2.search.DocumentFinder.FindReplaceResult result =
74             org.netbeans.modules.editor.lib2.search.DocumentFinder.findReplaceResult(
75                 replaceString, doc, startOffset, endOffset, props, oppositeDir);
76         
77         return new FindReplaceResult(result.getFoundPositions(), result.getReplacedString());
78     }
79
80     private DocumentFinder() {
81         
82     }
83     
84     public static class FindReplaceResult{
85         private int[] positions;
86         private String JavaDoc replacedString;
87         
88         public FindReplaceResult(int[] positions, String JavaDoc replacedString){
89             this.positions = positions;
90             this.replacedString = replacedString;
91         }
92         
93         public String JavaDoc getReplacedString(){
94             return replacedString;
95         }
96         
97         public int[] getFoundPositions(){
98             return positions;
99         }
100     } // End of FindReplaceResult class
101
}
102
103
104
Popular Tags