Top Description Inners Fields Constructors Methods
com.ibm.icu.text

public final Class StringPrep

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, java.lang.ref.WeakReference, java.nio.ByteBuffer, com.ibm.icu.impl.CharTrie, .ICUBinary, .StringPrepDataReader, .UBiDiProps, com.ibm.icu.lang.UCharacter, .UCharacterDirection, com.ibm.icu.util.ICUUncheckedIOException, .VersionInfo

StringPrep API implements the StingPrep framework as described by RFC 3454. StringPrep prepares Unicode strings for use in network protocols. Profiles of StingPrep are set of rules and data according to which the Unicode Strings are prepared. Each profiles contains tables which describe how a code point should be treated. The tables are broadly classied into The procedure for preparing Unicode strings:
  1. Map: For each character in the input, check if it has a mapping and, if so, replace it with its mapping.
  2. Normalize: Possibly normalize the result of step 1 using Unicode normalization.
  3. Prohibit: Check for any characters that are not allowed in the output. If any are found, return an error.
  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.
Author
Ram Viswanadha
ICU Status
Stable since ICU 2.8.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
public static final int
ALLOW_UNASSIGNED

Option to allow processing of unassigned code points in the input

private UBiDiProps
private static final WeakReference<StringPrep>[]
private static final int
private boolean
public static final int
DEFAULT

Option to prohibit processing of unassigned code points in the input

private static final int
private boolean
private static final int
private static final int
private static final int
private int[]
private static final int
private char[]
private static final int
private static final int
private static final int
private static final int
private VersionInfo
private static final int
private static final int
private static final String[]
private static final int
public static final int
RFC3491_NAMEPREP

Profile type: RFC3491 Nameprep

public static final int
RFC3530_NFS4_CIS_PREP

Profile type: RFC3530 nfs4_cis_prep

public static final int
RFC3530_NFS4_CS_PREP

Profile type: RFC3530 nfs4_cs_prep

public static final int
RFC3530_NFS4_CS_PREP_CI

Profile type: RFC3530 nfs4_cs_prep with case insensitive option

public static final int
RFC3530_NFS4_MIXED_PREP_PREFIX

Profile type: RFC3530 nfs4_mixed_prep for prefix

public static final int
RFC3530_NFS4_MIXED_PREP_SUFFIX

Profile type: RFC3530 nfs4_mixed_prep for suffix

public static final int
RFC3722_ISCSI

Profile type: RFC3722 iSCSI

public static final int
RFC3920_NODEPREP

Profile type: RFC3920 XMPP Nodeprep

public static final int
RFC3920_RESOURCEPREP

Profile type: RFC3920 XMPP Resourceprep

public static final int
RFC4011_MIB

Profile type: RFC4011 Policy MIB Stringprep

public static final int
RFC4013_SASLPREP

Profile type: RFC4013 SASLprep

public static final int
RFC4505_TRACE

Profile type: RFC4505 trace

public static final int
RFC4518_LDAP

Profile type: RFC4518 LDAP

public static final int
RFC4518_LDAP_CI

Profile type: RFC4518 LDAP for case ignore, numeric and stored prefix matching rules

private CharTrie
private VersionInfo
private static final int
private static final int
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
public
StringPrep(InputStream
The stream for reading the StringPrep profile binarySun
inputStream
)

Creates an StringPrep object after reading the input stream.

private

Method Summary

Modifier and TypeMethod and Description
private char
public static StringPrep
getInstance(int
The profile passed to find the StringPrep instance.
profile
)

Gets a StringPrep instance for the specified profile

private static final void
getValues(char trieWord, StringPrep.Values values)

private static VersionInfo
getVersionInfo(int comp)

private static VersionInfo
getVersionInfo(byte[] version)

private StringBuffer
map(UCharacterIterator iter, int options)

private StringBuffer
public StringBuffer

Returns:

StringBuffer A StringBuffer containing the output
prepare
(UCharacterIterator
A UCharacterIterator object containing the source string
src
,
int
A bit set of options:
  • DEFAULT Prohibit processing of unassigned code points in the input
  • ALLOW_UNASSIGNED Treat the unassigned code points are in the input as normal Unicode code points.
options
)

Prepare the input buffer for use in applications with the given profile.

public String

Returns:

String A String containing the output
prepare
(String
A string
src
,
int
A bit set of options:
  • DEFAULT Prohibit processing of unassigned code points in the input
  • ALLOW_UNASSIGNED Treat the unassigned code points are in the input as normal Unicode code points.
options
)

