Class Stringprep


  • public final class Stringprep
    extends java.lang.Object
    Java implementation of StringPrep (RFC 3454).
    Version:
    2.0
    See Also:
    RFC 3454
    • Field Detail

      • profile

        private final Profile profile
      • mapToNothing

        private final boolean mapToNothing
      • additionalMapping

        private final boolean additionalMapping
      • caseFoldNfkc

        private final boolean caseFoldNfkc
      • caseFoldNoNormalization

        private final boolean caseFoldNoNormalization
      • normalizeKc

        private final boolean normalizeKc
      • checkBidi

        private final boolean checkBidi
      • forbidAdditionalCharacters

        private final boolean forbidAdditionalCharacters
      • forbidAsciiSpaces

        private final boolean forbidAsciiSpaces
      • forbidNonAsciiSpaces

        private final boolean forbidNonAsciiSpaces
      • forbidAsciiControl

        private final boolean forbidAsciiControl
      • forbidNonAsciiControl

        private final boolean forbidNonAsciiControl
      • forbidPrivateUse

        private final boolean forbidPrivateUse
      • forbidNonCharacter

        private final boolean forbidNonCharacter
      • forbidSurrogate

        private final boolean forbidSurrogate
      • forbidInappropriatePlainText

        private final boolean forbidInappropriatePlainText
      • forbidInappropriateCanonRep

        private final boolean forbidInappropriateCanonRep
      • forbidChangeDisplayDeprecated

        private final boolean forbidChangeDisplayDeprecated
      • forbidTagging

        private final boolean forbidTagging
      • forbidUnassigned

        private final boolean forbidUnassigned
    • Constructor Detail

      • Stringprep

        Stringprep​(Profile profile,
                   boolean storedStrings)
        Create a Stringprep instance based on a Profile Options and the two different types of strings in typical protocols where internationalized strings are used: "stored strings" and "queries".
        Parameters:
        profile - includes the options to implement a Stringprep profile.
        storedStrings - "stored strings" MUST NOT contain unassigned code points, "queries" MAY include them.
        Throws:
        java.lang.NullPointerException - if profile is null.
    • Method Detail

      • getProvider

        public static Profile getProvider​(java.lang.String profileName)
        Lookup the provider service that contains the profile.
        Parameters:
        profileName - name of the profile to lookup from the ServiceLoader.
        Returns:
        Profile if there is a provider match.
        Throws:
        java.lang.IllegalArgumentException - if no provider is found.
        java.lang.NullPointerException - if profileName is null.
      • prepare

        char[] prepare​(char[] string)
        Preparation of Internationalized Strings.

        The steps for preparing strings are:

        1. Map -- For each character in the input, check if it has a mapping and, if so, replace it with its mapping. This is described in section 3.
        2. Normalize -- Possibly normalize the result of step 1 using Unicode normalization. This is described in section 4.
        3. Prohibit -- Check for any characters that are not allowed in the output. If any are found, return an error. This is described in section 5.
        4. Check bidi -- Possibly check for right-to-left characters, and if any are found, make sure that the whole string satisfies the requirements for bidirectional strings. If the string does not satisfy the requirements for bidirectional strings, return an error. This is described in section 6.
        Parameters:
        string - to prepare.
        Returns:
        The prepared string following the options of the profile.
        Throws:
        java.lang.IllegalArgumentException - if there are prohibited or bidi characters depending on the profile used.
        java.lang.NullPointerException - if string is null.
      • map

        private char[] map​(char[] string)
      • prohibitedOutput

        private void prohibitedOutput​(int codePoint)
      • checkProhibited

        private static void checkProhibited​(boolean forbid,
                                            java.util.function.IntPredicate tableCheck,
                                            int codePoint,
                                            java.lang.String msg)