1 package org.andromda.utils.beans.comparators;
2
3 import java.io.Serializable;
4 import java.text.Collator;
5 import java.util.Comparator;
6
7
8
9
10
11
12 class CharacterComparator
13 implements Comparator,
14 Serializable
15 {
16 private static final long serialVersionUID = 34L;
17
18 private Collator collator = null;
19
20
21
22
23
24
25
26
27 public int compare(
28 Object objectA,
29 Object objectB)
30 {
31 Character aAsCharacter = (Character)objectA;
32 Character bAsCharacter = (Character)objectB;
33 this.initializeCollator();
34 return collator.compare(
35 Character.toString(aAsCharacter.charValue()),
36 Character.toString(bAsCharacter.charValue()));
37 }
38
39
40
41
42 private void initializeCollator()
43 {
44 if (this.collator == null)
45 {
46 this.collator = Collator.getInstance();
47
48
49 collator.setStrength(Collator.PRIMARY);
50 }
51 }
52 }