Prepare the input String for use in applications with the given profile.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALLOW_UNASSIGNEDback to summary
public static final int ALLOW_UNASSIGNED

Option to allow processing of unassigned code points in the input

ICU Status
Stable since ICU 2.8.
See Also
prepare
bdpback to summary
private UBiDiProps bdp
CACHEback to summary
private static final WeakReference<StringPrep>[] CACHE
Annotations
@SuppressWarnings:unchecked, rawtypes
CHECK_BIDI_ONback to summary
private static final int CHECK_BIDI_ON
checkBiDiback to summary
private boolean checkBiDi
DEFAULTback to summary
public static final int DEFAULT

Option to prohibit processing of unassigned code points in the input

ICU Status
Stable since ICU 2.8.
See Also
prepare
DELETEback to summary
private static final int DELETE
doNFKCback to summary
private boolean doNFKC
FOUR_UCHARS_MAPPING_INDEX_STARTback to summary
private static final int FOUR_UCHARS_MAPPING_INDEX_START
INDEX_MAPPING_DATA_SIZEback to summary
private static final int INDEX_MAPPING_DATA_SIZE
INDEX_TOPback to summary
private static final int INDEX_TOP
indexesback to summary
private int[] indexes
MAPback to summary
private static final int MAP
mappingDataback to summary
private char[] mappingData
MAX_INDEX_VALUEback to summary
private static final int MAX_INDEX_VALUE
MAX_PROFILEback to summary
private static final int MAX_PROFILE
NORM_CORRECTNS_LAST_UNI_VERSIONback to summary
private static final int NORM_CORRECTNS_LAST_UNI_VERSION
NORMALIZATION_ONback to summary
private static final int NORMALIZATION_ON
normCorrVerback to summary
private VersionInfo normCorrVer
ONE_UCHAR_MAPPING_INDEX_STARTback to summary
private static final int ONE_UCHAR_MAPPING_INDEX_START
OPTIONSback to summary
private static final int OPTIONS
PROFILE_NAMESback to summary
private static final String[] PROFILE_NAMES
PROHIBITEDback to summary
private static final int PROHIBITED
RFC3491_NAMEPREPback to summary
public static final int RFC3491_NAMEPREP

Profile type: RFC3491 Nameprep

ICU Status
Stable since ICU 4.2.
See Also
getInstance(int)
RFC3530_NFS4_CIS_PREPback to summary
public static final int RFC3530_NFS4_CIS_PREP

Profile type: RFC3530 nfs4_cis_prep

ICU Status
Stable since ICU 4.2.
See Also
getInstance(int)
RFC3530_NFS4_CS_PREPback to summary
public static final int RFC3530_NFS4_CS_PREP

Profile type: RFC3530 nfs4_cs_prep

ICU Status
Stable since ICU 4.2.
See Also
getInstance(int)
RFC3530_NFS4_CS_PREP_CIback to summary
public static final int RFC3530_NFS4_CS_PREP_CI

Profile type: RFC3530 nfs4_cs_prep with case insensitive option

ICU Status
Stable since ICU 4.2.
See Also
getInstance(int)
RFC3530_NFS4_MIXED_PREP_PREFIXback to summary
public static final int RFC3530_NFS4_MIXED_PREP_PREFIX

Profile type: RFC3530 nfs4_mixed_prep for prefix

ICU Status
Stable since ICU 4.2.
See Also
getInstance(int)
RFC3530_NFS4_MIXED_PREP_SUFFIXback to summary
public static final int RFC3530_NFS4_MIXED_PREP_SUFFIX

Profile type: RFC3530 nfs4_mixed_prep for suffix

ICU Status
Stable since ICU 4.2.
See Also
getInstance(int)
RFC3722_ISCSIback to summary
public static final int RFC3722_ISCSI

Profile type: RFC3722 iSCSI

ICU Status
Stable since ICU 4.2.
See Also
getInstance(int)
RFC3920_NODEPREPback to summary
public static final int RFC3920_NODEPREP

Profile type: RFC3920 XMPP Nodeprep

ICU Status
Stable since ICU 4.2.
See Also
getInstance(int)
RFC3920_RESOURCEPREPback to summary
public static final int RFC3920_RESOURCEPREP

Profile type: RFC3920 XMPP Resourceprep

ICU Status
Stable since ICU 4.2.
See Also
getInstance(int)
RFC4011_MIBback to summary
public static final int RFC4011_MIB

Profile type: RFC4011 Policy MIB Stringprep

ICU Status
Stable since ICU 4.2.
See Also
getInstance(int)
RFC4013_SASLPREPback to summary
public static final int RFC4013_SASLPREP

