KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > sp > jedit > search > SearchMatcher


1 /*
2  * SearchMatcher.java - Abstract string matcher interface
3  * :tabSize=8:indentSize=8:noTabs=false:
4  * :folding=explicit:collapseFolds=1:
5  *
6  * Copyright (C) 1999, 2001, 2002 Slava Pestov
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21  */

22
23 package org.gjt.sp.jedit.search;
24
25 /**
26  * An abstract class for matching strings.
27  * @author Slava Pestov
28  * @version $Id: SearchMatcher.java 6704 2006-08-19 23:17:01Z vanza $
29  */

30 public abstract class SearchMatcher
31 {
32     public SearchMatcher()
33     {
34         returnValue = new Match();
35     }
36
37     /**
38      * Returns the offset of the first match of the specified text
39      * within this matcher.
40      * @param text The text to search in
41      * @param start True if the start of the segment is the beginning of the
42      * buffer
43      * @param end True if the end of the segment is the end of the buffer
44      * @param firstTime If false and the search string matched at the start
45      * offset with length zero, automatically find next match
46      * @param reverse If true, searching will be performed in a backward
47      * direction.
48      * @return an array where the first element is the start offset
49      * of the match, and the second element is the end offset of
50      * the match
51      * @since jEdit 4.3pre5
52      */

53     public abstract Match nextMatch(CharSequence JavaDoc text, boolean start,
54         boolean end, boolean firstTime, boolean reverse);
55
56     /**
57      * Returns whether the matcher is matching the end of the line
58      * character. This should be used to adjust the matched region
59      * size when matching the end-of-line character, since it's not
60      * included in the matched region returned by the
61      * java.util.regex.Pattern matcher.
62      *
63      * @return Whether the end of the match region will be the EOL
64      * character.
65      * @since jEdit 4.3pre7
66      */

67     public boolean isMatchingEOL()
68     {
69         return false;
70     }
71
72     protected Match returnValue;
73
74     //{{{ Match class
75
public static class Match
76     {
77         public int start;
78         public int end;
79         public String JavaDoc[] substitutions;
80     } //}}}
81
}
82
Popular Tags