2 *******************************************************************************
\r
3 * Copyright (C) 1998-2004, International Business Machines Corporation and *
\r
4 * others. All Rights Reserved. *
\r
5 *******************************************************************************
\r
7 * Created on Dec 3, 2003
\r
9 *******************************************************************************
\r
11 package com.ibm.icu.dev.tool.layout;
\r
13 import com.ibm.icu.lang.UCharacter;
\r
14 import com.ibm.icu.lang.UProperty;
\r
15 import com.ibm.icu.text.Normalizer;
\r
16 import com.ibm.icu.text.UnicodeSet;
\r
18 public class ArabicCharacterData
\r
22 public int getCodePoint()
\r
27 public int getGeneralCategory()
\r
29 return generalCategory;
\r
32 public int getDecompositionType()
\r
34 return decompositionType;
\r
37 public String getDecomposition()
\r
39 return decomposition;
\r
42 private Record(int character)
\r
44 codePoint = character;
\r
45 generalCategory = UCharacter.getType(character);
\r
46 decompositionType = UCharacter.getIntPropertyValue(character, UProperty.DECOMPOSITION_TYPE);
\r
48 switch (decompositionType) {
\r
49 case UCharacter.DecompositionType.FINAL:
\r
50 case UCharacter.DecompositionType.INITIAL:
\r
51 case UCharacter.DecompositionType.ISOLATED:
\r
52 case UCharacter.DecompositionType.MEDIAL:
\r
53 decomposition = Normalizer.compose(UCharacter.toString(character), true);
\r
56 case UCharacter.DecompositionType.CANONICAL:
\r
57 decomposition = Normalizer.decompose(UCharacter.toString(character), true);
\r
61 decomposition = null;
\r
65 private int codePoint;
\r
66 private int generalCategory;
\r
67 private int decompositionType;
\r
68 private String decomposition;
\r
71 private ArabicCharacterData(int charCount)
\r
73 records = new Record[charCount];
\r
76 private void add(int character)
\r
78 records[recordIndex++] = new Record(character);
\r
81 public Record getRecord(int index)
\r
83 if (index < 0 || index >= records.length) {
\r
87 return records[index];
\r
90 public int countRecords()
\r
92 return records.length;
\r
95 // TODO: do we need to change this to use UnicodeSetIterator?
\r
96 // That will mean not knowing the number of characters until
\r
97 // after the iteration is done, so we'd have to use a vector
\r
98 // to hold the Records at first and copy it to an array
\r
99 // when we're done...
\r
100 public static ArabicCharacterData factory(UnicodeSet characterSet)
\r
102 int charCount = characterSet.size();
\r
103 ArabicCharacterData data = new ArabicCharacterData(charCount);
\r
105 for (int i = 0; i < charCount; i += 1) {
\r
106 data.add(characterSet.charAt(i));
\r
112 private Record[] records;
\r
113 private int recordIndex = 0;
\r