java::lang::Character Class Reference

Inheritance diagram for java::lang::Character:

Inheritance graph
java::lang::Objectjava::lang::Interfacejava::lang::Comparable
[legend]
Collaboration diagram for java::lang::Character:

Collaboration graph
java::lang::Objectjava::lang::Interfacejava::lang::Comparable
[legend]

List of all members.


Detailed Description

The Character class wraps a value of the primitive type char in an object.

An object of type Character contains a single field whose type is char.

In addition, this class provides several methods for determining the type of a character and converting characters from uppercase to lowercase and vice versa.

Many of the methods of class Character are defined in terms of a "Unicode attribute table" that specifies a name for every defined Unicode code point. The table also includes other attributes, such as a decimal value, an uppercase equivalent, a lowercase equivalent, and/or a titlecase equivalent. The character attribute tables for specific versions of Unicode are available on the World Wide Web in various subdirectories of: <blockquote>

   ftp://ftp.unicode.org/Public/
 
</blockquote>

For a more detailed specification of the Character class, one that encompasses the exact behavior of methods such as isDigit, isLetter, isLowerCase, and isUpperCase over the full range of Unicode values, see Gosling, Joy, and Steele, The Java Language Specification.

Author:
Lee Boynton

Guy Steele

Akira Tanaka

Yuh-Jye Chang

Version:
1.61, 02/02/00
Since:
JDK1.0

Public Types

enum  TYPE {
  UNASSIGNED, UPPERCASE_LETTER, LOWERCASE_LETTER, TITLECASE_LETTER,
  MODIFIER_LETTER, OTHER_LETTER, NON_SPACING_MARK, ENCLOSING_MARK,
  COMBINING_SPACING_MARK, DECIMAL_DIGIT_NUMBER, LETTER_NUMBER, OTHER_NUMBER,
  SPACE_SEPARATOR, LINE_SEPARATOR, PARAGRAPH_SEPARATOR, CONTROL,
  FORMAT, UNKNOWN_USE, PRIVATE_USE, SURROGATE,
  DASH_PUNCTUATION, START_PUNCTUATION, END_PUNCTUATION, CONNECTOR_PUNCTUATION,
  OTHER_PUNCTUATION, MATH_SYMBOL, CURRENCY_SYMBOL, MODIFIER_SYMBOL,
  OTHER_SYMBOL
}
 Public data for enumerated Unicode general category types. More...

Public Member Functions

 Character (jchar _value=0)
 Constructs a Character object and initializes it so that it represents the primitive value argument.
 operator jchar & ()
virtual jchar charValue () const
 Returns the value of this Character object.
virtual jboolean equals (const Object &src) const
 Compares this object against the specified object.
virtual jint hashCode () const
 Returns a hash code for this Character.
virtual jint compareTo (const Object &src) const
 Compares this Character to another Object.
String toString () const
 Returns a String object representing this character's value.

Static Public Member Functions

static jboolean isLowerCase (jchar ch)
 Determines if the specified character is a lowercase character.
static jboolean isUpperCase (jchar ch)
 Determines if the specified character is an uppercase character.
static jboolean isTitleCase (jchar ch)
 Determines if the specified character is a titlecase character.
static jboolean isDigit (jchar ch)
 Determines if the specified character is a digit.
static jboolean isDefined (jchar ch)
 Determines if a character has a defined meaning in Unicode.
static jboolean isLetter (jchar ch)
 Determines if the specified character is a letter.
static jboolean isLetterOrDigit (jchar ch)
 Determines if the specified character is a letter or digit.
static jboolean isJavaIdentifierStart (jchar ch)
 Determines if the specified character is permissible as the first character in a Java identifier.
static jboolean isJavaIdentifierPart (jchar ch)
 Determines if the specified character may be part of a Java identifier as other than the first character.
static jboolean isUnicodeIdentifierStart (jchar ch)
 Determines if the specified character is permissible as the first character in a Unicode identifier.
