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