com.ibm.icu.text
Class StringPrep

java.lang.Object
  extended by com.ibm.icu.text.StringPrep

public final class StringPrep
extends Object

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
Status:
Stable ICU 2.8.

Field Summary
static int ALLOW_UNASSIGNED
          Option to allow processing of unassigned code points in the input
static int DEFAULT
          Option to prohibit processing of unassigned code points in the input
static int RFC3491_NAMEPREP
          Profile type: RFC3491 Nameprep
static int RFC3530_NFS4_CIS_PREP
          Profile type: RFC3530 nfs4_cis_prep
static int RFC3530_NFS4_CS_PREP
          Profile type: RFC3530 nfs4_cs_prep
static int RFC3530_NFS4_CS_PREP_CI
          Profile type: RFC3530 nfs4_cs_prep with case insensitive option
static int RFC3530_NFS4_MIXED_PREP_PREFIX
          Profile type: RFC3530 nfs4_mixed_prep for prefix
static int RFC3530_NFS4_MIXED_PREP_SUFFIX
          Profile type: RFC3530 nfs4_mixed_prep for suffix
static int RFC3722_ISCSI
          Profile type: RFC3722 iSCSI
static int RFC3920_NODEPREP
          Profile type: RFC3920 XMPP Nodeprep
static int RFC3920_RESOURCEPREP
          Profile type: RFC3920 XMPP Resourceprep
static int RFC4011_MIB
          Profile type: RFC4011 Policy MIB Stringprep
static int RFC4013_SASLPREP
          Profile type: RFC4013 SASLprep
static int RFC4505_TRACE
          Profile type: RFC4505 trace
static int RFC4518_LDAP
          Profile type: RFC4518 LDAP
static int RFC4518_LDAP_CI
          Profile type: RFC4518 LDAP for case ignore, numeric and stored prefix matching rules
 
Constructor Summary
StringPrep(InputStream inputStream)
          Creates an StringPrep object after reading the input stream.
 
Method Summary
static StringPrep getInstance(int profile)
          Gets a StringPrep instance for the specified profile
 String prepare(String src, int options)
          Prepare the input String for use in applications with the given profile.
 StringBuffer prepare(UCharacterIterator src, int options)
          Prepare the input buffer for use in applications with the given profile.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT

public static final int DEFAULT
Option to prohibit processing of unassigned code points in the input

See Also:
prepare(com.ibm.icu.text.UCharacterIterator, int), Constant Field Values
Status:
Stable ICU 2.8.

ALLOW_UNASSIGNED

public static final int ALLOW_UNASSIGNED
Option to allow processing of unassigned code points in the input

See Also:
prepare(com.ibm.icu.text.UCharacterIterator, int), Constant Field Values
Status:
Stable ICU 2.8.

RFC3491_NAMEPREP

public static final int RFC3491_NAMEPREP
Profile type: RFC3491 Nameprep

See Also:
getInstance(int), Constant Field Values
Status:
Stable ICU 4.2.

RFC3530_NFS4_CS_PREP

public static final int RFC3530_NFS4_CS_PREP
Profile type: RFC3530 nfs4_cs_prep

See Also:
getInstance(int), Constant Field Values
Status:
Stable ICU 4.2.

RFC3530_NFS4_CS_PREP_CI

public static final int RFC3530_NFS4_CS_PREP_CI
Profile type: RFC3530 nfs4_cs_prep with case insensitive option

See Also:
getInstance(int), Constant Field Values
Status:
Stable ICU 4.2.

RFC3530_NFS4_CIS_PREP

public static final int RFC3530_NFS4_CIS_PREP
Profile type: RFC3530 nfs4_cis_prep

See Also:
getInstance(int), Constant Field Values
Status:
Stable ICU 4.2.

RFC3530_NFS4_MIXED_PREP_PREFIX

public static final int RFC3530_NFS4_MIXED_PREP_PREFIX
Profile type: RFC3530 nfs4_mixed_prep for prefix

See Also:
getInstance(int), Constant Field Values
Status:
Stable ICU 4.2.

RFC3530_NFS4_MIXED_PREP_SUFFIX

public static final int RFC3530_NFS4_MIXED_PREP_SUFFIX
Profile type: RFC3530 nfs4_mixed_prep for suffix

See Also:
getInstance(int), Constant Field Values
Status:
Stable ICU 4.2.

RFC3722_ISCSI

public static final int RFC3722_ISCSI
Profile type: RFC3722 iSCSI

See Also:
getInstance(int), Constant Field Values
Status:
Stable ICU 4.2.

RFC3920_NODEPREP

public static final int RFC3920_NODEPREP
Profile type: RFC3920 XMPP Nodeprep

See Also:
getInstance(int), Constant Field Values
Status:
Stable ICU 4.2.

RFC3920_RESOURCEPREP

public static final int RFC3920_RESOURCEPREP
Profile type: RFC3920 XMPP Resourceprep

See Also:
getInstance(int), Constant Field Values
Status:
Stable ICU 4.2.

RFC4011_MIB

public static final int RFC4011_MIB
Profile type: RFC4011 Policy MIB Stringprep

See Also:
getInstance(int), Constant Field Values
Status:
Stable ICU 4.2.

RFC4013_SASLPREP

public static final int RFC4013_SASLPREP
Profile type: RFC4013 SASLprep

See Also:
getInstance(int), Constant Field Values
Status:
Stable ICU 4.2.

RFC4505_TRACE

public static final int RFC4505_TRACE
Profile type: RFC4505 trace

See Also:
getInstance(int), Constant Field Values
Status:
Stable ICU 4.2.

RFC4518_LDAP

public static final int RFC4518_LDAP
Profile type: RFC4518 LDAP

See Also:
getInstance(int), Constant Field Values
Status:
Stable ICU 4.2.

RFC4518_LDAP_CI

public static final int RFC4518_LDAP_CI
Profile type: RFC4518 LDAP for case ignore, numeric and stored prefix matching rules

See Also:
getInstance(int), Constant Field Values
Status:
Stable ICU 4.2.
Constructor Detail

StringPrep

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 - The stream for reading the StringPrep profile binarySun
Throws:
IOException - An exception occurs when I/O of the inputstream is invalid
Status:
Stable ICU 2.8.
Method Detail

getInstance

public static StringPrep getInstance(int profile)
Gets a StringPrep instance for the specified profile

Parameters:
profile - The profile passed to find the StringPrep instance.
Status:
Stable ICU 4.2.

prepare

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 - A UCharacterIterator object containing the source string
options - A bit set of options: - StringPrep.NONE Prohibit processing of unassigned code points in the input - StringPrep.ALLOW_UNASSIGNED Treat the unassigned code points are in the input as normal Unicode code points.
Returns:
StringBuffer A StringBuffer containing the output
Throws:
StringPrepParseException - An exception occurs when parsing a string is invalid.
Status:
Stable ICU 2.8.

prepare

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 - A string
options - A bit set of options: - StringPrep.NONE Prohibit processing of unassigned code points in the input - StringPrep.ALLOW_UNASSIGNED Treat the unassigned code points are in the input as normal Unicode code points.
Returns:
String A String containing the output
Throws:
StringPrepParseException - An exception when parsing or preparing a string is invalid.
Status:
Stable ICU 4.2.


Copyright (c) 2011 IBM Corporation and others.