static jboolean isUnicodeIdentifierPart (jchar ch)
 Determines if the specified character may be part of a Unicode identifier as other than the first character.
static jboolean isIdentifierIgnorable (jchar ch)
 Determines if the specified character should be regarded as an ignorable character in a Java identifier or a Unicode identifier.
static jchar toLowerCase (jchar ch)
 The given character is mapped to its lowercase equivalent; if the character has no lowercase equivalent, the character itself is returned.
static jchar toUpperCase (jchar ch)
 Converts the character argument to uppercase.
static jchar toTitleCase (jchar ch)
 Converts the character argument to titlecase.
static jint digit (jchar ch, jint radix=10)
 Returns the numeric value of the character ch in the specified radix.
static jint getNumericValue (jchar ch)
 Returns the Unicode numeric value of the character as a nonnegative integer.
static jboolean isSpaceChar (jchar ch)
 Determines if the specified character is a Unicode space character.
static jboolean isWhitespace (jchar ch)
 Determines if the specified character is white space according to Java.
static jboolean isISOControl (jchar ch)
 Determines if the specified character is an ISO control character.
static jint getType (jchar ch)
 Returns a value indicating a character category.
static jchar forDigit (jint digit, jint radix=10)
 Determines the character representation for a specific digit in the specified radix.

Static Public Attributes

static const jint MIN_RADIX
 The minimum radix available for conversion to and from Strings.
static const jint MAX_RADIX
 The maximum radix available for conversion to and from Strings.
static const jchar MIN_VALUE
 The constant value of this field is the smallest value of type char.
static const jchar MAX_VALUE
 The constant value of this field is the largest value of type char.

Classes

class  Subset
 Instances of this class represent particular subsets of the Unicode character set. More...
class  UnicodeBlock
 A family of character subsets representing the character blocks defined by the Unicode 2.0 specification. More...

Member Enumeration Documentation

enum java::lang::Character::TYPE

Public data for enumerated Unicode general category types.

Since:
JDK1.1
Enumerator:
UNASSIGNED 
UPPERCASE_LETTER 
LOWERCASE_LETTER 
TITLECASE_LETTER 
MODIFIER_LETTER 
OTHER_LETTER 
NON_SPACING_MARK 
ENCLOSING_MARK 
COMBINING_SPACING_MARK 
DECIMAL_DIGIT_NUMBER 
LETTER_NUMBER 
OTHER_NUMBER 
SPACE_SEPARATOR 
LINE_SEPARATOR 
PARAGRAPH_SEPARATOR 
CONTROL 
FORMAT 
UNKNOWN_USE 
PRIVATE_USE 
SURROGATE 
DASH_PUNCTUATION 
START_PUNCTUATION 
END_PUNCTUATION 
CONNECTOR_PUNCTUATION 
OTHER_PUNCTUATION 
MATH_SYMBOL 
CURRENCY_SYMBOL 
MODIFIER_SYMBOL 
OTHER_SYMBOL 


Constructor & Destructor Documentation

java::lang::Character::Character ( jchar  _value = 0  ) 

Constructs a Character object and initializes it so that it represents the primitive value argument.

Parameters:
value value for the new Character object.


Member Function Documentation

java::lang::Character::operator jchar & (  ) 

virtual jchar java::lang::Character::charValue (  )  const [virtual]

Returns the value of this Character object.

Returns:
the primitive char value represented by this object.

virtual jboolean java::lang::Character::equals ( const Object src  )  const [virtual]

Compares this object against the specified object.

The result is true if and only if the argument is not null and is a Character object that represents the same char value as this object.

Parameters:
obj the object to compare with.
Returns:
true if the objects are the same; false otherwise.

Reimplemented from java::lang::Object.

virtual jint java::lang::Character::hashCode (  )  const [virtual]

Returns a hash code for this Character.

