Class PrepareString

    • Field Detail

      • CASE_SENSITIVE

        public static final boolean CASE_SENSITIVE
        A flag used to lowercase chars during the map process
        See Also:
        Constant Field Values
      • IGNORE_CASE

        public static final boolean IGNORE_CASE
        A flag used to keep casing during the map process
        See Also:
        Constant Field Values
    • Constructor Detail

      • PrepareString

        private PrepareString()
        A private constructor, to avoid instance creation of this static class.
    • Method Detail

      • transcode

        public static String transcode​(byte[] bytes)
        The first step defined by RFC 4518 : Transcode, which transform an UTF-8 encoded String to Unicode. This is done using the Strings.utf8ToString(byte[]) method. This
        Parameters:
        bytes - The byte[] to transcode
        Returns:
        The transcoded String
      • normalize

        public static String normalize​(String value)
        Normalize a String
        Parameters:
        value - the value to normalize
        Returns:
        The normalized value
      • mapCaseSensitive

        public static String mapCaseSensitive​(String unicode)
        Apply the RFC 4518 MAP transformation, case sensitive
        Parameters:
        unicode - The original String
        Returns:
        The mapped String
      • checkProhibited

        public static void checkProhibited​(char[] value)
                                    throws org.apache.directory.api.util.exception.InvalidCharacterException
        Check that the String does not contain any prohibited char
        Parameters:
        value - The String to analyze
        Throws:
        org.apache.directory.api.util.exception.InvalidCharacterException - If any character is prohibited
      • checkProhibited

        private static void checkProhibited​(char c)
                                     throws org.apache.directory.api.util.exception.InvalidCharacterException
        Prohibit characters described in RFC 4518 : - Table A.1 of RFC 3454 - Table C.3 of RFC 3454 - Table C.4 of RFC 3454 - Table C.5 of RFC 3454 - Table C.8 of RFC 3454 - character U-FFFD
        Parameters:
        c - The char to analyze
        Throws:
        org.apache.directory.api.util.exception.InvalidCharacterException - If any character is prohibited
      • insignificantNumericStringHandling

        public static String insignificantNumericStringHandling​(char[] source)
        Remove all insignificant spaces in a numeric string. For instance, the following numeric string : " 123 456 789 " will be transformed to : "123456789"
        Parameters:
        source - The numeric String
        Returns:
        The modified numeric String
      • insignificantTelephoneNumberStringHandling

        public static String insignificantTelephoneNumberStringHandling​(char[] source)
        Remove all insignificant spaces in a TelephoneNumber string, Hyphen and spaces. For instance, the following telephone number : "+ (33) 1-123--456 789" will be transformed to : "+(33)1123456789"
        Parameters:
        source - The telephoneNumber String
        Returns:
        The modified telephoneNumber String
      • insignificantSpacesStringValue

        public static String insignificantSpacesStringValue​(char[] origin)
        Remove all insignificant spaces in a string. Any resulting String will start with a space, ands with a space and every spaces found in the middle of the String will be aggregated into two consecutive spaces :
        • empty string --> <space><space>
        • A --> <space>A<space>
        • <space>A --> <space>A<space>
        • <space><space>A --> <space>A<space>
        • A<space> --> <space>A<space>
        • A<space><space><space>B --> <space>A<space><space>B<space>
        This method use a finite state machine to parse the text.
        Parameters:
        origin - The String to modify
        Returns:
        The modified String
      • insignificantSpacesStringInitial

        public static String insignificantSpacesStringInitial​(char[] origin)
        Remove all insignificant spaces in a Initial assertion. A String will always start with one space, every space in the middle will be doubled and if there are spaces at the end, they will be replaced by one space :
        • A --> <space>A
        • <space>A --> <space>A
        • <space><space>A --> <space>A
        • A<space> --> <space>A<space>
        • A<space>B --> <space>A<space><space>B
        This method use a finite state machine to parse the text.
        Parameters:
        origin - The String to modify
        Returns:
        The modified String
      • insignificantSpacesStringAny

        public static String insignificantSpacesStringAny​(char[] origin)
        Remove all insignificant spaces in a Any assertion. A String starting with spaces will start with exactly one space, every space in the middle will be doubled and if there are spaces at the end, they will be replaced by one space :
        • A --> A
        • <space>A --> <space>A
        • <space><space>A --> <space>A
        • A<space> --> A<space>
        • A<space><space> --> A<space>
        • A<space>B --> A<space><space>B
        This method use a finite state machine to parse the text.
        Parameters:
        origin - The String to modify
        Returns:
        The modified String
      • insignificantSpacesStringFinal

        public static String insignificantSpacesStringFinal​(char[] origin)
        Remove all insignificant spaces in a string. This method use a finite state machine to parse the text.
        Parameters:
        origin - The String to modify
        Returns:
        The modified StringBuilder
      • mapIgnoreCaseAscii

        private static String mapIgnoreCaseAscii​(String unicode)
        Map for Ascii String, case insensitive
        Parameters:
        unicode - The string to map
        Returns:
        The lower cased string
      • mapCaseSensitiveAscii

        private static String mapCaseSensitiveAscii​(String unicode)
        Map for Ascii String, case sensitive
        Parameters:
        unicode - The string to re-map
        Returns:
        The mapped string
      • mapIgnoreCase

        public static String mapIgnoreCase​(String unicode)
        Apply the RFC 4518 MAP transformation, case insensitive
        Parameters:
        unicode - The original String
        Returns:
        The mapped String