Example usage for java.text BreakIterator DONE

List of usage examples for java.text BreakIterator DONE

Introduction

In this page you can find the example usage for java.text BreakIterator DONE.

Prototype

int DONE

To view the source code for java.text BreakIterator DONE.

Click Source Link

Document

DONE is returned by previous(), next(), next(int), preceding(int) and following(int) when either the first or last text boundary has been reached.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {

    BreakIterator iterator = BreakIterator.getWordInstance(Locale.CANADA);
    iterator.setText("a sentence");
    for (int index = iterator.first(); index != BreakIterator.DONE; index = iterator.next()) {
        System.out.println(index);
    }//from   w w w.  j a  va2s.  c o  m
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    BreakIterator iterator = BreakIterator.getCharacterInstance(Locale.CANADA);
    iterator.setText("aString");
    for (int index = iterator.first(); index != BreakIterator.DONE; index = iterator.next()) {
        System.out.println(index);
    }//from   w w w  .  j  a  v  a 2  s . c o  m
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    BreakIterator iterator = BreakIterator.getLineInstance(Locale.CANADA);
    iterator.setText("line1\nline2");
    for (int index = iterator.first(); index != BreakIterator.DONE; index = iterator.next()) {
        System.out.println(index);
    }//from   ww  w .j av  a 2 s.  co m
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    BreakIterator iterator = BreakIterator.getSentenceInstance(Locale.CANADA);
    iterator.setText("this is a test.");
    for (int index = iterator.first(); index != BreakIterator.DONE; index = iterator.next()) {
        System.out.println(index);
    }/*from  ww w .  j a  v  a 2s . c o  m*/
}

From source file:HangulTextBoundaryDetection.java

static void printBoundaries(String source, BreakIterator bi) {
    bi.setText(source);/*  w w  w . j a  v  a 2 s. co m*/
    int boundary = bi.first();

    while (boundary != BreakIterator.DONE) {
        System.out.print(boundary + " ");
        boundary = bi.next();
    }
}

From source file:Main.java

public static String wordSpace(String source) {
    BreakIterator boundary = BreakIterator.getLineInstance(new Locale("th"));
    boundary.setText(source);// w w w .j  a v  a 2 s. com
    int start = boundary.first();
    StringBuffer wordbuffer = new StringBuffer("");
    for (int end = boundary.next(); end != BreakIterator.DONE; start = end, end = boundary.next()) {
        wordbuffer.append(source.substring(start, end) + "\u200b");
        //           wordbuffer.append(source.substring(start, end)+"\ufeff");
    }
    return wordbuffer.toString();
}

From source file:Main.java

static void extractWords(String target, BreakIterator wordIterator) {
    wordIterator.setText(target);/*from w w w . j  a v a  2 s.c  o  m*/
    int start = wordIterator.first();
    int end = wordIterator.next();

    while (end != BreakIterator.DONE) {
        String word = target.substring(start, end);
        if (Character.isLetterOrDigit(word.charAt(0))) {
            System.out.println(word);
        }
        start = end;
        end = wordIterator.next();
    }
}

From source file:Main.java

public TextBoundaryFrame() {
    getContentPane().add(new JScrollPane(outputText));

    Locale currentLocale = Locale.getDefault();
    BreakIterator currentBreakIterator = BreakIterator.getLineInstance(currentLocale);

    String text = "The quick, brown fox jump-ed\n" + "over the lazy \"dog.\" And then...what happened?";
    currentBreakIterator.setText(text);//from ww  w.  j av  a  2s . c  o m
    outputText.setText("");

    int from = currentBreakIterator.first();
    int to;
    while ((to = currentBreakIterator.next()) != BreakIterator.DONE) {
        outputText.append(text.substring(from, to) + "|");
        from = to;
    }
    outputText.append(text.substring(from));
}

From source file:Main.java

public TextBoundaryFrame() {
    getContentPane().add(new JScrollPane(outputText));

    Locale currentLocale = Locale.getDefault();
    BreakIterator currentBreakIterator = BreakIterator.getWordInstance(currentLocale);

    String text = "The quick, brown fox jump-ed\n" + "over the lazy \"dog.\" And then...what happened?";
    currentBreakIterator.setText(text);/*from www .  j  a  v a2 s. c o  m*/
    outputText.setText("");

    int from = currentBreakIterator.first();
    int to;
    while ((to = currentBreakIterator.next()) != BreakIterator.DONE) {
        outputText.append(text.substring(from, to) + "|");
        from = to;
    }
    outputText.append(text.substring(from));
}

From source file:Main.java

public TextBoundaryFrame() {
    getContentPane().add(new JScrollPane(outputText));

    Locale currentLocale = Locale.getDefault();
    BreakIterator currentBreakIterator = BreakIterator.getSentenceInstance(currentLocale);

    String text = "The quick, brown fox jump-ed\n" + "over the lazy \"dog.\" And then...what happened?";
    currentBreakIterator.setText(text);/*  w  w  w . j  a  va  2s. c om*/
    outputText.setText("");

    int from = currentBreakIterator.first();
    int to;
    while ((to = currentBreakIterator.next()) != BreakIterator.DONE) {
        outputText.append(text.substring(from, to) + "|");
        from = to;
    }
    outputText.append(text.substring(from));
}