Returns:
a hash code value for this object.

Reimplemented from java::lang::Object.

virtual jint java::lang::Character::compareTo ( const Object src  )  const [virtual]

Compares this Character to another Object.

If the Object is a Character, this function behaves like compareTo(Character). Otherwise, it throws a ClassCastException (as Characters are comparable only to other Characters).

Parameters:
o the Object to be compared.
Returns:
the value 0 if the argument is a Character numerically equal to this Character; a value less than 0 if the argument is a Character numerically greater than this Character; and a value greater than 0 if the argument is a Character numerically less than this Character.
Exceptions:
<code>ClassCastException</code> if the argument is not a Character.
Since:
1.2

Reimplemented from java::lang::Comparable.

String java::lang::Character::toString (  )  const [virtual]

Returns a String object representing this character's value.

Converts this Character object to a string. The result is a string whose length is 1. The string's sole component is the primitive char value represented by this object.

Returns:
a string representation of this object.

Reimplemented from java::lang::Object.

static jboolean java::lang::Character::isLowerCase ( jchar  ch  )  [static]

Determines if the specified character is a lowercase character.

A character is lowercase if it is not in the range '&#92;u2000' through '&#92;u2FFF', the Unicode attribute table does not specify a mapping to lowercase for the character, and at least one of the following is true:

A character is considered to be lowercase if and only if it is specified to be lowercase by the Unicode 2.0 standard (category "Ll" in the Unicode specification data file).

Of the ISO-LATIN-1 characters (character codes 0x0000 through 0x00FF), the following are lowercase:

<blockquote>

 a b c d e f g h i j k l m n o p q r s t u v w x y z
 &#92;u00DF &#92;u00E0 &#92;u00E1 &#92;u00E2 &#92;u00E3 &#92;u00E4 &#92;u$
 &#92;u00E8 &#92;u00E9 &#92;u00EA &#92;u00EB &#92;u00EC &#92;u00ED &#92;u$
 &#92;u00F1 &#92;u00F2 &#92;u00F3 &#92;u00F4 &#92;u00F5 &#92;u00F6 &#92;u$
 &#92;u00FB &#92;u00FC &#92;u00FD &#92;u00FE &#92;u00FF
 
</blockquote>

Many other Unicode characters are lowercase, too.

Parameters:
ch the character to be tested.
Returns:
true if the character is lowercase; false otherwise.

static jboolean java::lang::Character::isUpperCase ( jchar  ch  )  [static]

Determines if the specified character is an uppercase character.

A character is uppercase if it is not in the range '&#92;u2000' through '&#92;u2FFF', the Unicode attribute table does not specify a mapping to uppercase for the character, and at least one of the following is true:

Of the ISO-LATIN-1 characters (character codes 0x0000 through 0x00FF), the following are uppercase:

<blockquote>

 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z   
 &#92;u00C0 &#92;u00C1 &#92;u00C2 &#92;u00C3 &#92;u00C4 &#92;u00C5 &#92;u$
 &#92;u00C8 &#92;u00C9 &#92;u00CA &#92;u00CB &#92;u00CC &#92;u00CD &#92;u$
 &#92;u00D1 &#92;u00D2 &#92;u00D3 &#92;u00D4 &#92;u00D5 &#92;u00D6 &#92;u$
 &#92;u00DB &#92;u00DC &#92;u00DD &#92;u00DE
 
</blockquote>

Many other Unicode characters are uppercase, too.

Parameters:
ch the character to be tested.
Returns:
true if the character is uppercase; false otherwise.

static jboolean java::lang::Character::isTitleCase ( jchar  ch  )  [static]

Determines if the specified character is a titlecase character.

A character is considered to be titlecase if and only if it is specified to be titlecase by the Unicode 2.0 standard (category "Lt" in the Unicode specification data file).

