]> granicus.if.org Git - icu/commitdiff
ICU-13461 Fixing build error in Java 6.
authorShane Carr <shane@unicode.org>
Mon, 12 Feb 2018 23:21:27 +0000 (23:21 +0000)
committerShane Carr <shane@unicode.org>
Mon, 12 Feb 2018 23:21:27 +0000 (23:21 +0000)
X-SVN-Rev: 40899

icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/NumberParserImpl.java
icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/StringSegment.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/StringSegmentTest.java

index 577cc1f850bc85a4372043000e9471a0b421c6d3..3db8b782aec514e7ad8799c076d80c769d6d6b56 100644 (file)
@@ -307,14 +307,8 @@ public class NumberParserImpl {
     /**
      * Creates a new, empty parser.
      *
-     * @param ignoreCase
-     *            If true, perform case-folding. This parameter needs to go into the constructor because
-     *            its value is used during the construction of the matcher chain.
-     * @param optimize
-     *            If true, compute "lead chars" UnicodeSets for the matchers. This reduces parsing
-     *            runtime but increases construction runtime. If the parser is going to be used only once
-     *            or twice, set this to false; if it is going to be used hundreds of times, set it to
-     *            true.
+     * @param parseFlags
+     *            The parser settings defined in the PARSE_FLAG_* fields.
      */
     public NumberParserImpl(int parseFlags) {
         matchers = new ArrayList<NumberParseMatcher>();
index bc0cab0c5d02bd733dd8e09e9ed418146c922384..eb2b27bc8eefd3e979fa245268618b11eb527e45 100644 (file)
@@ -92,13 +92,13 @@ public class StringSegment implements CharSequence {
     public int getCodePoint() {
         assert start < end;
         char lead = str.charAt(start);
-        if (Character.isHighSurrogate(lead) && start + 1 < end) {
-            return Character.toCodePoint(lead, str.charAt(start + 1));
-        } else if (Character.isSurrogate(lead)) {
-            return -1;
-        } else {
-            return lead;
+        char trail;
+        if (Character.isHighSurrogate(lead)
+                && start + 1 < end
+                && Character.isLowSurrogate(trail = str.charAt(start + 1))) {
+            return Character.toCodePoint(lead, trail);
         }
+        return lead;
     }
 
     /**
index cb4106ad93414aa7346f989966dcdbe7c177a28c..833df6537e9ebe6dc8b58fdf6f5315f39832a7e0 100644 (file)
@@ -56,10 +56,10 @@ public class StringSegmentTest {
         StringSegment segment = new StringSegment(SAMPLE_STRING, 0);
         assertEquals(0x1F4FB, segment.getCodePoint());
         segment.setLength(1);
-        assertEquals(-1, segment.getCodePoint());
+        assertEquals(0xD83D, segment.getCodePoint());
         segment.resetLength();
         segment.adjustOffset(1);
-        assertEquals(-1, segment.getCodePoint());
+        assertEquals(0xDCFB, segment.getCodePoint());
         segment.adjustOffset(1);
         assertEquals(0x20, segment.getCodePoint());
     }