Class Stringprep

java.lang.Object
com.ongres.stringprep.Stringprep

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

    • 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 Details

    • 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:
      NullPointerException - if profile is null.
  • Method Details

    • getProvider

      public static Profile getProvider(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:
      IllegalArgumentException - if no provider is found.
      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:
      IllegalArgumentException - if there are prohibited or bidi characters depending on the profile used.
      NullPointerException - if string is null.
    • map

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

      private void prohibitedOutput(int codePoint)
    • checkProhibited

      private static void checkProhibited(boolean forbid, IntPredicate tableCheck, int codePoint, String msg)