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

Print this page




4765      * a {@linkplain #isHighSurrogate(char) high-surrogate code unit}.
4766      *
4767      * @param  ch the {@code char} value to be tested.
4768      * @return {@code true} if the {@code char} value is between
4769      *         {@link #MIN_SURROGATE} and
4770      *         {@link #MAX_SURROGATE} inclusive;
4771      *         {@code false} otherwise.
4772      * @since  1.7
4773      */
4774     public static boolean isSurrogate(char ch) {
4775         return ch >= MIN_SURROGATE && ch < (MAX_SURROGATE + 1);
4776     }
4777 
4778     /**
4779      * Determines whether the specified pair of {@code char}
4780      * values is a valid
4781      * <a href="http://www.unicode.org/glossary/#surrogate_pair">
4782      * Unicode surrogate pair</a>.
4783 
4784      * <p>This method is equivalent to the expression:
4785      * <blockquote><pre>
4786      * isHighSurrogate(high) && isLowSurrogate(low)
4787      * </pre></blockquote>
4788      *
4789      * @param  high the high-surrogate code value to be tested
4790      * @param  low the low-surrogate code value to be tested
4791      * @return {@code true} if the specified high and
4792      * low-surrogate code values represent a valid surrogate pair;
4793      * {@code false} otherwise.
4794      * @since  1.5
4795      */
4796     public static boolean isSurrogatePair(char high, char low) {
4797         return isHighSurrogate(high) && isLowSurrogate(low);
4798     }
4799 
4800     /**
4801      * Determines the number of {@code char} values needed to
4802      * represent the specified character (Unicode code point). If the
4803      * specified character is equal to or greater than 0x10000, then
4804      * the method returns 2. Otherwise, the method returns 1.
4805      *
4806      * <p>This method doesn't validate the specified character to be a
4807      * valid Unicode code point. The caller must validate the




4765      * a {@linkplain #isHighSurrogate(char) high-surrogate code unit}.
4766      *
4767      * @param  ch the {@code char} value to be tested.
4768      * @return {@code true} if the {@code char} value is between
4769      *         {@link #MIN_SURROGATE} and
4770      *         {@link #MAX_SURROGATE} inclusive;
4771      *         {@code false} otherwise.
4772      * @since  1.7
4773      */
4774     public static boolean isSurrogate(char ch) {
4775         return ch >= MIN_SURROGATE && ch < (MAX_SURROGATE + 1);
4776     }
4777 
4778     /**
4779      * Determines whether the specified pair of {@code char}
4780      * values is a valid
4781      * <a href="http://www.unicode.org/glossary/#surrogate_pair">
4782      * Unicode surrogate pair</a>.
4783 
4784      * <p>This method is equivalent to the expression:
4785      * <blockquote><pre>{@code
4786      * isHighSurrogate(high) && isLowSurrogate(low)
4787      * }</pre></blockquote>
4788      *
4789      * @param  high the high-surrogate code value to be tested
4790      * @param  low the low-surrogate code value to be tested
4791      * @return {@code true} if the specified high and
4792      * low-surrogate code values represent a valid surrogate pair;
4793      * {@code false} otherwise.
4794      * @since  1.5
4795      */
4796     public static boolean isSurrogatePair(char high, char low) {
4797         return isHighSurrogate(high) && isLowSurrogate(low);
4798     }
4799 
4800     /**
4801      * Determines the number of {@code char} values needed to
4802      * represent the specified character (Unicode code point). If the
4803      * specified character is equal to or greater than 0x10000, then
4804      * the method returns 2. Otherwise, the method returns 1.
4805      *
4806      * <p>This method doesn't validate the specified character to be a
4807      * valid Unicode code point. The caller must validate the