01: /*
02: * gnu/regexp/RETokenAny.java
03: * Copyright (C) 1998 Wes Biggs
04: *
05: * This library is free software; you can redistribute it and/or modify
06: * it under the terms of the GNU Library General Public License as published
07: * by the Free Software Foundation; either version 2 of the License, or
08: * (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: * GNU Library General Public License for more details.
14: *
15: * You should have received a copy of the GNU Library General Public License
16: * along with this program; if not, write to the Free Software
17: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18: */
19:
20: package gnu.regexp;
21:
22: class RETokenAny extends REToken {
23: /** True if '.' can match a newline (RE_DOT_NEWLINE) */
24: private boolean m_newline;
25:
26: /** True if '.' can't match a null (RE_DOT_NOT_NULL) */
27: private boolean m_null;
28:
29: RETokenAny(int f_subIndex, boolean f_newline, boolean f_null) {
30: super (f_subIndex);
31: m_newline = f_newline;
32: m_null = f_null;
33: }
34:
35: int getMinimumLength() {
36: return 1;
37: }
38:
39: int[] match(CharIndexed input, int index, int eflags,
40: REMatch mymatch) {
41: char ch = input.charAt(index);
42: if ((ch == CharIndexed.OUT_OF_BOUNDS)
43: || (!m_newline && (ch == '\n'))
44: || (m_null && (ch == 0)))
45: return null;
46:
47: return next(input, index + 1, eflags, mymatch);
48: }
49:
50: void dump(StringBuffer os) {
51: os.append('.');
52: }
53: }
|