From 9ef7eb788496fc12a1f58b6666a0524c04353b1f Mon Sep 17 00:00:00 2001 From: Martin Buchholz Date: Mon, 31 Aug 2009 15:00:04 -0700 Subject: [PATCH] 6860431: Character.isSurrogate(char ch) Add new method Character.isSurrogate(char ch) Reviewed-by: sherman, darcy, okutsu --- .../share/classes/java/lang/Character.java | 179 +++++++++++------- .../classes/sun/io/CharToByteDBCS_ASCII.java | 6 +- .../classes/sun/io/CharToByteDBCS_EBCDIC.java | 6 +- .../share/classes/sun/nio/cs/ISO_8859_1.java | 4 +- .../share/classes/sun/nio/cs/SingleByte.java | 8 +- .../classes/sun/nio/cs/SingleByteEncoder.java | 4 +- .../share/classes/sun/nio/cs/Surrogate.java | 13 +- .../share/classes/sun/nio/cs/US_ASCII.java | 4 +- .../share/classes/sun/nio/cs/UTF_32Coder.java | 6 +- jdk/src/share/classes/sun/nio/cs/UTF_8.java | 14 +- .../classes/sun/nio/cs/UnicodeDecoder.java | 6 +- .../classes/sun/nio/cs/UnicodeEncoder.java | 4 +- .../classes/sun/nio/cs/ext/DoubleByte.java | 8 +- .../sun/nio/cs/ext/DoubleByteEncoder.java | 4 +- .../share/classes/sun/nio/cs/ext/EUC_JP.java | 4 +- .../classes/sun/nio/cs/ext/EUC_JP_LINUX.java | 4 +- .../share/classes/sun/nio/cs/ext/EUC_TW.java | 16 +- .../share/classes/sun/nio/cs/ext/GB18030.java | 6 +- .../share/classes/sun/nio/cs/ext/ISCII91.java | 4 +- .../share/classes/sun/nio/cs/ext/ISO2022.java | 4 +- .../classes/sun/nio/cs/ext/ISO2022_JP.java | 8 +- .../sun/nio/cs/ext/SimpleEUCEncoder.java | 4 +- 22 files changed, 178 insertions(+), 138 deletions(-) diff --git a/jdk/src/share/classes/java/lang/Character.java b/jdk/src/share/classes/java/lang/Character.java index 56e763ee6a6..65a3fc40184 100644 --- a/jdk/src/share/classes/java/lang/Character.java +++ b/jdk/src/share/classes/java/lang/Character.java @@ -162,7 +162,7 @@ class Character extends Object implements java.io.Serializable, ComparableClass instance representing the primitive type @@ -518,75 +518,91 @@ class Character extends Object implements java.io.Serializable, Comparableleading-surrogate. + * The minimum value of a + * + * Unicode high-surrogate code unit + * in the UTF-16 encoding, constant '\uD800'. + * A high-surrogate is also known as a leading-surrogate. * * @since 1.5 */ public static final char MIN_HIGH_SURROGATE = '\uD800'; /** - * The maximum value of a Unicode high-surrogate code unit in the - * UTF-16 encoding. A high-surrogate is also known as a - * leading-surrogate. + * The maximum value of a + * + * Unicode high-surrogate code unit + * in the UTF-16 encoding, constant '\uDBFF'. + * A high-surrogate is also known as a leading-surrogate. * * @since 1.5 */ public static final char MAX_HIGH_SURROGATE = '\uDBFF'; /** - * The minimum value of a Unicode low-surrogate code unit in the - * UTF-16 encoding. A low-surrogate is also known as a - * trailing-surrogate. + * The minimum value of a + * + * Unicode low-surrogate code unit + * in the UTF-16 encoding, constant '\uDC00'. + * A low-surrogate is also known as a trailing-surrogate. * * @since 1.5 */ public static final char MIN_LOW_SURROGATE = '\uDC00'; /** - * The maximum value of a Unicode low-surrogate code unit in the - * UTF-16 encoding. A low-surrogate is also known as a - * trailing-surrogate. + * The maximum value of a + * + * Unicode low-surrogate code unit + * in the UTF-16 encoding, constant '\uDFFF'. + * A low-surrogate is also known as a trailing-surrogate. * * @since 1.5 */ public static final char MAX_LOW_SURROGATE = '\uDFFF'; /** - * The minimum value of a Unicode surrogate code unit in the UTF-16 encoding. + * The minimum value of a Unicode surrogate code unit in the + * UTF-16 encoding, constant '\uD800'. * * @since 1.5 */ public static final char MIN_SURROGATE = MIN_HIGH_SURROGATE; /** - * The maximum value of a Unicode surrogate code unit in the UTF-16 encoding. + * The maximum value of a Unicode surrogate code unit in the + * UTF-16 encoding, constant '\uDFFF'. * * @since 1.5 */ public static final char MAX_SURROGATE = MAX_LOW_SURROGATE; /** - * The minimum value of a supplementary code point. + * The minimum value of a + * + * Unicode supplementary code point, constant {@code U+10000}. * * @since 1.5 */ public static final int MIN_SUPPLEMENTARY_CODE_POINT = 0x010000; /** - * The minimum value of a Unicode code point. + * The minimum value of a + * + * Unicode code point, constant {@code U+0000}. * * @since 1.5 */ public static final int MIN_CODE_POINT = 0x000000; /** - * The maximum value of a Unicode code point. + * The maximum value of a + * + * Unicode code point, constant {@code U+10FFFF}. * * @since 1.5 */ - public static final int MAX_CODE_POINT = 0x10ffff; + public static final int MAX_CODE_POINT = 0X10FFFF; /** @@ -2648,19 +2664,15 @@ class Character extends Object implements java.io.Serializable, Comparable0x0000 to - * 0x10FFFF inclusive. This method is equivalent to - * the expression: - * - *
-     * codePoint >= 0x0000 && codePoint <= 0x10FFFF
-     * 
+ * Determines whether the specified code point is a valid + * + * Unicode code point value. * * @param codePoint the Unicode code point to be tested - * @return true if the specified code point value - * is a valid code point value; - * false otherwise. + * @return {@code true} if the specified code point value is between + * {@link #MIN_CODE_POINT} and + * {@link #MAX_CODE_POINT} inclusive; + * {@code false} otherwise. * @since 1.5 */ public static boolean isValidCodePoint(int codePoint) { @@ -2669,15 +2681,13 @@ class Character extends Object implements java.io.Serializable, Comparable
-     * codePoint >= 0x10000 && codePoint <= 0x10FFFF
-     * 
+ * is in the supplementary character range. * * @param codePoint the character (Unicode code point) to be tested - * @return true if the specified character is in the Unicode - * supplementary character range; false otherwise. + * @return {@code true} if the specified code point is between + * {@link #MIN_SUPPLEMENTARY_CODE_POINT} and + * {@link #MAX_CODE_POINT} inclusive; + * {@code false} otherwise. * @since 1.5 */ public static boolean isSupplementaryCodePoint(int codePoint) { @@ -2686,56 +2696,83 @@ class Character extends Object implements java.io.Serializable, Comparablechar value is a - * high-surrogate code unit (also known as leading-surrogate - * code unit). Such values do not represent characters by - * themselves, but are used in the representation of supplementary characters in the - * UTF-16 encoding. + * Determines if the given {@code char} value is a + * + * Unicode high-surrogate code unit + * (also known as leading-surrogate code unit). * - *

This method returns true if and only if - *

ch >= '\uD800' && ch <= '\uDBFF'
-     * 
- * is true. + *

Such values do not represent characters by themselves, + * but are used in the representation of + * supplementary characters + * in the UTF-16 encoding. * - * @param ch the char value to be tested. - * @return true if the char value - * is between '\uD800' and '\uDBFF' inclusive; - * false otherwise. - * @see java.lang.Character#isLowSurrogate(char) - * @see Character.UnicodeBlock#of(int) - * @since 1.5 + * @param ch the {@code char} value to be tested. + * @return {@code true} if the {@code char} value is between + * {@link #MIN_HIGH_SURROGATE} and + * {@link #MAX_HIGH_SURROGATE} inclusive; + * {@code false} otherwise. + * @see #isLowSurrogate(char) + * @see Character.UnicodeBlock#of(int) + * @since 1.5 */ public static boolean isHighSurrogate(char ch) { return ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE; } /** - * Determines if the given char value is a - * low-surrogate code unit (also known as trailing-surrogate code - * unit). Such values do not represent characters by themselves, - * but are used in the representation of supplementary characters in the UTF-16 encoding. + * Determines if the given {@code char} value is a + * + * Unicode low-surrogate code unit + * (also known as trailing-surrogate code unit). * - *

This method returns true if and only if - *

ch >= '\uDC00' && ch <= '\uDFFF'
-     * 
is true. + *

Such values do not represent characters by themselves, + * but are used in the representation of + * supplementary characters + * in the UTF-16 encoding. * - * @param ch the char value to be tested. - * @return true if the char value - * is between '\uDC00' and '\uDFFF' inclusive; - * false otherwise. - * @see java.lang.Character#isHighSurrogate(char) - * @since 1.5 + * @param ch the {@code char} value to be tested. + * @return {@code true} if the {@code char} value is between + * {@link #MIN_LOW_SURROGATE} and + * {@link #MAX_LOW_SURROGATE} inclusive; + * {@code false} otherwise. + * @see #isHighSurrogate(char) + * @since 1.5 */ public static boolean isLowSurrogate(char ch) { return ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE; } + /** + * Determines if the given {@code char} value is a Unicode + * surrogate code unit. + * + *

Such values do not represent characters by themselves, + * but are used in the representation of + * supplementary characters + * in the UTF-16 encoding. + * + *

A char value is a surrogate code unit if and only if it is either + * a {@linkplain #isLowSurrogate(char) low-surrogate code unit} or + * a {@linkplain #isHighSurrogate(char) high-surrogate code unit}. + * + * @param ch the {@code char} value to be tested. + * @return {@code true} if the {@code char} value is between + * {@link #MIN_SURROGATE} and + * {@link #MAX_SURROGATE} inclusive; + * {@code false} otherwise. + * @since 1.7 + */ + public static boolean isSurrogate(char ch) { + return ch >= MIN_SURROGATE && ch <= MAX_SURROGATE; + } + /** * Determines whether the specified pair of char - * values is a valid surrogate pair. This method is equivalent to - * the expression: + * values is a valid + * + * Unicode surrogate pair. + + *

This method is equivalent to the expression: *

      * isHighSurrogate(high) && isLowSurrogate(low)
      * 
@@ -4968,7 +5005,7 @@ class Character extends Object implements java.io.Serializable, Comparablechar value in unsigned - * binary form. + * binary form, constant {@code 16}. * * @since 1.5 */ diff --git a/jdk/src/share/classes/sun/io/CharToByteDBCS_ASCII.java b/jdk/src/share/classes/sun/io/CharToByteDBCS_ASCII.java index f1c9f38ff4b..f928b27b85a 100644 --- a/jdk/src/share/classes/sun/io/CharToByteDBCS_ASCII.java +++ b/jdk/src/share/classes/sun/io/CharToByteDBCS_ASCII.java @@ -91,7 +91,7 @@ public abstract class CharToByteDBCS_ASCII extends CharToByteConverter } // Is this a high surrogate? - if (Surrogate.isHigh(inputChar)) { + if (Character.isHighSurrogate(inputChar)) { // Is this the last character of the input? if (charOff + inputSize >= inEnd) { highHalfZoneCode = inputChar; @@ -101,7 +101,7 @@ public abstract class CharToByteDBCS_ASCII extends CharToByteConverter // Is there a low surrogate following? inputChar = input[charOff + inputSize]; - if (Surrogate.isLow(inputChar)) { + if (Character.isLowSurrogate(inputChar)) { // We have a valid surrogate pair. Too bad we don't do // surrogates. Is substitution enabled? if (subMode) { @@ -125,7 +125,7 @@ public abstract class CharToByteDBCS_ASCII extends CharToByteConverter } } // Is this an unaccompanied low surrogate? - else if (Surrogate.isLow(inputChar)) { + else if (Character.isLowSurrogate(inputChar)) { badInputLength = 1; throw new MalformedInputException(); } else { diff --git a/jdk/src/share/classes/sun/io/CharToByteDBCS_EBCDIC.java b/jdk/src/share/classes/sun/io/CharToByteDBCS_EBCDIC.java index a8d958e1d67..11e4a9ed73f 100644 --- a/jdk/src/share/classes/sun/io/CharToByteDBCS_EBCDIC.java +++ b/jdk/src/share/classes/sun/io/CharToByteDBCS_EBCDIC.java @@ -108,7 +108,7 @@ public abstract class CharToByteDBCS_EBCDIC extends CharToByteConverter } // Is this a high surrogate? - if (Surrogate.isHigh(inputChar)) { + if (Character.isHighSurrogate(inputChar)) { // Is this the last character of the input? if (charOff + inputSize >= inEnd) { highHalfZoneCode = inputChar; @@ -118,7 +118,7 @@ public abstract class CharToByteDBCS_EBCDIC extends CharToByteConverter // Is there a low surrogate following? inputChar = input[charOff + inputSize]; - if (Surrogate.isLow(inputChar)) { + if (Character.isLowSurrogate(inputChar)) { // We have a valid surrogate pair. Too bad we don't do // surrogates. Is substitution enabled? if (subMode) { @@ -142,7 +142,7 @@ public abstract class CharToByteDBCS_EBCDIC extends CharToByteConverter } } // Is this an unaccompanied low surrogate? - else if (Surrogate.isLow(inputChar)) { + else if (Character.isLowSurrogate(inputChar)) { badInputLength = 1; throw new MalformedInputException(); } else { diff --git a/jdk/src/share/classes/sun/nio/cs/ISO_8859_1.java b/jdk/src/share/classes/sun/nio/cs/ISO_8859_1.java index b57cfb96fb9..34dee6235b8 100644 --- a/jdk/src/share/classes/sun/nio/cs/ISO_8859_1.java +++ b/jdk/src/share/classes/sun/nio/cs/ISO_8859_1.java @@ -228,8 +228,8 @@ class ISO_8859_1 dst[dp++] = (byte)c; continue; } - if (Surrogate.isHigh(c) && sp < sl && - Surrogate.isLow(src[sp])) { + if (Character.isHighSurrogate(c) && sp < sl && + Character.isLowSurrogate(src[sp])) { if (len > dst.length) { sl++; len--; diff --git a/jdk/src/share/classes/sun/nio/cs/SingleByte.java b/jdk/src/share/classes/sun/nio/cs/SingleByte.java index 9b0531eebd9..0ef6c1e0689 100644 --- a/jdk/src/share/classes/sun/nio/cs/SingleByte.java +++ b/jdk/src/share/classes/sun/nio/cs/SingleByte.java @@ -171,7 +171,7 @@ public class SingleByte char c = sa[sp]; int b = encode(c); if (b == UNMAPPABLE_ENCODING) { - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { if (sgp == null) sgp = new Surrogate.Parser(); if (sgp.parse(c, sa, sp, sl) < 0) @@ -194,7 +194,7 @@ public class SingleByte char c = src.get(); int b = encode(c); if (b == UNMAPPABLE_ENCODING) { - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { if (sgp == null) sgp = new Surrogate.Parser(); if (sgp.parse(c, src) < 0) @@ -243,8 +243,8 @@ public class SingleByte dst[dp++] = (byte)b; continue; } - if (Surrogate.isHigh(c) && sp < sl && - Surrogate.isLow(src[sp])) { + if (Character.isHighSurrogate(c) && sp < sl && + Character.isLowSurrogate(src[sp])) { if (len > dst.length) { sl++; len--; diff --git a/jdk/src/share/classes/sun/nio/cs/SingleByteEncoder.java b/jdk/src/share/classes/sun/nio/cs/SingleByteEncoder.java index 1d983e8e375..e26c898ee6a 100644 --- a/jdk/src/share/classes/sun/nio/cs/SingleByteEncoder.java +++ b/jdk/src/share/classes/sun/nio/cs/SingleByteEncoder.java @@ -84,7 +84,7 @@ public abstract class SingleByteEncoder try { while (sp < sl) { char c = sa[sp]; - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { if (sgp.parse(c, sa, sp, sl) < 0) return sgp.error(); return sgp.unmappableResult(); @@ -117,7 +117,7 @@ public abstract class SingleByteEncoder try { while (src.hasRemaining()) { char c = src.get(); - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { if (sgp.parse(c, src) < 0) return sgp.error(); return sgp.unmappableResult(); diff --git a/jdk/src/share/classes/sun/nio/cs/Surrogate.java b/jdk/src/share/classes/sun/nio/cs/Surrogate.java index 9e036c8fd09..4791255435b 100644 --- a/jdk/src/share/classes/sun/nio/cs/Surrogate.java +++ b/jdk/src/share/classes/sun/nio/cs/Surrogate.java @@ -51,21 +51,24 @@ public class Surrogate { public static final int UCS4_MAX = Character.MAX_CODE_POINT; /** - * Tells whether or not the given UTF-16 value is a high surrogate. + * Tells whether or not the given value is in the high surrogate range. + * Use of {@link Character#isHighSurrogate} is generally preferred. */ public static boolean isHigh(int c) { return (MIN_HIGH <= c) && (c <= MAX_HIGH); } /** - * Tells whether or not the given UTF-16 value is a low surrogate. + * Tells whether or not the given value is in the low surrogate range. + * Use of {@link Character#isLowSurrogate} is generally preferred. */ public static boolean isLow(int c) { return (MIN_LOW <= c) && (c <= MAX_LOW); } /** - * Tells whether or not the given UTF-16 value is a surrogate character, + * Tells whether or not the given value is in the surrogate range. + * Use of {@link Character#isSurrogate} is generally preferred. */ public static boolean is(int c) { return (MIN <= c) && (c <= MAX); @@ -88,7 +91,7 @@ public class Surrogate { } /** - * Returns the high UTF-16 surrogate for the given UCS-4 character. + * Returns the high UTF-16 surrogate for the given supplementary UCS-4 character. */ public static char high(int uc) { assert Character.isSupplementaryCodePoint(uc); @@ -98,7 +101,7 @@ public class Surrogate { } /** - * Returns the low UTF-16 surrogate for the given UCS-4 character. + * Returns the low UTF-16 surrogate for the given supplementary UCS-4 character. */ public static char low(int uc) { assert Character.isSupplementaryCodePoint(uc); diff --git a/jdk/src/share/classes/sun/nio/cs/US_ASCII.java b/jdk/src/share/classes/sun/nio/cs/US_ASCII.java index fe454bbee3f..182c00b907d 100644 --- a/jdk/src/share/classes/sun/nio/cs/US_ASCII.java +++ b/jdk/src/share/classes/sun/nio/cs/US_ASCII.java @@ -247,8 +247,8 @@ public class US_ASCII dst[dp++] = (byte)c; continue; } - if (Surrogate.isHigh(c) && sp < sl && - Surrogate.isLow(src[sp])) { + if (Character.isHighSurrogate(c) && sp < sl && + Character.isLowSurrogate(src[sp])) { if (len > dst.length) { sl++; len--; diff --git a/jdk/src/share/classes/sun/nio/cs/UTF_32Coder.java b/jdk/src/share/classes/sun/nio/cs/UTF_32Coder.java index 1229699d31f..6edfdfd7c52 100644 --- a/jdk/src/share/classes/sun/nio/cs/UTF_32Coder.java +++ b/jdk/src/share/classes/sun/nio/cs/UTF_32Coder.java @@ -154,11 +154,11 @@ class UTF_32Coder { try { while (src.hasRemaining()) { char c = src.get(); - if (Surrogate.isHigh(c)) { + if (Character.isHighSurrogate(c)) { if (!src.hasRemaining()) return CoderResult.UNDERFLOW; char low = src.get(); - if (Surrogate.isLow(low)) { + if (Character.isLowSurrogate(low)) { if (dst.remaining() < 4) return CoderResult.OVERFLOW; mark += 2; @@ -166,7 +166,7 @@ class UTF_32Coder { } else { return CoderResult.malformedForLength(1); } - } else if (Surrogate.isLow(c)) { + } else if (Character.isLowSurrogate(c)) { return CoderResult.malformedForLength(1); } else { if (dst.remaining() < 4) diff --git a/jdk/src/share/classes/sun/nio/cs/UTF_8.java b/jdk/src/share/classes/sun/nio/cs/UTF_8.java index 589e3679511..7b7da2da1c5 100644 --- a/jdk/src/share/classes/sun/nio/cs/UTF_8.java +++ b/jdk/src/share/classes/sun/nio/cs/UTF_8.java @@ -334,7 +334,7 @@ class UTF_8 extends Unicode } public boolean canEncode(char c) { - return !Surrogate.is(c); + return !Character.isSurrogate(c); } public boolean isLegalReplacement(byte[] repl) { @@ -370,7 +370,7 @@ class UTF_8 extends Unicode while (dp < dlASCII && sa[sp] < '\u0080') da[dp++] = (byte) sa[sp++]; while (sp < sl) { - int c = sa[sp]; + char c = sa[sp]; if (c < 0x80) { // Have at most seven bits if (dp >= dl) @@ -382,11 +382,11 @@ class UTF_8 extends Unicode return overflow(src, sp, dst, dp); da[dp++] = (byte)(0xc0 | ((c >> 06))); da[dp++] = (byte)(0x80 | (c & 0x3f)); - } else if (Surrogate.is(c)) { + } else if (Character.isSurrogate(c)) { // Have a surrogate pair if (sgp == null) sgp = new Surrogate.Parser(); - int uc = sgp.parse((char)c, sa, sp, sl); + int uc = sgp.parse(c, sa, sp, sl); if (uc < 0) { updatePositions(src, sp, dst, dp); return sgp.error(); @@ -417,7 +417,7 @@ class UTF_8 extends Unicode { int mark = src.position(); while (src.hasRemaining()) { - int c = src.get(); + char c = src.get(); if (c < 0x80) { // Have at most seven bits if (!dst.hasRemaining()) @@ -429,11 +429,11 @@ class UTF_8 extends Unicode return overflow(src, mark); dst.put((byte)(0xc0 | ((c >> 06)))); dst.put((byte)(0x80 | (c & 0x3f))); - } else if (Surrogate.is(c)) { + } else if (Character.isSurrogate(c)) { // Have a surrogate pair if (sgp == null) sgp = new Surrogate.Parser(); - int uc = sgp.parse((char)c, src); + int uc = sgp.parse(c, src); if (uc < 0) { src.position(mark); return sgp.error(); diff --git a/jdk/src/share/classes/sun/nio/cs/UnicodeDecoder.java b/jdk/src/share/classes/sun/nio/cs/UnicodeDecoder.java index 67afe2f897c..4e833a049b1 100644 --- a/jdk/src/share/classes/sun/nio/cs/UnicodeDecoder.java +++ b/jdk/src/share/classes/sun/nio/cs/UnicodeDecoder.java @@ -97,12 +97,12 @@ abstract class UnicodeDecoder extends CharsetDecoder { } // Surrogates - if (Surrogate.is(c)) { - if (Surrogate.isHigh(c)) { + if (Character.isSurrogate(c)) { + if (Character.isHighSurrogate(c)) { if (src.remaining() < 2) return CoderResult.UNDERFLOW; char c2 = decode(src.get() & 0xff, src.get() & 0xff); - if (!Surrogate.isLow(c2)) + if (!Character.isLowSurrogate(c2)) return CoderResult.malformedForLength(4); if (dst.remaining() < 2) return CoderResult.OVERFLOW; diff --git a/jdk/src/share/classes/sun/nio/cs/UnicodeEncoder.java b/jdk/src/share/classes/sun/nio/cs/UnicodeEncoder.java index c14bbbe772b..67a7f176db6 100644 --- a/jdk/src/share/classes/sun/nio/cs/UnicodeEncoder.java +++ b/jdk/src/share/classes/sun/nio/cs/UnicodeEncoder.java @@ -80,7 +80,7 @@ public abstract class UnicodeEncoder extends CharsetEncoder { try { while (src.hasRemaining()) { char c = src.get(); - if (!Surrogate.is(c)) { + if (!Character.isSurrogate(c)) { if (dst.remaining() < 2) return CoderResult.OVERFLOW; mark++; @@ -107,6 +107,6 @@ public abstract class UnicodeEncoder extends CharsetEncoder { } public boolean canEncode(char c) { - return ! Surrogate.is(c); + return ! Character.isSurrogate(c); } } diff --git a/jdk/src/share/classes/sun/nio/cs/ext/DoubleByte.java b/jdk/src/share/classes/sun/nio/cs/ext/DoubleByte.java index b7372ba20b7..04f1cb89746 100644 --- a/jdk/src/share/classes/sun/nio/cs/ext/DoubleByte.java +++ b/jdk/src/share/classes/sun/nio/cs/ext/DoubleByte.java @@ -449,7 +449,7 @@ public class DoubleByte { char c = sa[sp]; int bb = encodeChar(c); if (bb == UNMAPPABLE_ENCODING) { - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { if (sgp().parse(c, sa, sp, sl) < 0) return sgp.error(); return sgp.unmappableResult(); @@ -484,7 +484,7 @@ public class DoubleByte { char c = src.get(); int bb = encodeChar(c); if (bb == UNMAPPABLE_ENCODING) { - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { if (sgp().parse(c, src) < 0) return sgp.error(); return sgp.unmappableResult(); @@ -659,7 +659,7 @@ public class DoubleByte { char c = sa[sp]; int bb = encodeChar(c); if (bb == UNMAPPABLE_ENCODING) { - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { if (sgp().parse(c, sa, sp, sl) < 0) return sgp.error(); return sgp.unmappableResult(); @@ -705,7 +705,7 @@ public class DoubleByte { char c = src.get(); int bb = encodeChar(c); if (bb == UNMAPPABLE_ENCODING) { - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { if (sgp().parse(c, src) < 0) return sgp.error(); return sgp.unmappableResult(); diff --git a/jdk/src/share/classes/sun/nio/cs/ext/DoubleByteEncoder.java b/jdk/src/share/classes/sun/nio/cs/ext/DoubleByteEncoder.java index e548951da0e..d112c83c7b2 100644 --- a/jdk/src/share/classes/sun/nio/cs/ext/DoubleByteEncoder.java +++ b/jdk/src/share/classes/sun/nio/cs/ext/DoubleByteEncoder.java @@ -95,7 +95,7 @@ public abstract class DoubleByteEncoder try { while (sp < sl) { char c = sa[sp]; - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { if (sgp.parse(c, sa, sp, sl) < 0) return sgp.error(); if (sl - sp < 2) @@ -153,7 +153,7 @@ public abstract class DoubleByteEncoder try { while (src.hasRemaining()) { char c = src.get(); - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { int surr; if ((surr = sgp.parse(c, src)) < 0) return sgp.error(); diff --git a/jdk/src/share/classes/sun/nio/cs/ext/EUC_JP.java b/jdk/src/share/classes/sun/nio/cs/ext/EUC_JP.java index e29842eec06..0c13aa4b502 100644 --- a/jdk/src/share/classes/sun/nio/cs/ext/EUC_JP.java +++ b/jdk/src/share/classes/sun/nio/cs/ext/EUC_JP.java @@ -318,7 +318,7 @@ public class EUC_JP outputByte = tmpBuf; char c = sa[sp]; - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { if (sgp.parse(c, sa, sp, sl) < 0) return sgp.error(); return sgp.unmappableResult(); @@ -372,7 +372,7 @@ public class EUC_JP while (src.hasRemaining()) { outputByte = tmpBuf; char c = src.get(); - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { if (sgp.parse(c, src) < 0) return sgp.error(); return sgp.unmappableResult(); diff --git a/jdk/src/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java b/jdk/src/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java index 1db75fa15f7..d39084d8f1f 100644 --- a/jdk/src/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java +++ b/jdk/src/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java @@ -285,7 +285,7 @@ public class EUC_JP_LINUX while (sp < sl) { char c = sa[sp]; - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { if (sgp.parse(c, sa, sp, sl) < 0) return sgp.error(); return sgp.unmappableResult(); @@ -327,7 +327,7 @@ public class EUC_JP_LINUX try { while (src.hasRemaining()) { char c = src.get(); - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { if (sgp.parse(c, src) < 0) return sgp.error(); return sgp.unmappableResult(); diff --git a/jdk/src/share/classes/sun/nio/cs/ext/EUC_TW.java b/jdk/src/share/classes/sun/nio/cs/ext/EUC_TW.java index 158407bd108..5830da0f042 100644 --- a/jdk/src/share/classes/sun/nio/cs/ext/EUC_TW.java +++ b/jdk/src/share/classes/sun/nio/cs/ext/EUC_TW.java @@ -310,11 +310,11 @@ public class EUC_TW extends Charset implements HistoricallyNamedCharset int i = 0; while (i < cs.length()) { char c = cs.charAt(i++); - if (Surrogate.isHigh(c)) { + if (Character.isHighSurrogate(c)) { if (i == cs.length()) return false; char low = cs.charAt(i++); - if (!Surrogate.isLow(low) || toEUC(c, low, bb) == -1) + if (!Character.isLowSurrogate(low) || toEUC(c, low, bb) == -1) return false; } else if (!canEncode(c)) { return false; @@ -361,14 +361,14 @@ public class EUC_TW extends Charset implements HistoricallyNamedCharset // supplementary character encoding. given the use // of supplementary characters is really rare, this // is something worth doing. - if (Surrogate.isHigh(c)) { + if (Character.isHighSurrogate(c)) { if ((sp + 1) == sl) return CoderResult.UNDERFLOW; - if (!Surrogate.isLow(sa[sp + 1])) + if (!Character.isLowSurrogate(sa[sp + 1])) return CoderResult.malformedForLength(1); outSize = toEUC(c, sa[sp+1], bb); inSize = 2; - } else if (Surrogate.isLow(c)) { + } else if (Character.isLowSurrogate(c)) { return CoderResult.malformedForLength(1); } } @@ -405,15 +405,15 @@ public class EUC_TW extends Charset implements HistoricallyNamedCharset } else { outSize = toEUC(c, bb); if (outSize == -1) { - if (Surrogate.isHigh(c)) { + if (Character.isHighSurrogate(c)) { if (!src.hasRemaining()) return CoderResult.UNDERFLOW; char c2 = src.get(); - if (!Surrogate.isLow(c2)) + if (!Character.isLowSurrogate(c2)) return CoderResult.malformedForLength(1); outSize = toEUC(c, c2, bb); inSize = 2; - } else if (Surrogate.isLow(c)) { + } else if (Character.isLowSurrogate(c)) { return CoderResult.malformedForLength(1); } } diff --git a/jdk/src/share/classes/sun/nio/cs/ext/GB18030.java b/jdk/src/share/classes/sun/nio/cs/ext/GB18030.java index 53b66fa917e..76392bda2f1 100644 --- a/jdk/src/share/classes/sun/nio/cs/ext/GB18030.java +++ b/jdk/src/share/classes/sun/nio/cs/ext/GB18030.java @@ -12586,7 +12586,7 @@ public class GB18030 } public boolean canEncode(char c) { - return ! Surrogate.is(c); + return ! Character.isSurrogate(c); } private final Surrogate.Parser sgp = new Surrogate.Parser(); @@ -12625,7 +12625,7 @@ public class GB18030 int inputSize = 1; char c = sa[sp]; - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { if ((condensedKey=sgp.parse(c, sa, sp, sl)) < 0) return sgp.error(); // Surogate.toUCS4 looks like @@ -12719,7 +12719,7 @@ public class GB18030 while (src.hasRemaining()) { char c = src.get(); int inputSize = 1; - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { if ((condensedKey = sgp.parse(c, src))<0) return sgp.error(); condensedKey += 0x1e248; diff --git a/jdk/src/share/classes/sun/nio/cs/ext/ISCII91.java b/jdk/src/share/classes/sun/nio/cs/ext/ISCII91.java index 284cfda330e..7087036467a 100644 --- a/jdk/src/share/classes/sun/nio/cs/ext/ISCII91.java +++ b/jdk/src/share/classes/sun/nio/cs/ext/ISCII91.java @@ -885,7 +885,7 @@ public class ISCII91 extends Charset implements HistoricallyNamedCharset index = ((int)(inputChar) - 0x0900)*2; } - if (Surrogate.is(inputChar)) { + if (Character.isSurrogate(inputChar)) { if (sgp.parse(inputChar, sa, sp, sl) < 0) return sgp.error(); return sgp.unmappableResult(); @@ -948,7 +948,7 @@ public class ISCII91 extends Charset implements HistoricallyNamedCharset index = ((int)(inputChar) - 0x0900)*2; } - if (Surrogate.is(inputChar)) { + if (Character.isSurrogate(inputChar)) { if (sgp.parse(inputChar, src) < 0) return sgp.error(); return sgp.unmappableResult(); diff --git a/jdk/src/share/classes/sun/nio/cs/ext/ISO2022.java b/jdk/src/share/classes/sun/nio/cs/ext/ISO2022.java index 036dc04299d..8038d18f6a9 100644 --- a/jdk/src/share/classes/sun/nio/cs/ext/ISO2022.java +++ b/jdk/src/share/classes/sun/nio/cs/ext/ISO2022.java @@ -515,7 +515,7 @@ abstract class ISO2022 try { while (sp < sl) { char c = sa[sp]; - if (Surrogate.is(c)) { + if (Character.isSurrogate(c)) { if (sgp.parse(c, sa, sp, sl) < 0) return sgp.error(); return sgp.unmappableResult(); @@ -576,7 +576,7 @@ abstract class ISO2022 try { while (src.hasRemaining()) { char inputChar = src.get(); - if (Surrogate.is(inputChar)) { + if (Character.isSurrogate(inputChar)) { if (sgp.parse(inputChar, src) < 0) return sgp.error(); return sgp.unmappableResult(); diff --git a/jdk/src/share/classes/sun/nio/cs/ext/ISO2022_JP.java b/jdk/src/share/classes/sun/nio/cs/ext/ISO2022_JP.java index e92238e3714..69d2c9b413e 100644 --- a/jdk/src/share/classes/sun/nio/cs/ext/ISO2022_JP.java +++ b/jdk/src/share/classes/sun/nio/cs/ext/ISO2022_JP.java @@ -637,7 +637,7 @@ public class ISO2022_JP da[dp++] = (byte)(index >> 8); da[dp++] = (byte)(index & 0xff); } else { - if (Surrogate.is(c) && sgp.parse(c, sa, sp, sl) < 0) + if (Character.isSurrogate(c) && sgp.parse(c, sa, sp, sl) < 0) return sgp.error(); if (unmappableCharacterAction() == CodingErrorAction.REPLACE @@ -655,7 +655,7 @@ public class ISO2022_JP } currentMode = replaceMode; } - if (Surrogate.is(c)) + if (Character.isSurrogate(c)) return sgp.unmappableResult(); return CoderResult.unmappableForLength(1); } @@ -745,7 +745,7 @@ public class ISO2022_JP dst.put((byte)(index >> 8)); dst.put((byte)(index & 0xff)); } else { - if (Surrogate.is(c) && sgp.parse(c, src) < 0) + if (Character.isSurrogate(c) && sgp.parse(c, src) < 0) return sgp.error(); if (unmappableCharacterAction() == CodingErrorAction.REPLACE && currentMode != replaceMode) { @@ -762,7 +762,7 @@ public class ISO2022_JP } currentMode = replaceMode; } - if (Surrogate.is(c)) + if (Character.isSurrogate(c)) return sgp.unmappableResult(); return CoderResult.unmappableForLength(1); } diff --git a/jdk/src/share/classes/sun/nio/cs/ext/SimpleEUCEncoder.java b/jdk/src/share/classes/sun/nio/cs/ext/SimpleEUCEncoder.java index 308087376c9..8ce14afbcd3 100644 --- a/jdk/src/share/classes/sun/nio/cs/ext/SimpleEUCEncoder.java +++ b/jdk/src/share/classes/sun/nio/cs/ext/SimpleEUCEncoder.java @@ -114,7 +114,7 @@ public abstract class SimpleEUCEncoder while (sp < sl) { boolean allZeroes = true; char inputChar = sa[sp]; - if (Surrogate.is(inputChar)) { + if (Character.isSurrogate(inputChar)) { if (sgp.parse(inputChar, sa, sp, sl) < 0) return sgp.error(); return sgp.unmappableResult(); @@ -194,7 +194,7 @@ public abstract class SimpleEUCEncoder while (src.hasRemaining()) { char inputChar = src.get(); boolean allZeroes = true; - if (Surrogate.is(inputChar)) { + if (Character.isSurrogate(inputChar)) { if (sgp.parse(inputChar, src) < 0) return sgp.error(); return sgp.unmappableResult();