01: /*
02: * SearchMatcher.java - Abstract string matcher interface
03: * :tabSize=8:indentSize=8:noTabs=false:
04: * :folding=explicit:collapseFolds=1:
05: *
06: * Copyright (C) 1999, 2001, 2002 Slava Pestov
07: *
08: * This program is free software; you can redistribute it and/or
09: * 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: public SearchMatcher() {
32: returnValue = new Match();
33: }
34:
35: /**
36: * Returns the offset of the first match of the specified text
37: * within this matcher.
38: * @param text The text to search in
39: * @param start True if the start of the segment is the beginning of the
40: * buffer
41: * @param end True if the end of the segment is the end of the buffer
42: * @param firstTime If false and the search string matched at the start
43: * offset with length zero, automatically find next match
44: * @param reverse If true, searching will be performed in a backward
45: * direction.
46: * @return an array where the first element is the start offset
47: * of the match, and the second element is the end offset of
48: * the match
49: * @since jEdit 4.3pre5
50: */
51: public abstract Match nextMatch(CharSequence text, boolean start,
52: boolean end, boolean firstTime, boolean reverse);
53:
54: /**
55: * Returns whether the matcher is matching the end of the line
56: * character. This should be used to adjust the matched region
57: * size when matching the end-of-line character, since it's not
58: * included in the matched region returned by the
59: * java.util.regex.Pattern matcher.
60: *
61: * @return Whether the end of the match region will be the EOL
62: * character.
63: * @since jEdit 4.3pre7
64: */
65: public boolean isMatchingEOL() {
66: return false;
67: }
68:
69: protected Match returnValue;
70:
71: //{{{ Match class
72: public static class Match {
73: public int start;
74: public int end;
75: public String[] substitutions;
76: } //}}}
77: }
|