KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibm > icu > lang > UCharacterTypeIterator


1 /*
2 ******************************************************************************
3 * Copyright (C) 1996-2005, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 ******************************************************************************
6 */

7
8 package com.ibm.icu.lang;
9
10 import com.ibm.icu.impl.TrieIterator;
11 import com.ibm.icu.impl.UCharacterProperty;
12
13 /**
14  * Class enabling iteration of the codepoints according to their types.
15  * Result of each iteration contains the interval of codepoints that have
16  * the same type.
17  * Example of use:<br>
18  * <pre>
19  * RangeValueIterator iterator = UCharacter.getTypeIterator();
20  * RangeValueIterator.Element element = new RangeValueIterator.Element();
21  * while (iterator.next(element)) {
22  * System.out.println("Codepoint \\u" +
23  * Integer.toHexString(element.start) +
24  * " to codepoint \\u" +
25  * Integer.toHexString(element.limit - 1) +
26  * " has the character type " +
27  * element.value);
28  * }
29  * </pre>
30  * @author synwee
31  * @see com.ibm.icu.util.TrieIterator
32  * @since release 2.1, Jan 24 2002
33  */

34 class UCharacterTypeIterator extends TrieIterator
35 {
36     // protected constructor ---------------------------------------------
37

38     /**
39     * TrieEnumeration constructor
40     * @param property the unicode character properties to be used
41     * @draft 2.1
42     */

43     protected UCharacterTypeIterator(UCharacterProperty property)
44     {
45        super(property.m_trie_);
46     }
47     
48     // protected methods ----------------------------------------------
49

50     /**
51     * Called by nextElement() to extracts a 32 bit value from a trie value
52     * used for comparison.
53     * This method is to be overwritten if special manipulation is to be done
54     * to retrieve a relevant comparison.
55     * The default function is to return the value as it is.
56     * @param value a value from the trie
57     * @return extracted value
58     */

59     protected int extract(int value)
60     {
61         return value & UCharacterProperty.TYPE_MASK;
62     }
63     
64     // private data members ---------------------------------------------
65

66     /**
67      * Character property
68      */

69     private int m_property_[];
70 }
Popular Tags