]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_4_2-src/main/classes/core/src/com/ibm/icu/lang/UCharacterTypeIterator.java
go
[Dictionary.git] / jars / icu4j-4_4_2-src / main / classes / core / src / com / ibm / icu / lang / UCharacterTypeIterator.java
1 /*\r
2 ******************************************************************************\r
3 * Copyright (C) 1996-2008, International Business Machines Corporation and   *\r
4 * others. All Rights Reserved.                                               *\r
5 ******************************************************************************\r
6 */\r
7 \r
8 package com.ibm.icu.lang;\r
9 \r
10 import com.ibm.icu.impl.TrieIterator;\r
11 import com.ibm.icu.impl.UCharacterProperty;\r
12 \r
13 /**\r
14  * Class enabling iteration of the codepoints according to their types.\r
15  * Result of each iteration contains the interval of codepoints that have\r
16  * the same type.\r
17  * Example of use:<br>\r
18  * <pre>\r
19  * RangeValueIterator iterator = UCharacter.getTypeIterator();\r
20  * RangeValueIterator.Element element = new RangeValueIterator.Element();\r
21  * while (iterator.next(element)) {\r
22  *     System.out.println("Codepoint \\u" + \r
23  *                        Integer.toHexString(element.start) + \r
24  *                        " to codepoint \\u" +\r
25  *                        Integer.toHexString(element.limit - 1) + \r
26  *                        " has the character type " + \r
27  *                        element.value);\r
28  * }\r
29  * </pre>\r
30  * @author synwee\r
31  * @see com.ibm.icu.util.TrieIterator\r
32  * @since release 2.1, Jan 24 2002\r
33  */\r
34 class UCharacterTypeIterator extends TrieIterator\r
35 {\r
36     // protected constructor ---------------------------------------------\r
37     \r
38     /**\r
39     * TrieEnumeration constructor\r
40     * @param property the unicode character properties to be used\r
41     */\r
42     protected UCharacterTypeIterator(UCharacterProperty property)\r
43     {\r
44        super(property.m_trie_);\r
45     }\r
46     \r
47     // protected methods ----------------------------------------------\r
48     \r
49     /**\r
50     * Called by nextElement() to extracts a 32 bit value from a trie value\r
51     * used for comparison.\r
52     * This method is to be overwritten if special manipulation is to be done\r
53     * to retrieve a relevant comparison.\r
54     * The default function is to return the value as it is.\r
55     * @param value a value from the trie\r
56     * @return extracted value\r
57     */\r
58     protected int extract(int value)\r
59     {\r
60         return value & UCharacterProperty.TYPE_MASK;\r
61     }\r
62 }