3261N/A * Copyright (c) 1996, 2000, Oracle and/or its affiliates. All rights reserved. 893N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 893N/A * This code is free software; you can redistribute it and/or modify it 893N/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 893N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 893N/A * This code is distributed in the hope that it will be useful, but WITHOUT 893N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 893N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 893N/A * version 2 for more details (a copy is included in the LICENSE file that 893N/A * accompanied this code). 893N/A * You should have received a copy of the GNU General Public License version 893N/A * 2 along with this work; if not, write to the Free Software Foundation, 893N/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 893N/A * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved 893N/A * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved 893N/A * The original version of this source code and documentation 4216N/A * is copyrighted and owned by Taligent, Inc., a wholly-owned 893N/A * subsidiary of IBM. These materials are provided under terms 893N/A * of a License Agreement between Taligent and Sun. This technology 893N/A * is protected by multiple US and International patents. 893N/A * This notice and attribution to Taligent may not be removed. 893N/A * Taligent is a registered trademark of Taligent, Inc. 893N/A * This interface defines a protocol for bidirectional iteration over text. 893N/A * The iterator iterates over a bounded sequence of characters. Characters 893N/A * are indexed with values beginning with the value returned by getBeginIndex() and 893N/A * continuing through the value returned by getEndIndex()-1. 893N/A * Iterators maintain a current character index, whose valid range is from 893N/A * getBeginIndex() to getEndIndex(); the value getEndIndex() is included to allow 893N/A * handling of zero-length text ranges and for historical reasons. 893N/A * The current index can be retrieved by calling getIndex() and set directly 893N/A * by calling setIndex(), first(), and last(). 6319N/A * The methods previous() and next() are used for iteration. They return DONE if 6319N/A * they would move outside the range from getBeginIndex() to getEndIndex() -1, 893N/A * signaling that the iterator has reached the end of the sequence. DONE is 893N/A * also returned by other methods to indicate that the current index is 893N/A * Traverse the text from start to finish 893N/A * public void traverseForward(CharacterIterator iter) { 893N/A * for(char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) { 893N/A * Traverse the text backwards, from end to start 893N/A * public void traverseBackward(CharacterIterator iter) { 893N/A * for(char c = iter.last(); c != CharacterIterator.DONE; c = iter.previous()) { 6272N/A * Traverse both forward and backward from a given position in the text. 6272N/A * Calls to notBoundary() in this example represents some 6272N/A * additional stopping criteria. 893N/A * public void traverseOut(CharacterIterator iter, int pos) { 893N/A * for (char c = iter.setIndex(pos); 893N/A * c != CharacterIterator.DONE && notBoundary(c); 893N/A * int end = iter.getIndex(); 893N/A * for (char c = iter.setIndex(pos); 893N/A * c != CharacterIterator.DONE && notBoundary(c); 893N/A * c = iter.previous()) { 893N/A * int start = iter.getIndex(); 893N/A * processSection(start, end); 893N/A * @see StringCharacterIterator 893N/A * @see AttributedCharacterIterator 893N/A * Constant that is returned when the iterator has reached either the end 893N/A * or the beginning of the text. The value is '\\uFFFF', the "not a 893N/A * character" value which should not occur in any valid Unicode string. 893N/A * Sets the position to getBeginIndex() and returns the character at that 893N/A * @return the first character in the text, or DONE if the text is empty 893N/A * @see #getBeginIndex() 893N/A * Sets the position to getEndIndex()-1 (getEndIndex() if the text is empty) 893N/A * and returns the character at that position. 893N/A * @return the last character in the text, or DONE if the text is empty 893N/A * Gets the character at the current position (as returned by getIndex()). 893N/A * @return the character at the current position or DONE if the current 893N/A * position is off the end of the text. 893N/A * Increments the iterator's index by one and returns the character 893N/A * at the new index. If the resulting index is greater or equal 893N/A * to getEndIndex(), the current index is reset to getEndIndex() and 893N/A * a value of DONE is returned. 893N/A * @return the character at the new position or DONE if the new 893N/A * position is off the end of the text range. 893N/A * Decrements the iterator's index by one and returns the character 893N/A * at the new index. If the current index is getBeginIndex(), the index 893N/A * remains at getBeginIndex() and a value of DONE is returned. 893N/A * @return the character at the new position or DONE if the current 893N/A * position is equal to getBeginIndex(). 893N/A * Sets the position to the specified position in the text and returns that 893N/A * @param position the position within the text. Valid values range from 893N/A * getBeginIndex() to getEndIndex(). An IllegalArgumentException is thrown 893N/A * if an invalid value is supplied. 893N/A * @return the character at the specified position or DONE if the specified position is equal to getEndIndex() 893N/A * Returns the start index of the text. 893N/A * @return the index at which the text begins. 893N/A * Returns the end index of the text. This index is the index of the first 893N/A * character following the end of the text. 893N/A * @return the index after the last character in the text 893N/A * Returns the current index. 893N/A * @return the current index. 893N/A * Create a copy of this iterator 893N/A * @return A copy of this