Profile type: RFC4013 SASLprep

ICU Status
Stable since ICU 4.2.
See Also
getInstance(int)
RFC4505_TRACEback to summary
public static final int RFC4505_TRACE

Profile type: RFC4505 trace

ICU Status
Stable since ICU 4.2.
See Also
getInstance(int)
RFC4518_LDAPback to summary
public static final int RFC4518_LDAP

Profile type: RFC4518 LDAP

ICU Status
Stable since ICU 4.2.
See Also
getInstance(int)
RFC4518_LDAP_CIback to summary
public static final int RFC4518_LDAP_CI

Profile type: RFC4518 LDAP for case ignore, numeric and stored prefix matching rules

ICU Status
Stable since ICU 4.2.
See Also
getInstance(int)
sprepTrieback to summary
private CharTrie sprepTrie
sprepUniVerback to summary
private VersionInfo sprepUniVer
THREE_UCHARS_MAPPING_INDEX_STARTback to summary
private static final int THREE_UCHARS_MAPPING_INDEX_START
TWO_UCHARS_MAPPING_INDEX_STARTback to summary
private static final int TWO_UCHARS_MAPPING_INDEX_START
TYPE_LIMITback to summary
private static final int TYPE_LIMIT
TYPE_THRESHOLDback to summary
private static final int TYPE_THRESHOLD
UNASSIGNEDback to summary
private static final int UNASSIGNED

Constructor Detail

StringPrepback to summary
public StringPrep(InputStream inputStream) throws IOException

Creates an StringPrep object after reading the input stream. The object does not hold a reference to the input steam, so the stream can be closed after the method returns.

Parameters
inputStream:InputStream

The stream for reading the StringPrep profile binarySun

Exceptions
IOException:
An exception occurs when I/O of the inputstream is invalid
ICU Status
Stable since ICU 2.8.
StringPrepback to summary
private StringPrep(ByteBuffer bytes) throws IOException

Method Detail

getCodePointValueback to summary
private char getCodePointValue(int ch)
getInstanceback to summary
public static StringPrep getInstance(int profile)

Gets a StringPrep instance for the specified profile

Parameters
profile:int

The profile passed to find the StringPrep instance.

ICU Status
Stable since ICU 4.2.
getValuesback to summary
private static final void getValues(char trieWord, StringPrep.Values values)
getVersionInfoback to summary
private static VersionInfo getVersionInfo(int comp)
getVersionInfoback to summary
private static VersionInfo getVersionInfo(byte[] version)
mapback to summary
private StringBuffer map(UCharacterIterator iter, int options) throws StringPrepParseException
normalizeback to summary
private StringBuffer normalize(StringBuffer src)
prepareback to summary
public StringBuffer prepare(UCharacterIterator src, int options) throws StringPrepParseException

Prepare the input buffer for use in applications with the given profile. This operation maps, normalizes(NFKC), checks for prohibited and BiDi characters in the order defined by RFC 3454 depending on the options specified in the profile.

Parameters
src:UCharacterIterator

A UCharacterIterator object containing the source string

options:int

A bit set of options:

  • DEFAULT Prohibit processing of unassigned code points in the input
  • ALLOW_UNASSIGNED Treat the unassigned code points are in the input as normal Unicode code points.
Returns:StringBuffer

StringBuffer A StringBuffer containing the output

Exceptions
StringPrepParseException:
An exception occurs when parsing a string is invalid.
ICU Status
Stable since ICU 2.8.
prepareback to summary
public String prepare(String src, int options) throws StringPrepParseException

Prepare the input String for use in applications with the given profile. This operation maps, normalizes(NFKC), checks for prohibited and BiDi characters in the order defined by RFC 3454 depending on the options specified in the profile.

Parameters
src:String

A string

options:int

A bit set of options:

  • DEFAULT Prohibit processing of unassigned code points in the input
  • ALLOW_UNASSIGNED Treat the unassigned code points are in the input as normal Unicode code points.
Returns:String

String A String containing the output

Exceptions
StringPrepParseException:
An exception when parsing or preparing a string is invalid.
ICU Status
Stable since ICU 4.2.
com.ibm.icu.text back to summary

private final Class StringPrep.Values

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv boolean
pack-priv int
pack-priv int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

isIndexback to summary
pack-priv boolean isIndex
typeback to summary
pack-priv int type
valueback to summary
pack-priv int value

Constructor Detail

Valuesback to summary
private Values()

Method Detail

resetback to summary
public void reset()