Class Normalizer

java.lang.Object
org.jasypt.normalization.Normalizer

public final class Normalizer extends Object

Utility for the normalization of Unicode Strings to NFC form.

This class tries to use the java.text.Normalizer class in JDK 1.6 first and, if it the class is not found (Java version invalid input: '<' 6), then it will use the ICU4J com.ibm.icu.text.Normalizer class (in this case, a ClassNotFoundException will be thrown if ICU4J is not present).

Since:
1.5
  • Field Details

    • ICU_NORMALIZER_CLASS_NAME

      private static final String ICU_NORMALIZER_CLASS_NAME
      See Also:
    • JDK_NORMALIZER_CLASS_NAME

      private static final String JDK_NORMALIZER_CLASS_NAME
      See Also:
    • JDK_NORMALIZER_FORM_CLASS_NAME

      private static final String JDK_NORMALIZER_FORM_CLASS_NAME
      See Also:
    • useIcuNormalizer

      private static Boolean useIcuNormalizer
    • javaTextNormalizerMethod

      private static Method javaTextNormalizerMethod
    • javaTextNormalizerFormNFCConstant

      private static Object javaTextNormalizerFormNFCConstant
  • Constructor Details

    • Normalizer

      private Normalizer()
  • Method Details

    • normalizeToNfc

      public static String normalizeToNfc(String message)

      Normalize Unicode-input message to NFC.

      This algorithm will first try to normalize the input's UNICODE using icu4j's com.ibm.icu.text.Normalizer and, if it is not present at the classpath, will try to use java.text.Normalizer. If this is not present either (this class appeared in JavaSE 6), it will raise an exception.

      Parameters:
      message - the message to be normalized
      Returns:
      the result of the normalization operation
    • normalizeToNfc

      public static char[] normalizeToNfc(char[] message)

      Normalize Unicode-input message to NFC.

      This algorithm will first try to normalize the input's UNICODE using icu4j's com.ibm.icu.text.Normalizer and, if it is not present at the classpath, will try to use java.text.Normalizer. If this is not present either (this class appeared in JavaSE 6), it will raise an exception.

      Parameters:
      message - the message to be normalized
      Returns:
      the result of the normalization operation
    • initializeIcu4j

      static void initializeIcu4j() throws ClassNotFoundException
      Throws:
      ClassNotFoundException
    • initializeJavaTextNormalizer

      static void initializeJavaTextNormalizer() throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException, IllegalAccessException
      Throws:
      ClassNotFoundException
      NoSuchMethodException
      NoSuchFieldException
      IllegalAccessException
    • normalizeWithJavaNormalizer

      static char[] normalizeWithJavaNormalizer(char[] message)
    • normalizeWithIcu4j

      static char[] normalizeWithIcu4j(char[] message)