Package java.text

Examples of java.text.BreakIterator.preceding()


    private String getLine(int index) {
        String result = null;
        BreakIterator bi = BreakIterator.getSentenceInstance();
        bi.setText(getText());
        int end = bi.following(index);
        int start = bi.preceding(end - 1);
        try {
            result = document.getText(start, end - start);
        } catch (BadLocationException e) {
            e.printStackTrace();
        }
View Full Code Here


        String content = null;
        content = document.getText(0, length);
        bi.setText(content);
        int iteratorWordStart = pos;
        if (pos < length - 1) {
            iteratorWordStart = bi.preceding(pos + 1);
        } else {
            bi.last();
            iteratorWordStart = bi.previous();
        }
        return iteratorWordStart;
View Full Code Here

            return bi.last() - offset;
        }
        if (bi.isBoundary(fullIndex)) {
            return Character.isWhitespace(s.array[fullIndex]) ? index + 1 : index;
        }
        int prev = bi.preceding(fullIndex);
        if (prev == bi.first()) {
            return index;
        }
        return prev - offset;
    }
View Full Code Here

        int iteratorWordStart = 0;
        bi.first();
        for (int i = 0; i < length; i++) {
            int utilitiesWordStart = 0;
            if (i < length - 1) {
                iteratorWordStart = bi.preceding(i + 1);
            } else {
                bi.last();
                iteratorWordStart = bi.previous();
            }
            try {
View Full Code Here

        }
        assertNotNull(content);
        bi.first();
        for (int i = 0; i < length; i++) {
            int utilitiesPrevWord = 0;
            int iteratorPrevWord = bi.preceding(i);
            while (iteratorPrevWord > 0
                    && ((content.charAt(iteratorPrevWord) == ' ' || content
                            .charAt(iteratorPrevWord) == '\n') || content
                            .charAt(iteratorPrevWord) == '\t')) {
                iteratorPrevWord = bi.preceding(iteratorPrevWord);
View Full Code Here

            int iteratorPrevWord = bi.preceding(i);
            while (iteratorPrevWord > 0
                    && ((content.charAt(iteratorPrevWord) == ' ' || content
                            .charAt(iteratorPrevWord) == '\n') || content
                            .charAt(iteratorPrevWord) == '\t')) {
                iteratorPrevWord = bi.preceding(iteratorPrevWord);
            }
            try {
                utilitiesPrevWord = Utilities.getPreviousWord(c, i);
            } catch (BadLocationException e) {
            }
View Full Code Here

                        char c = text.charAt(lineBreakIndex);
                        if (Character.isWhitespace(c)) {
                            end = breakIterator.following(lineBreakIndex);
                        } else {
                            // Move back to the previous break
                            end = breakIterator.preceding(lineBreakIndex);

                            if (end <= start) {
                                // The whole word doesn't fit in the given space
                                if (breakOnWhitespaceOnly) {
                                    // Move forward to the next break
View Full Code Here

                    words.setText(s);
                    int end = findWordLimit(index, words, PREVIOUS, s);
                    if (end == BreakIterator.DONE) {
                        return null;
                    }
                    int start = words.preceding(end);
                    if (start == BreakIterator.DONE) {
                        return null;
                    }
                    return s.substring(start, end);
                }
View Full Code Here

          return null;
      }
      it.setText(text);
      int start = index;
      if (!it.isBoundary(index))
        start = it.preceding(index);
      int end = it.following(index);
      if (end == -1)
        return text.substring(index);
      else
        return text.substring(index, end);
View Full Code Here

          return null;
      }
      it.setText(text);
      int end = index;
      if (!it.isBoundary(index))
        end = it.preceding(index);
      // Make sure there was a complete unit.  I.e. if index is in the middle
      // of a word, return null if there is no word before that one.
      if (end == -1)
        return null;
      int start = it.preceding(end);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.