Package com.ongres.stringprep
Class Stringprep
- java.lang.Object
-
- com.ongres.stringprep.Stringprep
-
public final class Stringprep extends java.lang.Object
Java implementation of StringPrep (RFC 3454).- Version:
- 2.0
- See Also:
- RFC 3454
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
additionalMapping
private boolean
caseFoldNfkc
private boolean
caseFoldNoNormalization
private boolean
checkBidi
private boolean
forbidAdditionalCharacters
private boolean
forbidAsciiControl
private boolean
forbidAsciiSpaces
private boolean
forbidChangeDisplayDeprecated
private boolean
forbidInappropriateCanonRep
private boolean
forbidInappropriatePlainText
private boolean
forbidNonAsciiControl
private boolean
forbidNonAsciiSpaces
private boolean
forbidNonCharacter
private boolean
forbidPrivateUse
private boolean
forbidSurrogate
private boolean
forbidTagging
private boolean
forbidUnassigned
private boolean
mapToNothing
private boolean
normalizeKc
private Profile
profile
-
Constructor Summary
Constructors Constructor Description Stringprep(Profile profile, boolean storedStrings)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
checkProhibited(boolean forbid, java.util.function.IntPredicate tableCheck, int codePoint, java.lang.String msg)
static Profile
getProvider(java.lang.String profileName)
Lookup the provider service that contains the profile.private char[]
map(char[] string)
(package private) char[]
prepare(char[] string)
Preparation of Internationalized Strings.private void
prohibitedOutput(int codePoint)
-
-
-
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 aProfile
Option
s 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
- ifprofile
isnull
.
-
-
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
- ifprofileName
isnull
.
-
prepare
char[] prepare(char[] string)
Preparation of Internationalized Strings.The steps for preparing strings are:
- 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.
- Normalize -- Possibly normalize the result of step 1 using Unicode normalization. This is described in section 4.
- 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.
- 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
- ifstring
isnull
.
-
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)
-
-