Class PrepareString
java.lang.Object
org.apache.directory.api.ldap.model.schema.PrepareString
This class implements the 6 steps described in RFC 4518
- Author:
- Apache Directory Project
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe type of Assertion we have to normalize -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanA flag used to lowercase chars during the map processstatic final booleanA flag used to keep casing during the map process -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckProhibited(char[] value) Check that the String does not contain any prohibited charstatic StringinsignificantNumericStringHandling(char[] source) Remove all insignificant spaces in a numeric string.static StringinsignificantSpacesStringAny(char[] origin) Remove all insignificant spaces in a Any assertion.static StringinsignificantSpacesStringFinal(char[] origin) Remove all insignificant spaces in a string.static StringinsignificantSpacesStringInitial(char[] origin) Remove all insignificant spaces in a Initial assertion.static StringinsignificantSpacesStringValue(char[] origin) Remove all insignificant spaces in a string.static StringinsignificantTelephoneNumberStringHandling(char[] source) Remove all insignificant spaces in a TelephoneNumber string, Hyphen and spaces.static StringmapCaseSensitive(String unicode) Apply the RFC 4518 MAP transformation, case sensitivestatic StringmapIgnoreCase(String unicode) Apply the RFC 4518 MAP transformation, case insensitivestatic StringNormalize a Stringstatic Stringtranscode(byte[] bytes) The first step defined by RFC 4518 : Transcode, which transform an UTF-8 encoded String to Unicode.
-
Field Details
-
CASE_SENSITIVE
public static final boolean CASE_SENSITIVEA flag used to lowercase chars during the map process- See Also:
-
IGNORE_CASE
public static final boolean IGNORE_CASEA flag used to keep casing during the map process- See Also:
-
-
Method Details
-
transcode
The first step defined by RFC 4518 : Transcode, which transform an UTF-8 encoded String to Unicode. This is done using theStrings.utf8ToString(byte[])method. This- Parameters:
bytes- The byte[] to transcode- Returns:
- The transcoded String
-
normalize
-
mapCaseSensitive
-
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
-
insignificantNumericStringHandling
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
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
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>
- Parameters:
origin- The String to modify- Returns:
- The modified String
-
insignificantSpacesStringInitial
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
- Parameters:
origin- The String to modify- Returns:
- The modified String
-
insignificantSpacesStringAny
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
- Parameters:
origin- The String to modify- Returns:
- The modified String
-
insignificantSpacesStringFinal
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
-
mapIgnoreCase
-