2362N/A * Copyright (c) 2005, 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 ******************************************************************************* 0N/A * (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved * 0N/A * The original version of this source code and documentation is copyrighted * 0N/A * and owned by IBM, These materials are provided under terms of a License * 0N/A * Agreement between IBM and Sun. This technology is protected by multiple * 0N/A * US and International patents. This notice and attribution to IBM may not * 0N/A ******************************************************************************* 0N/A ********************************************************************** 0N/A * Created: September 23 2003 0N/A ********************************************************************** 0N/A * An iterator that returns 32-bit code points. This class is deliberately 0N/A * <em>not</em> related to any of the JDK or ICU4J character iterator classes 0N/A * in order to minimize complexity. 0N/A // TODO: Ideas for later. (Do not implement if not needed, lest the 0N/A // code coverage numbers go down due to unused methods.) 0N/A // 1. Add a copy constructor, equals() method, clone() method. 0N/A // 2. Rather than return DONE, throw an exception if the end 0N/A // is reached -- this is an alternate usage model, probably not useful. 0N/A // 3. Return isEscaped from next(). If this happens, 0N/A // don't keep an isEscaped member variable. 0N/A * Text being iterated. 0N/A * Position of iterator. 0N/A * Symbol table used to parse and dereference variables. May be null. 0N/A * Current variable expansion, or null if none. 0N/A * Position within buf[]. Meaningless if buf == null. 0N/A * Flag indicating whether the last character was parsed from an escape. 0N/A * Value returned when there are no more characters to iterate. 0N/A * Bitmask option to enable parsing of variable names. If (options & 0N/A * PARSE_VARIABLES) != 0, then an embedded variable will be expanded to 0N/A * its value. Variables are parsed using the SymbolTable API. 0N/A * Bitmask option to enable parsing of escape sequences. If (options & 0N/A * PARSE_ESCAPES) != 0, then an embedded escape sequence will be expanded 0N/A * to its value. Escapes are parsed using Utility.unescapeAt(). 0N/A * Bitmask option to enable skipping of whitespace. If (options & 0N/A * SKIP_WHITESPACE) != 0, then whitespace characters will be silently 0N/A * skipped, as if they were not present in the input. Whitespace 0N/A * characters are defined by UCharacterProperty.isRuleWhiteSpace(). 0N/A * Constructs an iterator over the given text, starting at the given 0N/A * @param text the text to be iterated 0N/A * @param sym the symbol table, or null if there is none. If sym is null, 0N/A * then variables will not be deferenced, even if the PARSE_VARIABLES 0N/A * @param pos upon input, the index of the next character to return. If a 0N/A * variable has been dereferenced, then pos will <em>not</em> increment as 0N/A * characters of the variable value are iterated. 0N/A * Returns true if this iterator has no more characters to return. 0N/A * Returns the next character using the given options, or DONE if there 0N/A * are no more characters, and advance the position to the next 0N/A * @param options one or more of the following options, bitwise-OR-ed 0N/A * together: PARSE_VARIABLES, PARSE_ESCAPES, SKIP_WHITESPACE. 0N/A * @return the current 32-bit code point, or DONE 0N/A // If name == null there was an isolated SYMBOL_REF; 0N/A // return it. Caller must be prepared for this. 0N/A // Handle empty variable value 0N/A * Returns true if the last character returned by next() was 0N/A * escaped. This will only be the case if the option passed in to 0N/A * next() included PARSE_ESCAPED and the next character was an 0N/A * Returns true if this iterator is currently within a variable expansion. 0N/A * Returns an object which, when later passed to setPos(), will 0N/A * restore this iterator's position. Usage idiom: 0N/A * RuleCharacterIterator iterator = ...; 0N/A * Object pos = iterator.getPos(null); // allocate position object 0N/A * pos = iterator.getPos(pos); // reuse position object 0N/A * int c = iterator.next(...); 0N/A * iterator.setPos(pos); 0N/A * @param p a position object previously returned by getPos(), 0N/A * or null. If not null, it will be updated and returned. If 0N/A * null, a new position object will be allocated and returned. 0N/A * @return a position object which may be passed to setPos(), 0N/A * either `p,' or if `p' == null, a newly-allocated object 0N/A int[] v = (
int[]) a[
1];
0N/A * Restores this iterator to the position it had when getPos() 0N/A * returned the given object. 0N/A * @param p a position object previously returned by getPos() 0N/A int[] v = (
int[]) a[
1];
0N/A * Skips ahead past any ignored characters, as indicated by the given 0N/A * options. This is useful in conjunction with the lookahead() method. 0N/A * Currently, this only has an effect for SKIP_WHITESPACE. 0N/A * @param options one or more of the following options, bitwise-OR-ed 0N/A * together: PARSE_VARIABLES, PARSE_ESCAPES, SKIP_WHITESPACE. 0N/A * Returns a string containing the remainder of the characters to be 0N/A * returned by this iterator, without any option processing. If the 0N/A * iterator is currently within a variable expansion, this will only 0N/A * extend to the end of the variable expansion. This method is provided 0N/A * so that iterators may interoperate with string-based APIs. The typical 0N/A * sequence of calls is to call skipIgnored(), then call lookahead(), then 0N/A * parse the string returned by lookahead(), then call jumpahead() to 0N/A * resynchronize the iterator. 0N/A * @return a string containing the characters to be returned by future 0N/A * Advances the position by the given number of 16-bit code units. 0N/A * This is useful in conjunction with the lookahead() method. 0N/A * @param count the number of 16-bit code units to jump over 0N/A * Returns the current 32-bit code point without parsing escapes, parsing 0N/A * variables, or skipping whitespace. 0N/A * @return the current 32-bit code point 0N/A * Advances the position by the given amount. 0N/A * @param count the number of 16-bit code units to advance past