Package java.text

Examples of java.text.BreakIterator.following()


            try {
                String s = unoObject.getText();
                BreakIterator sentence =
                    BreakIterator.getSentenceInstance(getLocale(index));
                sentence.setText(s);
                int end = sentence.following(index);
                return s.substring(sentence.previous(), end);
            } catch (IllegalArgumentException e) {
                return null;
            } catch (IndexOutOfBoundsException e) {
                return null;
View Full Code Here


        // was suggested in bug 90579.
        BreakIterator iter = BreakIterator.getWordInstance();
        iter.setText(text);
        int i = iter.first();
        while (i != java.text.BreakIterator.DONE && i < text.length()) {
            int j = iter.following(i);
            if (j == java.text.BreakIterator.DONE)
                j = text.length();
            if (Character.isLetterOrDigit(text.charAt(i))) {
                String word = text.substring(i, j);
                if (match(word))
View Full Code Here

    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

        if (pos < 0 || pos > length) {
            throwException("No word at " + pos, pos);
        }
        String content = document.getText(0, length);
        bi.setText(content);
        return (pos < bi.last()) ? bi.following(pos) : pos;
    }

    private int getWordStart(final int pos) throws BadLocationException {
        BreakIterator bi = BreakIterator.getWordInstance();
        int length = document.getLength();
View Full Code Here

        String content = null;

        content = doc.getText(0, doc.getLength());
        bi.setText(content);

        int iteratorNextWord = bi.following(pos);
        while (iteratorNextWord < length
             && ((content.charAt(iteratorNextWord) == ' '
             || content.charAt(iteratorNextWord) == '\n')
             || content.charAt(iteratorNextWord) == '\t')) {
             iteratorNextWord = bi.following(iteratorNextWord);
View Full Code Here

        int iteratorNextWord = bi.following(pos);
        while (iteratorNextWord < length
             && ((content.charAt(iteratorNextWord) == ' '
             || content.charAt(iteratorNextWord) == '\n')
             || content.charAt(iteratorNextWord) == '\t')) {
             iteratorNextWord = bi.following(iteratorNextWord);
        }
        if (iteratorNextWord == length) {
             iteratorNextWord = 0;
        }
        return iteratorNextWord;
View Full Code Here

        if (pos < 0 || pos > length) {
            throwException("No word at " + pos, pos);
        }
        String content = doc.getText(0, doc.getLength());
        bi.setText(content);
        return (pos < bi.last()) ? bi.following(pos) : pos;
   }

   public static final int getWordStart(final TextKit tk, final int pos)
        throws BadLocationException {
        Document doc = tk.getDocument();
View Full Code Here

                default:
                    return null;
                }
                seg.first();
                iterator.setText(seg);
                int end = iterator.following(index - seg.modelOffset + seg.offset);
                if (end == BreakIterator.DONE) {
                    return null;
                }
                if (end > seg.offset + seg.count) {
                    return null;
View Full Code Here

                return TextComponent.this.getText().substring(index, index+1);
            case AccessibleText.WORD:  {
                    String s = TextComponent.this.getText();
                    BreakIterator words = BreakIterator.getWordInstance();
                    words.setText(s);
                    int end = words.following(index);
                    return s.substring(words.previous(), end);
                }
            case AccessibleText.SENTENCE:  {
                    String s = TextComponent.this.getText();
                    BreakIterator sentence = BreakIterator.getSentenceInstance();
View Full Code Here

                }
            case AccessibleText.SENTENCE:  {
                    String s = TextComponent.this.getText();
                    BreakIterator sentence = BreakIterator.getSentenceInstance();
                    sentence.setText(s);
                    int end = sentence.following(index);
                    return s.substring(sentence.previous(), end);
                }
            default:
                return null;
            }
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.