use of java.text.BreakIterator in project elasticsearch by elastic.
the class CustomSeparatorBreakIteratorTests method testFirstPosition.
/** the current position must be ignored, initial position is always first() */
public void testFirstPosition() throws Exception {
BreakIterator expected = BreakIterator.getSentenceInstance(Locale.ROOT);
BreakIterator actual = new CustomSeparatorBreakIterator(randomSeparator());
assertSameBreaks("000ab000", 3, 2, 4, expected, actual);
}
use of java.text.BreakIterator in project elasticsearch by elastic.
the class CustomSeparatorBreakIteratorTests method testSliceStart.
public void testSliceStart() throws Exception {
BreakIterator expected = BreakIterator.getSentenceInstance(Locale.ROOT);
BreakIterator actual = new CustomSeparatorBreakIterator(randomSeparator());
assertSameBreaks("000a", 3, 1, expected, actual);
assertSameBreaks("000ab", 3, 2, expected, actual);
assertSameBreaks("000abc", 3, 3, expected, actual);
assertSameBreaks("000", 3, 0, expected, actual);
}
use of java.text.BreakIterator in project elasticsearch by elastic.
the class CustomSeparatorBreakIteratorTests method testSliceEnd.
public void testSliceEnd() throws Exception {
BreakIterator expected = BreakIterator.getSentenceInstance(Locale.ROOT);
BreakIterator actual = new CustomSeparatorBreakIterator(randomSeparator());
assertSameBreaks("a000", 0, 1, expected, actual);
assertSameBreaks("ab000", 0, 1, expected, actual);
assertSameBreaks("abc000", 0, 1, expected, actual);
assertSameBreaks("000", 0, 0, expected, actual);
}
use of java.text.BreakIterator in project j2objc by google.
the class JavadocGenerator method printDocComment.
private void printDocComment(Javadoc javadoc) {
if (javadoc != null) {
printIndent();
// Use HeaderDoc doc-comment start, which is compatible with Xcode Quick Help and Doxygen.
println("/*!");
List<TagElement> tags = javadoc.getTags();
for (TagElement tag : tags) {
if (tag.getTagName() == null) {
// Description section.
String description = printTagFragments(tag.getFragments());
// Extract first sentence from description.
BreakIterator iterator = BreakIterator.getSentenceInstance(Locale.US);
iterator.setText(description.toString());
int start = iterator.first();
int end = iterator.next();
if (end != BreakIterator.DONE) {
// Print brief tag first, since Quick Help shows it first. This makes the
// generated source easier to review.
printDocLine(String.format("@brief %s", description.substring(start, end)).trim());
String remainder = description.substring(end);
if (!remainder.isEmpty()) {
printDocLine(remainder);
}
} else {
printDocLine(description);
}
} else {
String doc = printTag(tag);
if (!doc.isEmpty()) {
printDocLine(doc);
}
}
}
printIndent();
println(" */");
}
}
use of java.text.BreakIterator in project robovm by robovm.
the class BreakIteratorTest method testConcurrentBreakIteratorAccess.
// http://code.google.com/p/android/issues/detail?id=41143
// This code is inherently unsafe and crazy;
// we're just trying to provoke native crashes!
public void testConcurrentBreakIteratorAccess() throws Exception {
final BreakIterator it = BreakIterator.getCharacterInstance();
ArrayList<Thread> threads = new ArrayList<Thread>();
for (int i = 0; i < 10; ++i) {
Thread t = new Thread(new Runnable() {
public void run() {
for (int i = 0; i < 4096; ++i) {
it.setText("some example text");
for (int index = it.first(); index != BreakIterator.DONE; index = it.next()) {
}
}
}
});
threads.add(t);
}
for (Thread t : threads) {
t.start();
}
for (Thread t : threads) {
t.join();
}
}
Aggregations