001/* 002 * gnu/regexp/RETokenAny.java 003 * Copyright (C) 1998-2001 Wes Biggs 004 * 005 * This library is free software; you can redistribute it and/or modify 006 * it under the terms of the GNU Lesser General Public License as published 007 * by the Free Software Foundation; either version 2.1 of the License, or 008 * (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public License 016 * along with this program; if not, write to the Free Software 017 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 018 */ 019 020package gnu.regexp; 021 022final class RETokenAny extends REToken { 023 /** True if '.' can match a newline (RE_DOT_NEWLINE) */ 024 private boolean newline; 025 026 /** True if '.' can't match a null (RE_DOT_NOT_NULL) */ 027 private boolean matchNull; 028 029 RETokenAny(int subIndex, boolean newline, boolean matchNull) { 030 super(subIndex); 031 this.newline = newline; 032 this.matchNull = matchNull; 033 } 034 035 int getMinimumLength() { 036 return 1; 037 } 038 039 boolean match(CharIndexed input, REMatch mymatch) { 040 char ch = input.charAt(mymatch.index); 041 if ((ch == CharIndexed.OUT_OF_BOUNDS) 042 || (!newline && (ch == '\n')) 043 || (matchNull && (ch == 0))) { 044 return false; 045 } 046 ++mymatch.index; 047 return next(input, mymatch); 048 } 049 050 void dump(StringBuffer os) { 051 os.append('.'); 052 } 053} 054