API: Add TextBoundary.isBoundary(offset) and preceeding(offset)

XMLWordPrintable

    • 1.2beta4
    • x86
    • windows_nt
    • Not verified



      Name: bb33257 Date: 05/15/97


      TextBoundary should have the following methods. The first
      is for convenience. The second one allows you to make a
      performance speedup when selecting words.

          /**
           * Check whether current offset is a boundary
           * @param offset offset in the text to check.
           * @return whether the offset is a boundary.
           */
          public boolean isBoundary(int offset)
          {
           if (offset == 0) return true;
           return following(offset-1) == offset;
          }

          /**
           * Return the first boundary before the specified offset
           * @param offset the offset to start
           * @return int the first boundary before offset
           */
          public int preceding(int offset)
          {
              if (offset < text.getBeginIndex() ||
                  offset >= text.getEndIndex())
                  throw new IllegalArgumentException(
                    "nextBoundaryAt offset out of bounds");
              pos = previousSafePosition(offset);
              int curr = pos;
              int last;
              do {
                  last = curr;
                  curr = next();
              } while (curr < offset && curr != DONE);
              return last;
          }
      ======================================================================

            Assignee:
            Richard Gillam (Inactive)
            Reporter:
            Brian Beck (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: