org.databene.commons
Class CharSet

java.lang.Object
  extended by org.databene.commons.CharSet

public class CharSet
extends java.lang.Object

Represents a Set of characters and provides locale-dependent character sets as well as set manipulation methods. Created: 18.08.2006 19:49:17

Author:
Volker Bergmann

Constructor Summary
CharSet()
          Default constructor that initializes to an isEmpty Set of characters with the fallback locale
CharSet(char c)
          Constructor that initializes to a Set with one character with the fallback locale
CharSet(char from, char to)
           
CharSet(CharSet charSet)
          Constructor that initializes to a predefined Set of characters with the fallback locale
CharSet(java.util.Locale locale)
          Constructor that initializes to an isEmpty Set of characters with the specified locale
CharSet(java.util.Set<java.lang.Character> set)
          Constructor that initializes to a predefined Set of characters with the fallback locale
CharSet(java.lang.String name, char from, char to)
          Constructor that initializes to a continuous range of characters with the fallback locale
CharSet(java.lang.String name, java.util.Set<java.lang.Character> set)
           
 
Method Summary
 CharSet add(char c)
          Adds a single character
 CharSet addAll(java.util.Set<java.lang.Character> chars)
          Adds a set of characters
 CharSet addAnyCharacters()
          Adds any character
 CharSet addDigits()
           
 CharSet addHexDigits()
           
 CharSet addNonDigits()
           
 CharSet addNonWhitespaces()
          Adds all characters that are not white spaces
 CharSet addNonWordChars()
          Adds all characters that are not letters of any locale
 CharSet addRange(char from, char to)
          Adds a range of characters
 CharSet addWhitespaces()
          Adds all whitespace characters
 CharSet addWordChars()
          Adds all letters of the internal locale to the Set
 CharSet addWordChars(java.util.Locale locale)
          Adds all letters of the specified locale to the Set
 boolean contains(char c)
           
 boolean containsAll(java.util.Set<java.lang.Character> set)
           
 boolean equals(java.lang.Object o)
          Compares with another Set, ignoring the locale.
static java.util.Set<java.lang.Character> getAnyCharacters()
          Returns any characters
static java.util.Set<java.lang.Character> getDigits()
           
static java.util.Set<java.lang.Character> getHexDigits()
           
static java.util.Set<java.lang.Character> getNonDigits()
           
static java.util.Set<java.lang.Character> getNonWhitespaces()
          Returns a set of all characters that are not white spaces
static java.util.Set<java.lang.Character> getNonWordChars()
          Returns all characters that are not letters of any locale
 java.util.Set<java.lang.Character> getSet()
          Returns a copy of the wrapped Set as HashSet
static java.util.Set<java.lang.Character> getWhitespaces()
          Returns all whitespace characters
static java.util.Set<java.lang.Character> getWordChars(java.util.Locale locale)
          Returns all letters of the specified locale
 int hashCode()
          Calculates the Set's hashCode, ignoring the locale.
 java.util.Iterator<java.lang.Character> iterator()
           
 CharSet remove(char c)
          removes one character
 CharSet removeAll()
          clears the set
 CharSet removeAll(java.util.Set<java.lang.Character> chars)
          Removes all characters of the specified set
 CharSet removeDigits()
           
 CharSet removeHexDigits()
           
 CharSet removeNonDigits()
           
 CharSet removeNonWhitespaces()
          Removes all characters that are not white spaces
 CharSet removeNonWordChars()
          Removes all characters that are not letters of any locale
 CharSet removeRange(char min, char max)
          Removes a range of characters
 CharSet removeWhitespaces()
          Removes all whitespace characters
 CharSet removeWordChars()
          Removes all letters of the internal locale from the Set
 CharSet removeWordChars(java.util.Locale locale)
          Removes all letters of the specified locale from the Set
 int size()
           
 java.lang.String toString()
          Returns a String representation of the Set
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CharSet

public CharSet()
Default constructor that initializes to an isEmpty Set of characters with the fallback locale


CharSet

public CharSet(java.util.Locale locale)
Constructor that initializes to an isEmpty Set of characters with the specified locale


CharSet

public CharSet(char c)
Constructor that initializes to a Set with one character with the fallback locale


CharSet

public CharSet(char from,
               char to)

CharSet

public CharSet(java.lang.String name,
               char from,
               char to)
Constructor that initializes to a continuous range of characters with the fallback locale


CharSet

