⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 character.java

📁 kaffe是一个java虚拟机的源代码。里面包含了一些java例程和标准的java包。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Java core library component. * * Copyright (c) 1997, 1998, 1999 *      Transvirtual Technologies, Inc.  All rights reserved. * * See the file "license.terms" for information on usage and redistribution * of this file. */package java.lang;import java.io.ByteArrayOutputStream;import java.io.IOException;import java.io.InputStream;import java.io.Serializable;import java.util.StringTokenizer;import java.util.zip.ZipFile;import java.util.zip.ZipEntry;import kaffe.util.IntegerHashtable;public final class Character implements Serializable, Comparable {  public static final int MIN_RADIX = 2;  public static final int MAX_RADIX = 36;  public static final char MIN_VALUE = 0x0000;  public static final char MAX_VALUE = 0xffff;  public static final byte UNASSIGNED = 0;		// Cn  public static final byte UPPERCASE_LETTER = 1;	// Lu  public static final byte LOWERCASE_LETTER = 2;	// Ll  public static final byte TITLECASE_LETTER = 3;	// Lt  public static final byte MODIFIER_LETTER = 4;		// Lm  public static final byte OTHER_LETTER = 5;		// Lo  public static final byte NON_SPACING_MARK = 6;	// Mn  public static final byte ENCLOSING_MARK = 7;		// Me  public static final byte COMBINING_SPACING_MARK = 8;	// Mc  public static final byte DECIMAL_DIGIT_NUMBER = 9;	// Nd  public static final byte LETTER_NUMBER = 10;		// Nl  public static final byte OTHER_NUMBER = 11;		// No  public static final byte SPACE_SEPARATOR = 12;	// Zs  public static final byte LINE_SEPARATOR = 13;		// Zl  public static final byte PARAGRAPH_SEPARATOR = 14;	// Zp  public static final byte CONTROL = 15;		// Cc  public static final byte FORMAT = 16;			// Cf  public static final byte PRIVATE_USE = 18;		// Co  public static final byte SURROGATE = 19;		// Cs  public static final byte DASH_PUNCTUATION = 20;	// Pd  public static final byte START_PUNCTUATION = 21;	// Ps  public static final byte END_PUNCTUATION = 22;	// Pe  public static final byte CONNECTOR_PUNCTUATION = 23;	// Pc  public static final byte OTHER_PUNCTUATION = 24;	// Po  public static final byte MATH_SYMBOL = 25;		// Sm  public static final byte CURRENCY_SYMBOL = 26;	// Sc  public static final byte MODIFIER_SYMBOL = 27;	// Sk  public static final byte OTHER_SYMBOL = 28;		// So  public static final Class TYPE = Class.getPrimitiveClass("char");  private final char value;  /* This is what Sun's JDK1.1 "serialver java.lang.Character" spits out */  private static final long serialVersionUID = 3786198910865385080L;  private static final char FULLWIDTH_LATIN_CAPITAL_LETTER_A = '\uff21';  private static final char FULLWIDTH_LATIN_CAPITAL_LETTER_Z = '\uff3a';  private static final char FULLWIDTH_LATIN_SMALL_LETTER_A = '\uff41';  private static final char FULLWIDTH_LATIN_SMALL_LETTER_Z = '\uff5a';  public Character(char value)  {    this.value = value;  }  public char charValue()  {    return (value);  }  public int hashCode()  {    return ((int)value);  }  public boolean equals(Object obj)  {    return (obj instanceof Character)      && (((Character) obj).value == this.value);  }  public String toString()  {    return (String.valueOf(value));  }  public int compareTo(Character c)  {    return (int)value - (int)c.value;  }  public int compareTo(Object o)  {    return compareTo((Character)o);  }  /**   * @deprecated Replaced by isWhitespace(char).   */  public static boolean isSpace(char ch)  {    switch ((int)ch) {    case 0x0009:	// HORIZONTAL TABULATION    case 0x000A:	// NEW LINE    case 0x000C:	// FORM FEED    case 0x000D:	// CARRIAGE RETURN    case 0x0020:	// SPACE      return (true);    default:      return (false);    }  }  public static boolean isLetterOrDigit(char ch)  {    return (isLetter(ch) || isDigit(ch));  }    /**   * @deprecated Replaced by isJavaIdentifierStart(char).   */  public static boolean isJavaLetter(char ch)  {    return ((ch == '$') || (ch == '_') || isLetter(ch));  }    /**   * @deprecated Replaced by isJavaIdentifierPart(char).   */  public static boolean isJavaLetterOrDigit(char ch)  {    return ((ch == '$') || (ch == '_') || isLetterOrDigit(ch));  }  public static boolean isTitleCase(char ch)  {      switch (getType(ch)) {      case TITLECASE_LETTER:	  return true;      }      return false;  }    /**   * Determines if a character has a defined meaning in Unicode.    * A character is defined if at least one of the following is true:  <br>   *   It has an entry in the Unicode attribute table.  <br>   *   Its value is in the range 0x3040 <= ch <= 0x9FA5.  <br>   *   Its value is in the range 0xF900 <= ch <= 0xFA2D.  <br>   */  public static boolean isDefined(char ch) {    // FIXME: check compatibility: U+3040 is not defined in Unicode 2.1.8    if (getType(ch) == UNASSIGNED) {      return (false);    }    return (true);  }  public static boolean isIdentifierIgnorable(char ch)  {    if ((ch >= 0x0000 && ch <= 0x0008) ||	// ISO control characters that        (ch >= 0x000E && ch <= 0x001B) ||	// are not whitespace        (ch >= 0x007F && ch <= 0x009F) ||	// and this range        (ch >= 0x200C && ch <= 0x200F) ||	// join controls        (ch >= 0x202A && ch <= 0x202E) ||	// bidirectional controls        (ch >= 0x206A && ch <= 0x206F) ||	// format controls        (ch == 0xFEFF)) {			// zero-width no-break space      return (true);    }    else {      return (false);    }  }  public static boolean isLowerCase(char ch)  {    switch (getType(ch)) {    case LOWERCASE_LETTER:      return (true);    }    return (false);  }  public static boolean isUpperCase(char ch)  {    switch (getType(ch)) {    case UPPERCASE_LETTER:      return (true);    }    return (false);  }  public static boolean isDigit(char ch)  {    if (getType(ch) == DECIMAL_DIGIT_NUMBER) {      return (true);    }    return (false);  }  public static boolean isLetter(char ch)  {    switch (getType(ch)) {    case UPPERCASE_LETTER:    case LOWERCASE_LETTER:    case TITLECASE_LETTER:    case MODIFIER_LETTER:    case OTHER_LETTER:      return (true);    default:      return (false);    }  }  /**   * Converts the caracter argument to lowercase.   *   * @param ch the character to be converted.   * @return the lowercase equivalent defined by the Unicode database   * 	or the character itself.   */  public static char toLowerCase(char ch)  {      CharacterProperties chProp = getCharProp(ch);      if (chProp.lower != 0x0000) {	  return chProp.lower;      }      else {	  return ch;      }  }  /**   * Converts the caracter argument to uppercase.   *   * @param ch the character to be converted.   * @return the uppercase equivalent defined by the Unicode database   * 	or the character itself.   */  public static char toUpperCase(char ch)  {      CharacterProperties chProp = getCharProp(ch);      if (chProp.upper != 0x0000) {	  return chProp.upper;      }      else {	  return ch;      }  }  /**   * Converts the caracter argument to titlecase.   *   * @param ch the character to be converted.   * @return the titlecase equivalent defined by the Unicode database   * 	or the character itself.   */  public static char toTitleCase(char ch)  {      CharacterProperties chProp = getCharProp(ch);      if (chProp.title != 0x0000) {	  return chProp.title;      }      else {	  return ch;      }  }  /**   * Returns the numeric value of the character ch in the specified   * radix.   *   * @param ch the character to be converted.   * @param radix the radix.   * @return the numeric value or -1.   */  public static int digit(char ch, int radix)  {    if (radix < MIN_RADIX || radix > MAX_RADIX) {      return -1;    }    int val = radix;    if (isDigit(ch)) {	// FIXME: true as long `decimal digit value' == `numeric value'	// FIXME: in the Unicode Database.  Add a check in unicode.pl	val =  getCharProp(ch).numeric;	if (val < 0) {	    return -1;	}    }    else if (('A' <= ch) && (ch <= 'Z')) {	// Help the compiler, group constant values !	val = (int)ch - ('A' - 10);    }    else if (('a' <= ch) && (ch <= 'z')) {	// Help the compiler, group constant values !	val = (int)ch - ('a' - 10);    }    else if((FULLWIDTH_LATIN_CAPITAL_LETTER_A <= ch)	    && (ch <= FULLWIDTH_LATIN_CAPITAL_LETTER_Z)) {	val = (int)ch - (FULLWIDTH_LATIN_CAPITAL_LETTER_A - 10);    }    else if((FULLWIDTH_LATIN_SMALL_LETTER_A <= ch)	    && (ch <= FULLWIDTH_LATIN_SMALL_LETTER_Z)) {	val = (int)ch - (FULLWIDTH_LATIN_SMALL_LETTER_A - 10);    }    return (val < radix) ? val : -1;  }  public static char forDigit(int digit, int radix)  {    if (radix < MIN_RADIX || radix > MAX_RADIX) {      return 0x0000;    }    if (digit < 0 || digit >= radix) {      return 0x0000;    }    if (digit < 10) {      return (char)(((int)'0')+digit);    }    else {      return (char)(((int)'a')+(digit-10));    }  }  /**   * Returns the Unicode numeric value of the character as a nonnegative   * integer.   *   * @param ch the character to be converted.   * @return the numeric value equivalent defined in the Unicode database   * 	or -2 if it is negative or not integer, else -1.   */  public static int getNumericValue(char ch)  {    int val = getCharProp(ch).numeric;    if (val == -1) {      return digit(ch, Character.MAX_RADIX);    }    else {      return val;    }  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -