org.opends.server.types
Class NamedCharacterSet

java.lang.Object
  extended by org.opends.server.types.NamedCharacterSet

@PublicAPI(stability=VOLATILE,
           mayInstantiate=true,
           mayExtend=false,
           mayInvoke=true)
public final class NamedCharacterSet
extends java.lang.Object

This class provides a data structure that makes it possible to associate a name with a given set of characters. The name must consist only of ASCII alphabetic characters.


Constructor Summary
NamedCharacterSet(java.lang.String name, char[] characters)
          Creates a new named character set with the provided information.
NamedCharacterSet(java.lang.String name, char[] characters, java.util.Random random)
          Creates a new named character set with the provided information.
 
Method Summary
static NamedCharacterSet[] decodeCharacterSets(java.util.SortedSet<java.lang.String> values)
          Decodes the values of the provided configuration attribute as a set of character set definitions.
 java.lang.String encode()
          Encodes this character set to a form suitable for use in the value of a configuration attribute.
 char[] getCharacters()
          Retrieves the characters included in this character set.
 java.lang.String getName()
          Retrieves the name for this character set.
 char getRandomCharacter()
          Retrieves a character at random from this named character set.
 void getRandomCharacters(java.lang.StringBuilder buffer, int count)
          Appends the specified number of characters chosen at random from this character set to the provided buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamedCharacterSet

public NamedCharacterSet(java.lang.String name,
                         char[] characters)
                  throws ConfigException
Creates a new named character set with the provided information.

Parameters:
name - The name for this character set.
characters - The characters to include in this character set.
Throws:
ConfigException - If the provided name contains one or more illegal characters.

NamedCharacterSet

public NamedCharacterSet(java.lang.String name,
                         char[] characters,
                         java.util.Random random)
                  throws ConfigException
Creates a new named character set with the provided information.

Parameters:
name - The name for this character set.
characters - The characters to include in this character set.
random - The random number generator to use with this character set.
Throws:
ConfigException - If the provided name contains one or more illegal characters.
Method Detail

getName

public java.lang.String getName()
Retrieves the name for this character set.

Returns:
The name for this character set.

getCharacters

public char[] getCharacters()
Retrieves the characters included in this character set.

Returns:
The characters included in this character set.

getRandomCharacter

public char getRandomCharacter()
Retrieves a character at random from this named character set.

Returns:
The randomly-selected character from this named character set;

getRandomCharacters

public void getRandomCharacters(java.lang.StringBuilder buffer,
                                int count)
Appends the specified number of characters chosen at random from this character set to the provided buffer.

Parameters:
buffer - The buffer to which the characters should be appended.
count - The number of characters to append to the provided buffer.

encode

public java.lang.String encode()
Encodes this character set to a form suitable for use in the value of a configuration attribute.

Returns:
The encoded character set in a form suitable for use in the value of a configuration attribute.

decodeCharacterSets

public static NamedCharacterSet[] decodeCharacterSets(java.util.SortedSet<java.lang.String> values)
                                               throws ConfigException
Decodes the values of the provided configuration attribute as a set of character set definitions.

Parameters:
values - The set of encoded character set values to decode.
Returns:
The decoded character set definitions.
Throws:
ConfigException - If a problem occurs while attempting to decode the character set definitions.