Java Code Examples for java.text.BreakIterator#clone()
The following examples show how to use
java.text.BreakIterator#clone() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BreakIteratorTest.java From j2objc with Apache License 2.0 | 6 votes |
public void testWordBoundaries() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < 1024; ++i) { if (i > 0) { sb.append(' '); } sb.append("12345"); } String s = sb.toString(); BreakIterator it = BreakIterator.getWordInstance(Locale.US); it.setText(s); // Check we're not leaking global references. 2048 would bust the VM's hard-coded limit. for (int i = 0; i < 2048; ++i) { it.setText(s); } BreakIterator clone = (BreakIterator) it.clone(); assertExpectedWordBoundaries(it, s); assertExpectedWordBoundaries(clone, s); }
Example 2
Source File: BreakIteratorTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private void doMultipleSelectionTest(BreakIterator iterator, String testText) { logln("Multiple selection test..."); BreakIterator testIterator = (BreakIterator)iterator.clone(); int offset = iterator.first(); int testOffset; int count = 0; do { testOffset = testIterator.first(); testOffset = testIterator.next(count); logln("next(" + count + ") -> " + testOffset); if (offset != testOffset) errln("next(n) and next() not returning consistent results: for step " + count + ", next(n) returned " + testOffset + " and next() had " + offset); if (offset != BreakIterator.DONE) { count++; offset = iterator.next(); } } while (offset != BreakIterator.DONE); // now do it backwards... offset = iterator.last(); count = 0; do { testOffset = testIterator.last(); testOffset = testIterator.next(count); logln("next(" + count + ") -> " + testOffset); if (offset != testOffset) errln("next(n) and next() not returning consistent results: for step " + count + ", next(n) returned " + testOffset + " and next() had " + offset); if (offset != BreakIterator.DONE) { count--; offset = iterator.previous(); } } while (offset != BreakIterator.DONE); }
Example 3
Source File: BreakIteratorTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void doMultipleSelectionTest(BreakIterator iterator, String testText) { logln("Multiple selection test..."); BreakIterator testIterator = (BreakIterator)iterator.clone(); int offset = iterator.first(); int testOffset; int count = 0; do { testOffset = testIterator.first(); testOffset = testIterator.next(count); logln("next(" + count + ") -> " + testOffset); if (offset != testOffset) errln("next(n) and next() not returning consistent results: for step " + count + ", next(n) returned " + testOffset + " and next() had " + offset); if (offset != BreakIterator.DONE) { count++; offset = iterator.next(); } } while (offset != BreakIterator.DONE); // now do it backwards... offset = iterator.last(); count = 0; do { testOffset = testIterator.last(); testOffset = testIterator.next(count); logln("next(" + count + ") -> " + testOffset); if (offset != testOffset) errln("next(n) and next() not returning consistent results: for step " + count + ", next(n) returned " + testOffset + " and next() had " + offset); if (offset != BreakIterator.DONE) { count--; offset = iterator.previous(); } } while (offset != BreakIterator.DONE); }
Example 4
Source File: BreakIteratorTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void doMultipleSelectionTest(BreakIterator iterator, String testText) { logln("Multiple selection test..."); BreakIterator testIterator = (BreakIterator)iterator.clone(); int offset = iterator.first(); int testOffset; int count = 0; do { testOffset = testIterator.first(); testOffset = testIterator.next(count); logln("next(" + count + ") -> " + testOffset); if (offset != testOffset) errln("next(n) and next() not returning consistent results: for step " + count + ", next(n) returned " + testOffset + " and next() had " + offset); if (offset != BreakIterator.DONE) { count++; offset = iterator.next(); } } while (offset != BreakIterator.DONE); // now do it backwards... offset = iterator.last(); count = 0; do { testOffset = testIterator.last(); testOffset = testIterator.next(count); logln("next(" + count + ") -> " + testOffset); if (offset != testOffset) errln("next(n) and next() not returning consistent results: for step " + count + ", next(n) returned " + testOffset + " and next() had " + offset); if (offset != BreakIterator.DONE) { count--; offset = iterator.previous(); } } while (offset != BreakIterator.DONE); }
Example 5
Source File: BreakIteratorTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void doMultipleSelectionTest(BreakIterator iterator, String testText) { logln("Multiple selection test..."); BreakIterator testIterator = (BreakIterator)iterator.clone(); int offset = iterator.first(); int testOffset; int count = 0; do { testOffset = testIterator.first(); testOffset = testIterator.next(count); logln("next(" + count + ") -> " + testOffset); if (offset != testOffset) errln("next(n) and next() not returning consistent results: for step " + count + ", next(n) returned " + testOffset + " and next() had " + offset); if (offset != BreakIterator.DONE) { count++; offset = iterator.next(); } } while (offset != BreakIterator.DONE); // now do it backwards... offset = iterator.last(); count = 0; do { testOffset = testIterator.last(); testOffset = testIterator.next(count); logln("next(" + count + ") -> " + testOffset); if (offset != testOffset) errln("next(n) and next() not returning consistent results: for step " + count + ", next(n) returned " + testOffset + " and next() had " + offset); if (offset != BreakIterator.DONE) { count--; offset = iterator.previous(); } } while (offset != BreakIterator.DONE); }
Example 6
Source File: BreakIteratorTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private void doMultipleSelectionTest(BreakIterator iterator, String testText) { logln("Multiple selection test..."); BreakIterator testIterator = (BreakIterator)iterator.clone(); int offset = iterator.first(); int testOffset; int count = 0; do { testOffset = testIterator.first(); testOffset = testIterator.next(count); logln("next(" + count + ") -> " + testOffset); if (offset != testOffset) errln("next(n) and next() not returning consistent results: for step " + count + ", next(n) returned " + testOffset + " and next() had " + offset); if (offset != BreakIterator.DONE) { count++; offset = iterator.next(); } } while (offset != BreakIterator.DONE); // now do it backwards... offset = iterator.last(); count = 0; do { testOffset = testIterator.last(); testOffset = testIterator.next(count); logln("next(" + count + ") -> " + testOffset); if (offset != testOffset) errln("next(n) and next() not returning consistent results: for step " + count + ", next(n) returned " + testOffset + " and next() had " + offset); if (offset != BreakIterator.DONE) { count--; offset = iterator.previous(); } } while (offset != BreakIterator.DONE); }
Example 7
Source File: IBreakIterator.java From FxDock with Apache License 2.0 | 5 votes |
/** * wraps a standard java.util.BreakIterator instance. * it is recommended to use com.ibm.icu.text.BreakIterator instead because * the stock java one is not complete (emoji!) */ public static IBreakIterator wrap(BreakIterator br) { return new IBreakIterator() { public void setText(String text) { br.setText(text); } public int first() { return br.first(); } public int next() { int rv = br.next(); if(rv == BreakIterator.DONE) { return DONE; } return rv; } public IBreakIterator copy() { return (IBreakIterator)br.clone(); } }; }