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

Print this page
rev 6151 : imported patch reducers


7217      *            code point.
7218      *
7219      * @since 1.7
7220      */
7221     public static String getName(int codePoint) {
7222         if (!isValidCodePoint(codePoint)) {
7223             throw new IllegalArgumentException();
7224         }
7225         String name = CharacterName.get(codePoint);
7226         if (name != null)
7227             return name;
7228         if (getType(codePoint) == UNASSIGNED)
7229             return null;
7230         UnicodeBlock block = UnicodeBlock.of(codePoint);
7231         if (block != null)
7232             return block.toString().replace('_', ' ') + " "
7233                    + Integer.toHexString(codePoint).toUpperCase(Locale.ENGLISH);
7234         // should never come here
7235         return Integer.toHexString(codePoint).toUpperCase(Locale.ENGLISH);
7236     }










































7237 }


7217      *            code point.
7218      *
7219      * @since 1.7
7220      */
7221     public static String getName(int codePoint) {
7222         if (!isValidCodePoint(codePoint)) {
7223             throw new IllegalArgumentException();
7224         }
7225         String name = CharacterName.get(codePoint);
7226         if (name != null)
7227             return name;
7228         if (getType(codePoint) == UNASSIGNED)
7229             return null;
7230         UnicodeBlock block = UnicodeBlock.of(codePoint);
7231         if (block != null)
7232             return block.toString().replace('_', ' ') + " "
7233                    + Integer.toHexString(codePoint).toUpperCase(Locale.ENGLISH);
7234         // should never come here
7235         return Integer.toHexString(codePoint).toUpperCase(Locale.ENGLISH);
7236     }
7237 
7238     /**
7239      * Adds two chars together as per the + operator.
7240      * Suitable for conversion as a method reference to functional interfaces such
7241      * as {@code BinaryOperator<Character>}.
7242      *
7243      * @param   a   an argument.
7244      * @param   b   another argument.
7245      * @return  the sum of {@code a} and {@code b}.
7246      * @since 1.8
7247      */
7248     public static char sum(char a, char b) {
7249         return (char) (a + b);
7250     }
7251 
7252     /**
7253      * Returns the greater of two {@code char} values.
7254      * Suitable for conversion as a method reference to functional interfaces such
7255      * as {@code BinaryOperator<Character>}.
7256      *
7257      * @param   a   an argument.
7258      * @param   b   another argument.
7259      * @return  the larger of {@code a} and {@code b}.
7260      * @since 1.8
7261      */
7262     public static char max(char a, char b) {
7263         return (a >= b) ? a : b;
7264     }
7265 
7266     /**
7267      * Returns the lesser of two {@code char} values.
7268      * Suitable for conversion as a method reference to functional interfaces such
7269      * as {@code BinaryOperator<Character>}.
7270      *
7271      * @param   a   an argument.
7272      * @param   b   another argument.
7273      * @return  the lesser of {@code a} and {@code b}.
7274      * @since 1.8
7275      */
7276     public static char min(char a, char b) {
7277         return (a <= b) ? a : b;
7278     }
7279 }