The printed representations of four Unicode characters look like pairs of Latin letters. For example, there is an uppercase letter that looks like "LJ" and has a corresponding lowercase letter that looks like "lj". A third form, which looks like "Lj", is the appropriate form to use when rendering a word in lowercase with initial capitals, as for a book title.

These are the Unicode characters for which this method returns true:

Parameters:
ch the character to be tested.
Returns:
true if the character is titlecase; false otherwise.

static jboolean java::lang::Character::isDigit ( jchar  ch  )  [static]

Determines if the specified character is a digit.

A character is considered to be a digit if it is not in the range '&#92;u2000' <= ch <= '&#92;u2FFF' and its Unicode name contains the word "<code>DIGIT</code>". For a more complete specification that encompasses all Unicode characters that are defined as digits, see Gosling, Joy, and Steele, The Java Language Specification.

These are the ranges of Unicode characters that are considered digits:
0x0030 through 0x0039 ISO-LATIN-1 digits ('0' through '9')
0x0660 through 0x0669 Arabic-Indic digits
0x06F0 through 0x06F9 Extended Arabic-Indic digits
0x0966 through 0x096F Devanagari digits
0x09E6 through 0x09EF Bengali digits
0x0A66 through 0x0A6F Gurmukhi digits
0x0AE6 through 0x0AEF Gujarati digits
0x0B66 through 0x0B6F Oriya digits
0x0BE7 through 0x0BEF Tamil digits
0x0C66 through 0x0C6F Telugu digits
0x0CE6 through 0x0CEF Kannada digits
0x0D66 through 0x0D6F Malayalam digits
0x0E50 through 0x0E59 Thai digits
0x0ED0 through 0x0ED9 Lao digits
0x0F20 through 0x0F29 Tibetan digits
0xFF10 through 0xFF19 Fullwidth digits

Parameters:
ch the character to be tested.
Returns:
true if the character is a digit; false otherwise.

static jboolean java::lang::Character::isDefined ( jchar  ch  )  [static]

Determines if a character has a defined meaning in Unicode.

A character is defined if at least one of the following is true:

Parameters:
ch the character to be tested
Returns:
true if the character has a defined meaning in Unicode; false otherwise.

static jboolean java::lang::Character::isLetter ( jchar  ch  )  [static]

Determines if the specified character is a letter.

For a more complete specification that encompasses all Unicode characters, see Gosling, Joy, and Steele, The Java Language Specification.

A character is considered to be a letter if and only if it is specified to be a letter by the Unicode 2.0 standard (category "Lu", "Ll", "Lt", "Lm", or "Lo" in the Unicode specification data file).

Note that most ideographic characters are considered to be letters (category "Lo") for this purpose.

Note also that not all letters have case: many Unicode characters are letters but are neither uppercase nor lowercase nor titlecase.

Parameters:
ch the character to be tested.
Returns:
true if the character is a letter; false otherwise.

static jboolean java::lang::Character::isLetterOrDigit ( jchar  ch  )  [static]

Determines if the specified character is a letter or digit.

For a more complete specification that encompasses all Unicode characters, see Gosling, Joy, and Steele, The Java Language Specification.

A character is considered to be a letter if and only if it is specified to be a letter or a digit by the Unicode 2.0 standard (category "Lu", "Ll", "Lt", "Lm", "Lo", or "Nd" in the Unicode specification data file). In other words, isLetterOrDigit is true of a character if and only if either isLetter is true of the character or isDigit is true of the character.

Parameters:
ch the character to be tested.
Returns:
true if the character is a letter or digit; false otherwise.

static jboolean java::lang::Character::isJavaIdentifierStart ( jchar  ch  )  [static]

Determines if the specified character is permissible as the first character in a Java identifier.

A character may start a Java identifier if and only if it is one of the following:

Parameters:
ch the character to be tested.
Returns:
true if the character may start a Java identifier; false otherwise.
Since:
JDK1.1