public CharSet(CharSet charSet)
Constructor that initializes to a predefined Set of characters with the fallback locale


CharSet

public CharSet(java.util.Set<java.lang.Character> set)
Constructor that initializes to a predefined Set of characters with the fallback locale


CharSet

public CharSet(java.lang.String name,
               java.util.Set<java.lang.Character> set)
Method Detail

addDigits

public CharSet addDigits()

removeDigits

public CharSet removeDigits()

addHexDigits

public CharSet addHexDigits()

removeHexDigits

public CharSet removeHexDigits()

addNonDigits

public CharSet addNonDigits()

removeNonDigits

public CharSet removeNonDigits()

getDigits

public static java.util.Set<java.lang.Character> getDigits()

getHexDigits

public static java.util.Set<java.lang.Character> getHexDigits()

getNonDigits

public static java.util.Set<java.lang.Character> getNonDigits()

addWordChars

public CharSet addWordChars()
Adds all letters of the internal locale to the Set


addWordChars

public CharSet addWordChars(java.util.Locale locale)
Adds all letters of the specified locale to the Set


removeWordChars

public CharSet removeWordChars()
Removes all letters of the internal locale from the Set


removeWordChars

public CharSet removeWordChars(java.util.Locale locale)
Removes all letters of the specified locale from the Set


getWordChars

public static java.util.Set<java.lang.Character> getWordChars(java.util.Locale locale)
Returns all letters of the specified locale


addNonWordChars

public CharSet addNonWordChars()
Adds all characters that are not letters of any locale


removeNonWordChars

public CharSet removeNonWordChars()
Removes all characters that are not letters of any locale


getNonWordChars

public static java.util.Set<java.lang.Character> getNonWordChars()
Returns all characters that are not letters of any locale


addWhitespaces

public CharSet addWhitespaces()
Adds all whitespace characters

Returns:
this

removeWhitespaces

public CharSet removeWhitespaces()
Removes all whitespace characters

Returns:
this

getWhitespaces

public static java.util.Set<java.lang.Character> getWhitespaces()
Returns all whitespace characters

Returns:
a Set of all whitespace charaters

addNonWhitespaces

public CharSet addNonWhitespaces()
Adds all characters that are not white spaces

Returns:
this

removeNonWhitespaces

public CharSet removeNonWhitespaces()
Removes all characters that are not white spaces

Returns:
this

getNonWhitespaces

public static java.util.Set<java.lang.Character> getNonWhitespaces()
Returns a set of all characters that are not white spaces

Returns:
a set of all characters that are not white spaces

addAnyCharacters

public CharSet addAnyCharacters()
Adds any character


getAnyCharacters

public static java.util.Set<java.lang.Character> getAnyCharacters()
Returns any characters

Returns:
a set of any characters

removeAll

public CharSet removeAll()
clears the set

Returns:
this

addRange

public CharSet addRange(char from,
                        char to)
Adds a range of characters

Returns:
this

add

public CharSet add(char c)
Adds a single character

Returns:
this

addAll

public CharSet addAll(java.util.Set<java.lang.Character> chars)
Adds a set of characters

Returns:
this

removeAll

public CharSet removeAll(java.util.Set<java.lang.Character> chars)
Removes all characters of the specified set

Parameters:
chars -
Returns:
this

removeRange

public CharSet removeRange(char min,
                           char max)
Removes a range of characters

Parameters:
min -
max -
Returns:
this

remove

public CharSet remove(char c)
removes one character

Parameters:
c -
Returns:
this

getSet

public java.util.Set<java.lang.Character> getSet()
Returns a copy of the wrapped Set as HashSet

Returns:
a copy of the wrapped Set as HashSet

iterator

public java.util.Iterator<java.lang.Character> iterator()

contains

public boolean contains(char c)

size

public int size()

containsAll

public boolean containsAll(java.util.Set<java.lang.Character> set)

toString

public java.lang.String toString()
Returns a String representation of the Set

Overrides:
toString in class java.lang.Object
Returns:
a String representation of the Set
See Also:
Object

equals

public boolean equals(java.lang.Object o)
Compares with another Set, ignoring the locale.

Overrides:
equals in class java.lang.Object
See Also:
Object

hashCode

public int hashCode()
Calculates the Set's hashCode, ignoring the locale.

Overrides:
hashCode in class java.lang.Object
Returns:
the Set'S hash code
See Also:
Object


Copyright © 2010. All Rights Reserved.