Class PrepareString
- java.lang.Object
-
- org.apache.directory.api.ldap.model.schema.PrepareString
-
public final class PrepareString extends Object
This class implements the 6 steps described in RFC 4518- Author:
- Apache Directory Project
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PrepareString.AssertionType
The type of Assertion we have to normalize
-
Field Summary
Fields Modifier and Type Field Description static boolean
CASE_SENSITIVE
A flag used to lowercase chars during the map processstatic boolean
IGNORE_CASE
A flag used to keep casing during the map process
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkProhibited(char[] value)
Check that the String does not contain any prohibited charstatic String
insignificantNumericStringHandling(char[] source)
Remove all insignificant spaces in a numeric string.static String
insignificantSpacesStringAny(char[] origin)
Remove all insignificant spaces in a Any assertion.static String
insignificantSpacesStringFinal(char[] origin)
Remove all insignificant spaces in a string.static String
insignificantSpacesStringInitial(char[] origin)
Remove all insignificant spaces in a Initial assertion.static String
insignificantSpacesStringValue(char[] origin)
Remove all insignificant spaces in a string.static String
insignificantTelephoneNumberStringHandling(char[] source)
Remove all insignificant spaces in a TelephoneNumber string, Hyphen and spaces.static String
mapCaseSensitive(String unicode)
Apply the RFC 4518 MAP transformation, case sensitivestatic String
mapIgnoreCase(String unicode)
Apply the RFC 4518 MAP transformation, case insensitivestatic String
normalize(String value)
Normalize a Stringstatic String
transcode(byte[] bytes)
The first step defined by RFC 4518 : Transcode, which transform an UTF-8 encoded String to Unicode.
-
-
-
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
-
-
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 theStrings.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 InvalidCharacterException
Check that the String does not contain any prohibited char- Parameters:
value
- The String to analyze- Throws:
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>
- 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
- 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
- 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
-
mapIgnoreCase
public static String mapIgnoreCase(String unicode)
Apply the RFC 4518 MAP transformation, case insensitive- Parameters:
unicode
- The original String- Returns:
- The mapped String
-
-