001: /*
002: * Portions Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: /*
027: *******************************************************************************
028: * (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
029: * *
030: * The original version of this source code and documentation is copyrighted *
031: * and owned by IBM, These materials are provided under terms of a License *
032: * Agreement between IBM and Sun. This technology is protected by multiple *
033: * US and International patents. This notice and attribution to IBM may not *
034: * to removed. *
035: *******************************************************************************
036: */
037:
038: package sun.text.normalizer;
039:
040: /**
041: * <p>Interface for enabling iteration over sets of <int index, int value>,
042: * where index is the sorted integer index in ascending order and value, its
043: * associated integer value.</p>
044: * <p>The result for each iteration is the consecutive range of
045: * <int index, int value> with the same value. Result is represented by
046: * <start, limit, value> where</p>
047: * <ul>
048: * <li> start is the starting integer of the result range
049: * <li> limit is 1 after the maximum integer that follows start, such that
050: * all integers between start and (limit - 1), inclusive, have the same
051: * associated integer value.
052: * <li> value is the integer value that all integers from start to (limit - 1)
053: * share in common.
054: * </ul>
055: * <p>
056: * Hence value(start) = value(start + 1) = .... = value(start + n) = .... =
057: * value(limit - 1). However value(start -1) != value(start) and
058: * value(limit) != value(start).
059: * </p>
060: * <p>Most implementations will be created by factory methods, such as the
061: * character type iterator in UCharacter.getTypeIterator. See example below.
062: * </p>
063: * Example of use:<br>
064: * <pre>
065: * RangeValueIterator iterator = UCharacter.getTypeIterator();
066: * RangeValueIterator.Element result = new RangeValueIterator.Element();
067: * while (iterator.next(result)) {
068: * System.out.println("Codepoint \\u" +
069: * Integer.toHexString(result.start) +
070: * " to codepoint \\u" +
071: * Integer.toHexString(result.limit - 1) +
072: * " has the character type " + result.value);
073: * }
074: * </pre>
075: * @author synwee
076: * @stable ICU 2.6
077: */
078: public interface RangeValueIterator {
079: // public inner class ---------------------------------------------
080:
081: /**
082: * Return result wrapper for com.ibm.icu.util.RangeValueIterator.
083: * Stores the start and limit of the continous result range and the
084: * common value all integers between [start, limit - 1] has.
085: * @stable ICU 2.6
086: */
087: public class Element {
088: // public data member ---------------------------------------------
089:
090: /**
091: * Starting integer of the continuous result range that has the same
092: * value
093: * @stable ICU 2.6
094: */
095: public int start;
096: /**
097: * (End + 1) integer of continuous result range that has the same
098: * value
099: * @stable ICU 2.6
100: */
101: public int limit;
102: /**
103: * Gets the common value of the continous result range
104: * @stable ICU 2.6
105: */
106: public int value;
107:
108: // public constructor --------------------------------------------
109:
110: /**
111: * Empty default constructor to make javadoc happy
112: * @stable ICU 2.4
113: */
114: public Element() {
115: }
116: }
117:
118: // public methods -------------------------------------------------
119:
120: /**
121: * <p>Gets the next maximal result range with a common value and returns
122: * true if we are not at the end of the iteration, false otherwise.</p>
123: * <p>If the return boolean is a false, the contents of elements will not
124: * be updated.</p>
125: * @param element for storing the result range and value
126: * @return true if we are not at the end of the iteration, false otherwise.
127: * @see Element
128: * @stable ICU 2.6
129: */
130: public boolean next(Element element);
131:
132: /**
133: * Resets the iterator to the beginning of the iteration.
134: * @stable ICU 2.6
135: */
136: public void reset();
137: }
|