static jboolean java::lang::Character::isJavaIdentifierPart ( jchar  ch  )  [static]

Determines if the specified character may be part of a Java identifier as other than the first character.

A character may be part of a Java identifier if and only if it is one of the following:

Parameters:
ch the character to be tested.
Returns:
true if the character may be part of a Unicode identifier; false otherwise.

static jboolean java::lang::Character::isUnicodeIdentifierStart ( jchar  ch  )  [static]

Determines if the specified character is permissible as the first character in a Unicode identifier.

A character may start a Unicode identifier if and only if it is a letter.

Parameters:
ch the character to be tested.
Returns:
true if the character may start a Unicode identifier; false otherwise.

static jboolean java::lang::Character::isUnicodeIdentifierPart ( jchar  ch  )  [static]

Determines if the specified character may be part of a Unicode identifier as other than the first character.

A character may be part of a Unicode identifier if and only if it is one of the following:

Parameters:
ch the character to be tested.
Returns:
true if the character may be part of a Unicode identifier; false otherwise.

static jboolean java::lang::Character::isIdentifierIgnorable ( jchar  ch  )  [static]

Determines if the specified character should be regarded as an ignorable character in a Java identifier or a Unicode identifier.

The following Unicode characters are ignorable in a Java identifier or a Unicode identifier:
0x0000 through 0x0008, ISO control characters that
0x000E through 0x001B, are not whitespace
and 0x007F through 0x009F
0x200C through 0x200F join controls
0x200A through 0x200E bidirectional controls
0x206A through 0x206F format controls
0xFEFF zero-width no-break space

Parameters:
ch the character to be tested.
Returns:
true if the character may be part of a Unicode identifier; false otherwise.

static jchar java::lang::Character::toLowerCase ( jchar  ch  )  [static]

The given character is mapped to its lowercase equivalent; if the character has no lowercase equivalent, the character itself is returned.

A character has a lowercase equivalent if and only if a lowercase mapping is specified for the character in the Unicode attribute table.

Note that some Unicode characters in the range '&#92;u2000' to '&#92;u2FFF' have lowercase mappings; this method does map such characters to their lowercase equivalents even though the method isUpperCase does not return true for such characters.

Parameters:
ch the character to be converted.
Returns:
the lowercase equivalent of the character, if any; otherwise the character itself.

static jchar java::lang::Character::toUpperCase ( jchar  ch  )  [static]

Converts the character argument to uppercase.

A character has an uppercase equivalent if and only if an uppercase mapping is specified for the character in the Unicode attribute table.

Note that some Unicode characters in the range '&#92;u2000' to '&#92;u2000FFF' have uppercase mappings; this method does map such characters to their titlecase equivalents even though the method isLowerCase does not return true for such characters.

Parameters:
ch the character to be converted.
Returns:
the uppercase equivalent of the character, if any; otherwise the character itself.
See also:
java.lang.Character::isLowerCase(char)

java.lang.Character::isUpperCase(char)

java.lang.Character::toLowerCase(char)

java.lang.Character::toTitleCase(char)

static jchar java::lang::Character::toTitleCase ( jchar  ch  )  [static]

Converts the character argument to titlecase.

A character has a titlecase equivalent if and only if a titlecase mapping is specified for the character in the Unicode attribute table.

Note that some Unicode characters in the range '&#92;u2000' through '&#92;u2FFF' have titleca$ mappings; this method does map such characters to their titlecase equivalents even though the method isTitleCase does not return true for such characters.

There are only four Unicode characters that are truly titlecase forms that are distinct from uppercase forms. As a rule, if a character has no true titlecase equivalent but does have an uppercase mapping, then the Unicode 2.0 attribute table specifies a titlecase mapping that is the same as the uppercase mapping.

Parameters:
ch the character to be converted.
Returns:
the titlecase equivalent of the character, if any; otherwise the character itself.

static jint java::lang::Character::digit ( jchar  ch,
jint  radix = 10 
) [static]

