2362N/A * Copyright (c) 1995, 2001, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A class to represent a pool of regular expressions. A string 0N/A * can be matched against the whole pool all at once. It is much 0N/A * faster than doing individual regular expression matches one-by-one. 0N/A * @see java.misc.RegexpTarget 0N/A * @author James Gosling 0N/A private static final int BIG =
0x7FFFFFFF;
0N/A * Add a regular expression to the pool of regular expressions. 0N/A * @param re The regular expression to add to the pool. 0N/A For now, only handles strings that either begin or end with 0N/A * @param ret The object to be returned when this regular expression is 0N/A matched. If ret is an instance of the RegexpTarget class, ret.found 0N/A is called with the string fragment that matched the '*' as its 0N/A * @exception REException error 0N/A * Replace the target for the regular expression with a different 0N/A * @param re The regular expression to be replaced in the pool. 0N/A * For now, only handles strings that either begin or end with 0N/A * @param ret The object to be returned when this regular expression is 0N/A * matched. If ret is an instance of the RegexpTarget class, ret.found 0N/A * is called with the string fragment that matched the '*' as its 0N/A // should never occur if replace is true 0N/A * Delete the regular expression and its target. 0N/A * @param re The regular expression to be deleted from the pool. 0N/A * must begin or end with a '*' 0N/A * @return target - the old target. 0N/A /* March forward through the prefix machine */ 0N/A /* march backward through the suffix machine */ 0N/A // delete only if there is an exact match 0N/A /** Search for a match to a string & return the object associated 0N/A with it with the match. When multiple regular expressions 0N/A would match the string, the best match is returned first. 0N/A The next best match is returned the next time matchNext is 0N/A @param s The string to match against the regular expressions 0N/A @return null on failure, otherwise the object associated with 0N/A the regular expression when it was added to the pool. 0N/A If the object is an instance of RegexpTarget, then 0N/A the return value is the result from calling 0N/A return.found(string_that_matched_wildcard). 0N/A /** Identical to match except that it will only find matches to 0N/A regular expressions that were added to the pool <i>after</i> 0N/A the last regular expression that matched in the last call 0N/A to match() or matchNext() */ 0N/A /* March forward through the prefix machine */ 0N/A /* march backward through the suffix machine */ 0N/A /** Resets the pool so that the next call to matchNext looks 0N/A at all regular expressions in the pool. match(s); is equivalent 0N/A to reset(); matchNext(s); 0N/A regular expression pool. If multiple threads could be using this 0N/A pool this way, they should be syncronized to avoid race hazards. 0N/A match() was done in such a way that there are no such race 0N/A hazards: multiple threads can be matching in the same pool 0N/A /** Print this pool to standard output */ 0N/A/* A node in a regular expression finite state machine. */