2 *******************************************************************************
3 * Copyright (C) 2011-2012, Google, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
7 package com.ibm.icu.dev.util;
9 import com.ibm.icu.text.Transform;
10 import com.ibm.icu.text.UTF16;
13 * Simple wrapping for normalizer that allows for both the standard ICU normalizer, and one built directly from the UCD.
15 public abstract class UnicodeTransform implements Transform<String,String> {
17 NFD, NFC, NFKD, NFKC, CASEFOLD
20 public interface Factory {
21 public UnicodeTransform getInstance(Type type);
24 private static Factory factory = new IcuUnicodeNormalizerFactory();
26 public static synchronized Factory getFactory() {
30 public static synchronized void setFactory(Factory factory) {
31 UnicodeTransform.factory = factory;
34 public static synchronized UnicodeTransform getInstance(Type type) {
35 return factory.getInstance(type);
38 public abstract String transform(String source);
41 * Can be overridden for performance.
43 public boolean isTransformed(String source) {
44 return source.equals(transform(source));
47 * Can be overridden for performance.
49 public String transform(int source) {
50 return transform(UTF16.valueOf(source));
53 * Can be overridden for performance.
55 public boolean isTransformed(int source) {
56 return isTransformed(UTF16.valueOf(source));