Returns the numeric value of the character ch in the specified radix.

If the radix is not in the range MIN_RADIX <= radix <= MAX_RADIX or if the value of ch is not a valid digit in the specified radix, -1 is returned. A character is a valid digit if at least one of the following is true:

Parameters:
ch the character to be converted.
radix the radix.
Returns:
the numeric value represented by the character in the specified radix.

static jint java::lang::Character::getNumericValue ( jchar  ch  )  [static]

Returns the Unicode numeric value of the character as a nonnegative integer.

If the character does not have a numeric value, then -1 is returned. If the character has a numeric value that cannot be represented as a nonnegative integer (for example, a fractional value), then -2 is returned.

Parameters:
ch the character to be converted.
Returns:
the numeric value of the character, as a nonnegative int value; -2 if the character has a numeric value that is not a nonnegative integer; -1 if the character has no numeric value.
See also:
java.lang.Character::forDigit(int, int)

java.lang.Character::isDigit(char)

Since:
JDK1.1

static jboolean java::lang::Character::isSpaceChar ( jchar  ch  )  [static]

Determines if the specified character is a Unicode space character.

A character is considered to be a space character if and only if it is specified to be a space character by the Unicode 2.0 standard (category "Zs", "Zl, or "Zp" in the Unicode specification data file).

Parameters:
ch the character to be tested.
Returns:
true if the character is a space character; false otherwise.
See also:
java.lang.Character::isWhitespace(char)
Since:
JDK1.1

static jboolean java::lang::Character::isWhitespace ( jchar  ch  )  [static]

Determines if the specified character is white space according to Java.

A character is considered to be a Java whitespace character if and only if it satisfies one of the following criteria:

Parameters:
ch the character to be tested.
Returns:
true if the character is a Java whitespace character; false otherwise.

static jboolean java::lang::Character::isISOControl ( jchar  ch  )  [static]

Determines if the specified character is an ISO control character.

A character is considered to be an ISO control character if its code is in the range &#92;u0000 through &#92;u001F or in the range &#92;u007F through &#92;u009F.

Parameters:
ch the character to be tested.
Returns:
true if the character is an ISO control character; false otherwise.

static jint java::lang::Character::getType ( jchar  ch  )  [static]

Returns a value indicating a character category.

Parameters:
ch the character to be tested.
Returns:
a value of type int, the character category.

static jchar java::lang::Character::forDigit ( jint  digit,
jint  radix = 10 
) [static]

Determines the character representation for a specific digit in the specified radix.

If the value of radix is not a valid radix, or the value of digit is not a valid digit in the specified radix, the null character ('&#92;u0000') is returned.

The radix argument is valid if it is greater than or equal to MIN_RADIX and less than or equal to MAX_RADIX. The digit argument is valid if 0 <= digit <= radix.

If the digit is less than 10, then '0' + digit is returned. Otherwise, the value 'a' + digit - 10 is returned.

Parameters:
digit the number to convert to a character.
radix the radix.
Returns:
the char representation of the specified digit in the specified radix.


Member Data Documentation

const jint java::lang::Character::MIN_RADIX [static]

The minimum radix available for conversion to and from Strings.

The constant value of this field is the smallest value permitted for the radix argument in radix-conversion methods such as the digit method, the forDigit method, and the toString method of class Integer.

const jint java::lang::Character::MAX_RADIX [static]

The maximum radix available for conversion to and from Strings.

The constant value of this field is the largest value permitted for the radix argument in radix-conversion methods such as the digit method, the forDigit method, and the toString method of class Integer.

const jchar java::lang::Character::MIN_VALUE [static]

The constant value of this field is the smallest value of type char.

Since:
JDK1.0.2

const jchar java::lang::Character::MAX_VALUE [static]

The constant value of this field is the largest value of type char.

Since:
JDK1.0.2


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:34 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3