FileDocCategorySizeDatePackage
Decomposition.javaAPI DocExample1872Fri Mar 30 00:11:26 BST 2001None

Decomposition

public class Decomposition extends Object

Fields Summary
Constructors Summary
public Decomposition()

    String pairs[][] = new String[3][3];
    pairs[0][0] = "Half-Width and full-width A";
    pairs[0][1] = "A";
    pairs[0][2] = "\uFF21"; // full-width A
    pairs[1][0] = "A with Ring and Angstrom Sign";
    pairs[1][1] = "\u00c5"; // A with ring
    pairs[1][2] = "\u212b"; // Angstrom
    pairs[2][0] = "a + umlaut and precomposed a-umlaut";
    pairs[2][1] = "a\u0308";
    pairs[2][2] = "\u00e4";

    for (int i = 0; i < 3; i++) {
      Collator collate = Collator.getInstance(Locale.US);
      collate.setStrength(Collator.IDENTICAL);

      System.out.println("Comparing " + pairs[i][0]);
      collate.setDecomposition(Collator.NO_DECOMPOSITION);
      compare(collate, pairs[i][1],pairs[i][2]);

      collate.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
      compare(collate, pairs[i][1],pairs[i][2]);

      collate.setDecomposition(Collator.FULL_DECOMPOSITION);
      compare(collate, pairs[i][1],pairs[i][2]);
      System.out.println("");
    }
  
Methods Summary
public voidcompare(java.text.Collator c, java.lang.String a, java.lang.String b)

    switch(c.getDecomposition()) {
      case Collator.NO_DECOMPOSITION:
        System.out.print(" NO DECOMPOSITION: ");
        break;
      case Collator.CANONICAL_DECOMPOSITION:
        System.out.print(" CANONICAL DECOMPOSITION: ");
        break;
      case Collator.FULL_DECOMPOSITION:
        System.out.print(" FULL DECOMPOSITION: ");
        break;
      default:
        System.out.print(" UNKNOWN DECOMPOSITION: ");
    }

    if (c.equals(a, b))
      System.out.println("The strings are equal.");
    else
      System.out.println("The strings are NOT equal.");
  
public static voidmain(java.lang.String[] s)

    new Decomposition();