KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
23 * Advanced finder that can adjust the start and limit position
24 * of the search. The finder can be used in the <tt>BaseDocument.find()</tt>
25 * which calls its adjust-methods automatically.
26 * The order of the methods called for the search is
27 * <br>
28 * 1. <tt>adjustStartPos()</tt> is called<br>
29 * 2. <tt>adjustStartPos()</tt> is called<br>
30 * 3. <tt>reset()</tt> is called<br>
31 * If the search is void i.e. <tt>doc.find(finder, pos, pos)</tt>
32 * is called, no adjust-methods are called, only the <tt>reset()</tt>
33 * is called.
34 * For backward search the start-position is higher than the limit-position.
35 * The relation <tt>startPos &lt; endPos</tt> defines whether the search
36 * will be forward or backward. The adjust-methods could in fact
37 * revert this relation turning the forward search into the backward one
38 * and vice versa. This is not allowed. If that happens the search
39 * is considered void.
40 * The adjust-methods must NOT use the shortcut -1 for the end of document.
41 *
42 * @author Miloslav Metelka
43 * @version 1.00
44 */

45
46 public interface AdjustFinder extends Finder {
47
48     /** Adjust start position of the search to be either the same or lower.
49     * This method can be used
50     * for example to scan the whole line by the reg-exp finder even
51     * if the original start position is not at the begining of the line.
52     * Although it's not specifically checked the finder should NOT in any case
53     * return the position that is lower than the original
54     * @param doc document to search on
55     * @param startPos start position originally requested in <tt>BaseDocument.find()</tt>.
56     * @return possibly modified start position. The returned position must be
57     * the same or lower than the original start position for forward search
58     * and the same or high.
59     */

60     public int adjustStartPos(BaseDocument doc, int startPos);
61
62     /** Adjust the limit position of the search
63     * (it's the position where the search will end) to be either the same or greater.
64     * @param doc document to search on
65     * @param limitPos limit position originally requested in <tt>BaseDocument.find()</tt>
66     * @return possibly modified limit position. The returned position must be
67     * the same or greater than the original limit position.
68     */

69     public int adjustLimitPos(BaseDocument doc, int limitPos);
70
71 }
72
Popular Tags