[BI] BreakIterator Line Instance breaks on WORDS

XMLWordPrintable

    • Type: Bug
    • Resolution: Not an Issue
    • Priority: P4
    • None
    • Affects Version/s: 6u10
    • Component/s: core-libs
    • x86
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.6.0_20"
      Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
      Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7600]

      A DESCRIPTION OF THE PROBLEM :
      Trying to use BreakIterator returned by getLineInstance().

      It's breaking on WORDS, not LINES.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run supplied code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expected the text to be broken on LINE boundaries, but it's breaking on WORD boundaries.

      I got this:
      =======
      idx1=0 idx2=4
      idx1=4 idx2=7
      time=>>>now <<< author=>>>is
      <<<

      There is no Line Break between "now" and "is"
      ACTUAL -
      I expected this:
      ============
      idx1=0 idx2=6
      idx1=6 idx2=-1
      time=>>>now is
      <<< author=>>>the time<<<

      The Line Break is between "now is" and "the time"

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package xxtest;

      import java.text.*;
      import java.util.*;

      public class X
      {

        public static void main(String[] args)
        {
          String header = "now is\nthe time ";
          String time = null;
          String author = null;

          BreakIterator bi = BreakIterator.getLineInstance();
          bi.setText(header);
          int idx1 = bi.first();
          int idx2 = bi.next();
          System.out.println("idx1=" + idx1 + " idx2=" + idx2);
          time = header.substring(idx1, idx2);//.trim();
          if (idx2 == BreakIterator.DONE) {
          } else {
            idx1 = idx2;
            idx2 = bi.next();
            System.out.println("idx1=" + idx1 + " idx2=" + idx2);
            author = header.substring(idx1, idx2);//.trim();
          }

          System.out.println("time=>>>" + time + "<<< author=>>>" + author + "<<<");
        }
      }
      ---------- END SOURCE ----------

            Assignee:
            Yuka Kamiya (Inactive)
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: