Package java.text

Examples of java.text.BreakIterator.first()


        // assume @tag signifies end of sentence
        text = text.replaceFirst("(?ms)\\n\\s*@(see|param|throws|return|author|since|exception|version|deprecated|todo)\\s.*", "").trim();
        // Comment Summary using first sentence (Locale sensitive)
        BreakIterator boundary = BreakIterator.getSentenceInstance(Locale.getDefault()); // todo - allow locale to be passed in
        boundary.setText(text);
        int start = boundary.first();
        int end = boundary.next();
        if (start > -1 && end > -1) {
            // need to abbreviate this comment for the summary
            text = text.substring(start, end);
        }
View Full Code Here


      it = BreakIterator.getCharacterInstance();
    }
    it.setText(text);

    int lineLen = 0;
    int start = it.first();
    for (int end = it.next(); end != BreakIterator.DONE; start = end, end = it
        .next()) {
      String next = text.substring(start, end);

      if (lineLen + next.length() > width) {
View Full Code Here

        if(text == null)
            return "";
        // First try to get the first sentence
        BreakIterator breaker = BreakIterator.getSentenceInstance();
        breaker.setText(text);
        breaker.first();
        int dot = breaker.next();
        // First sentence is sufficiently short
        if (dot != BreakIterator.DONE
                && dot <= FIRST_LINE_MAX_SIZE) {
            return text.substring(0, dot).replaceAll("\\s*$", "");
View Full Code Here

            return text;
        }
        // First sentence is really long, to try to break on a word
        breaker = BreakIterator.getWordInstance();
        breaker.setText(text);
        int pos = breaker.first();
        while (pos < FIRST_LINE_MAX_SIZE
                && pos != BreakIterator.DONE) {
            pos = breaker.next();
        }
        if (pos != BreakIterator.DONE
View Full Code Here

     * JCL Foundation (bug 80053). Also need to do this in an NL-sensitive way.
     * The use of BreakIterator 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();

View Full Code Here

        List<StringBuilder> lines = new ArrayList<StringBuilder>();
        StringBuilder line = new StringBuilder();
        lines.add(line);
        BreakIterator it = BreakIterator.getWordInstance();
        it.setText(originalText);
        int prev = it.first();
        int next;
        while ((next = it.next()) != BreakIterator.DONE) {
            String part = originalText.substring(prev, next);
            if (fm.stringWidth(line.toString() + part) > width) {
                line = new StringBuilder();
View Full Code Here

    @Override
    public boolean matches(String input, int offset) {
        BreakIterator it = BreakIterator.getWordInstance();
        String part = input.substring(offset, input.length());
        it.setText(part);
        int start = it.first();
        int end = it.next();
        if (end == BreakIterator.DONE) {
            this.offset = -1;
            lexeme = null;
            return false;
View Full Code Here

        BreakIterator boundary = BreakIterator.getLineInstance(locale);
        StringBuffer result = new StringBuffer(prefix1);

        boundary.setText(text);

        int start = boundary.first();
        int end = boundary.next();
        int lineLength = 0;

        while (end != BreakIterator.DONE) {
            String word = text.substring(start, end);
View Full Code Here

            captionLabel.setText(caption);

            BreakIterator iter = BreakIterator.getWordInstance();
            if (text != null) {
                iter.setText(text);
                int start = iter.first(), end;
                int nLines = 0;

                do {
                    end = iter.next();
View Full Code Here

                    line = BreakIterator.getLineInstance(c.getLocale());
                } else {
                    line = BreakIterator.getLineInstance();
                }
                line.setText(segment);
                int start = line.first();
                for (int end = line.next();
                     end != BreakIterator.DONE;
                     start = end, end = line.next()) {
                    if (end > start) {
                        span = Math.max(span,
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.