01: /*
02: ******************************************************************************
03: * Copyright (C) 1996-2005, International Business Machines Corporation and *
04: * others. All Rights Reserved. *
05: ******************************************************************************
06: */
07:
08: package com.ibm.icu.lang;
09:
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: // protected constructor ---------------------------------------------
36:
37: /**
38: * TrieEnumeration constructor
39: * @param property the unicode character properties to be used
40: * @draft 2.1
41: */
42: protected UCharacterTypeIterator(UCharacterProperty property) {
43: super (property.m_trie_);
44: }
45:
46: // protected methods ----------------------------------------------
47:
48: /**
49: * Called by nextElement() to extracts a 32 bit value from a trie value
50: * used for comparison.
51: * This method is to be overwritten if special manipulation is to be done
52: * to retrieve a relevant comparison.
53: * The default function is to return the value as it is.
54: * @param value a value from the trie
55: * @return extracted value
56: */
57: protected int extract(int value) {
58: return value & UCharacterProperty.TYPE_MASK;
59: }
60:
61: // private data members ---------------------------------------------
62:
63: /**
64: * Character property
65: */
66: private int m_property_[];
67: }
|