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

Print this page
rev 6091 : 7088952: Add size in bytes constant "BYTES" to primitive type wrapper types
Summary: Adds a constant BYTES to each of the primitive wrapper classes (Byte, Character, Double, Float, Integer, Long, Short) with the calculation Primitive.SIZE / Byte.SIZE already made.
Reviewed-by: smarks, darcy


7141      *
7142      * @param   codePoint   the character (Unicode code point) to be converted.
7143      * @return a {@code char[]} with the uppercased character.
7144      * @since 1.4
7145      */
7146     static char[] toUpperCaseCharArray(int codePoint) {
7147         // As of Unicode 6.0, 1:M uppercasings only happen in the BMP.
7148         assert isBmpCodePoint(codePoint);
7149         return CharacterData.of(codePoint).toUpperCaseCharArray(codePoint);
7150     }
7151 
7152     /**
7153      * The number of bits used to represent a <tt>char</tt> value in unsigned
7154      * binary form, constant {@code 16}.
7155      *
7156      * @since 1.5
7157      */
7158     public static final int SIZE = 16;
7159 
7160     /**








7161      * Returns the value obtained by reversing the order of the bytes in the
7162      * specified <tt>char</tt> value.
7163      *
7164      * @return the value obtained by reversing (or, equivalently, swapping)
7165      *     the bytes in the specified <tt>char</tt> value.
7166      * @since 1.5
7167      */
7168     public static char reverseBytes(char ch) {
7169         return (char) (((ch & 0xFF00) >> 8) | (ch << 8));
7170     }
7171 
7172     /**
7173      * Returns the Unicode name of the specified character
7174      * {@code codePoint}, or null if the code point is
7175      * {@link #UNASSIGNED unassigned}.
7176      * <p>
7177      * Note: if the specified character is not assigned a name by
7178      * the <i>UnicodeData</i> file (part of the Unicode Character
7179      * Database maintained by the Unicode Consortium), the returned
7180      * name is the same as the result of expression.




7141      *
7142      * @param   codePoint   the character (Unicode code point) to be converted.
7143      * @return a {@code char[]} with the uppercased character.
7144      * @since 1.4
7145      */
7146     static char[] toUpperCaseCharArray(int codePoint) {
7147         // As of Unicode 6.0, 1:M uppercasings only happen in the BMP.
7148         assert isBmpCodePoint(codePoint);
7149         return CharacterData.of(codePoint).toUpperCaseCharArray(codePoint);
7150     }
7151 
7152     /**
7153      * The number of bits used to represent a <tt>char</tt> value in unsigned
7154      * binary form, constant {@code 16}.
7155      *
7156      * @since 1.5
7157      */
7158     public static final int SIZE = 16;
7159 
7160     /**
7161      * The number of bytes used to represent a {@code char} value in unsigned
7162      * binary form.
7163      *
7164      * @since 1.8
7165      */
7166     public static final int BYTES = SIZE / Byte.SIZE;
7167 
7168     /**
7169      * Returns the value obtained by reversing the order of the bytes in the
7170      * specified <tt>char</tt> value.
7171      *
7172      * @return the value obtained by reversing (or, equivalently, swapping)
7173      *     the bytes in the specified <tt>char</tt> value.
7174      * @since 1.5
7175      */
7176     public static char reverseBytes(char ch) {
7177         return (char) (((ch & 0xFF00) >> 8) | (ch << 8));
7178     }
7179 
7180     /**
7181      * Returns the Unicode name of the specified character
7182      * {@code codePoint}, or null if the code point is
7183      * {@link #UNASSIGNED unassigned}.
7184      * <p>
7185      * Note: if the specified character is not assigned a name by
7186      * the <i>UnicodeData</i> file (part of the Unicode Character
7187      * Database maintained by the Unicode Consortium), the returned
7188      * name is the same as the result of expression.