< prev index next >

src/java.base/share/classes/java/lang/Character.java

Print this page




3082             new UnicodeBlock("SOYOMBO");
3083 
3084         /**
3085          * Constant for the "Bhaiksuki" Unicode
3086          * character block.
3087          * @since 11
3088          */
3089         public static final UnicodeBlock BHAIKSUKI =
3090             new UnicodeBlock("BHAIKSUKI");
3091 
3092         /**
3093          * Constant for the "CJK Unified Ideographs Extension F" Unicode
3094          * character block.
3095          * @since 11
3096          */
3097         public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS_EXTENSION_F =
3098             new UnicodeBlock("CJK_UNIFIED_IDEOGRAPHS_EXTENSION_F",
3099                              "CJK UNIFIED IDEOGRAPHS EXTENSION F",
3100                              "CJKUNIFIEDIDEOGRAPHSEXTENSIONF");
3101 
3102         private static final int blockStarts[] = {
3103             0x0000,   // 0000..007F; Basic Latin
3104             0x0080,   // 0080..00FF; Latin-1 Supplement
3105             0x0100,   // 0100..017F; Latin Extended-A
3106             0x0180,   // 0180..024F; Latin Extended-B
3107             0x0250,   // 0250..02AF; IPA Extensions
3108             0x02B0,   // 02B0..02FF; Spacing Modifier Letters
3109             0x0300,   // 0300..036F; Combining Diacritical Marks
3110             0x0370,   // 0370..03FF; Greek and Coptic
3111             0x0400,   // 0400..04FF; Cyrillic
3112             0x0500,   // 0500..052F; Cyrillic Supplement
3113             0x0530,   // 0530..058F; Armenian
3114             0x0590,   // 0590..05FF; Hebrew
3115             0x0600,   // 0600..06FF; Arabic
3116             0x0700,   // 0700..074F; Syriac
3117             0x0750,   // 0750..077F; Arabic Supplement
3118             0x0780,   // 0780..07BF; Thaana
3119             0x07C0,   // 07C0..07FF; NKo
3120             0x0800,   // 0800..083F; Samaritan
3121             0x0840,   // 0840..085F; Mandaic
3122             0x0860,   // 0860..086F; Syriac Supplement


7889     /**
7890      * Constructs a newly allocated {@code Character} object that
7891      * represents the specified {@code char} value.
7892      *
7893      * @param  value   the value to be represented by the
7894      *                  {@code Character} object.
7895      *
7896      * @deprecated
7897      * It is rarely appropriate to use this constructor. The static factory
7898      * {@link #valueOf(char)} is generally a better choice, as it is
7899      * likely to yield significantly better space and time performance.
7900      */
7901     @Deprecated(since="9")
7902     public Character(char value) {
7903         this.value = value;
7904     }
7905 
7906     private static class CharacterCache {
7907         private CharacterCache(){}
7908 
7909         static final Character cache[] = new Character[127 + 1];
7910 
7911         static {
7912             for (int i = 0; i < cache.length; i++)
7913                 cache[i] = new Character((char)i);
7914         }
7915     }
7916 
7917     /**
7918      * Returns a {@code Character} instance representing the specified
7919      * {@code char} value.
7920      * If a new {@code Character} instance is not required, this method
7921      * should generally be used in preference to the constructor
7922      * {@link #Character(char)}, as this method is likely to yield
7923      * significantly better space and time performance by caching
7924      * frequently requested values.
7925      *
7926      * This method will always cache values in the range {@code
7927      * '\u005Cu0000'} to {@code '\u005Cu007F'}, inclusive, and may
7928      * cache other values outside of this range.
7929      *


7983      * @return  {@code true} if the objects are the same;
7984      *          {@code false} otherwise.
7985      */
7986     public boolean equals(Object obj) {
7987         if (obj instanceof Character) {
7988             return value == ((Character)obj).charValue();
7989         }
7990         return false;
7991     }
7992 
7993     /**
7994      * Returns a {@code String} object representing this
7995      * {@code Character}'s value.  The result is a string of
7996      * length 1 whose sole component is the primitive
7997      * {@code char} value represented by this
7998      * {@code Character} object.
7999      *
8000      * @return  a string representation of this object.
8001      */
8002     public String toString() {
8003         char buf[] = {value};
8004         return String.valueOf(buf);
8005     }
8006 
8007     /**
8008      * Returns a {@code String} object representing the
8009      * specified {@code char}.  The result is a string of length
8010      * 1 consisting solely of the specified {@code char}.
8011      *
8012      * @apiNote This method cannot handle <a
8013      * href="#supplementary"> supplementary characters</a>. To support
8014      * all Unicode characters, including supplementary characters, use
8015      * the {@link #toString(int)} method.
8016      *
8017      * @param c the {@code char} to be converted
8018      * @return the string representation of the specified {@code char}
8019      * @since 1.4
8020      */
8021     public static String toString(char c) {
8022         return String.valueOf(c);
8023     }




3082             new UnicodeBlock("SOYOMBO");
3083 
3084         /**
3085          * Constant for the "Bhaiksuki" Unicode
3086          * character block.
3087          * @since 11
3088          */
3089         public static final UnicodeBlock BHAIKSUKI =
3090             new UnicodeBlock("BHAIKSUKI");
3091 
3092         /**
3093          * Constant for the "CJK Unified Ideographs Extension F" Unicode
3094          * character block.
3095          * @since 11
3096          */
3097         public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS_EXTENSION_F =
3098             new UnicodeBlock("CJK_UNIFIED_IDEOGRAPHS_EXTENSION_F",
3099                              "CJK UNIFIED IDEOGRAPHS EXTENSION F",
3100                              "CJKUNIFIEDIDEOGRAPHSEXTENSIONF");
3101 
3102         private static final int[] blockStarts = {
3103             0x0000,   // 0000..007F; Basic Latin
3104             0x0080,   // 0080..00FF; Latin-1 Supplement
3105             0x0100,   // 0100..017F; Latin Extended-A
3106             0x0180,   // 0180..024F; Latin Extended-B
3107             0x0250,   // 0250..02AF; IPA Extensions
3108             0x02B0,   // 02B0..02FF; Spacing Modifier Letters
3109             0x0300,   // 0300..036F; Combining Diacritical Marks
3110             0x0370,   // 0370..03FF; Greek and Coptic
3111             0x0400,   // 0400..04FF; Cyrillic
3112             0x0500,   // 0500..052F; Cyrillic Supplement
3113             0x0530,   // 0530..058F; Armenian
3114             0x0590,   // 0590..05FF; Hebrew
3115             0x0600,   // 0600..06FF; Arabic
3116             0x0700,   // 0700..074F; Syriac
3117             0x0750,   // 0750..077F; Arabic Supplement
3118             0x0780,   // 0780..07BF; Thaana
3119             0x07C0,   // 07C0..07FF; NKo
3120             0x0800,   // 0800..083F; Samaritan
3121             0x0840,   // 0840..085F; Mandaic
3122             0x0860,   // 0860..086F; Syriac Supplement


7889     /**
7890      * Constructs a newly allocated {@code Character} object that
7891      * represents the specified {@code char} value.
7892      *
7893      * @param  value   the value to be represented by the
7894      *                  {@code Character} object.
7895      *
7896      * @deprecated
7897      * It is rarely appropriate to use this constructor. The static factory
7898      * {@link #valueOf(char)} is generally a better choice, as it is
7899      * likely to yield significantly better space and time performance.
7900      */
7901     @Deprecated(since="9")
7902     public Character(char value) {
7903         this.value = value;
7904     }
7905 
7906     private static class CharacterCache {
7907         private CharacterCache(){}
7908 
7909         static final Character[] cache = new Character[127 + 1];
7910 
7911         static {
7912             for (int i = 0; i < cache.length; i++)
7913                 cache[i] = new Character((char)i);
7914         }
7915     }
7916 
7917     /**
7918      * Returns a {@code Character} instance representing the specified
7919      * {@code char} value.
7920      * If a new {@code Character} instance is not required, this method
7921      * should generally be used in preference to the constructor
7922      * {@link #Character(char)}, as this method is likely to yield
7923      * significantly better space and time performance by caching
7924      * frequently requested values.
7925      *
7926      * This method will always cache values in the range {@code
7927      * '\u005Cu0000'} to {@code '\u005Cu007F'}, inclusive, and may
7928      * cache other values outside of this range.
7929      *


7983      * @return  {@code true} if the objects are the same;
7984      *          {@code false} otherwise.
7985      */
7986     public boolean equals(Object obj) {
7987         if (obj instanceof Character) {
7988             return value == ((Character)obj).charValue();
7989         }
7990         return false;
7991     }
7992 
7993     /**
7994      * Returns a {@code String} object representing this
7995      * {@code Character}'s value.  The result is a string of
7996      * length 1 whose sole component is the primitive
7997      * {@code char} value represented by this
7998      * {@code Character} object.
7999      *
8000      * @return  a string representation of this object.
8001      */
8002     public String toString() {
8003         char[] buf = {value};
8004         return String.valueOf(buf);
8005     }
8006 
8007     /**
8008      * Returns a {@code String} object representing the
8009      * specified {@code char}.  The result is a string of length
8010      * 1 consisting solely of the specified {@code char}.
8011      *
8012      * @apiNote This method cannot handle <a
8013      * href="#supplementary"> supplementary characters</a>. To support
8014      * all Unicode characters, including supplementary characters, use
8015      * the {@link #toString(int)} method.
8016      *
8017      * @param c the {@code char} to be converted
8018      * @return the string representation of the specified {@code char}
8019      * @since 1.4
8020      */
8021     public static String toString(char c) {
8022         return String.valueOf(c);
8023     }


< prev index next >