本文整理汇总了Java中java.text.CollationElementIterator类的典型用法代码示例。如果您正苦于以下问题:Java CollationElementIterator类的具体用法?Java CollationElementIterator怎么用?Java CollationElementIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CollationElementIterator类属于java.text包,在下文中一共展示了CollationElementIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPrevious
import java.text.CollationElementIterator; //导入依赖的package包/类
public void testPrevious() {
RuleBasedCollator coll = (RuleBasedCollator) Collator.getInstance(Locale.US);
String text = "abc";
CollationElementIterator iterator = coll
.getCollationElementIterator(text);
int[] orders = new int[text.length()];
int order = iterator.next();
int i = 0;
while (order != CollationElementIterator.NULLORDER) {
orders[i++] = order;
order = iterator.next();
}
int offset = iterator.getOffset();
assertEquals(text.length(), offset);
order = iterator.previous();
while (order != CollationElementIterator.NULLORDER) {
assertEquals(orders[--i], order);
order = iterator.previous();
}
assertEquals(0, iterator.getOffset());
}
示例2: testNext
import java.text.CollationElementIterator; //导入依赖的package包/类
public void testNext() {
String text = "abc";
CollationElementIterator iterator = coll
.getCollationElementIterator(text);
int[] orders = new int[text.length()];
int order = iterator.next();
int i = 0;
while (order != CollationElementIterator.NULLORDER) {
orders[i++] = order;
order = iterator.next();
}
int offset = iterator.getOffset();
assertEquals(text.length(), offset);
order = iterator.previous();
while (order != CollationElementIterator.NULLORDER) {
assertEquals(orders[--i], order);
order = iterator.previous();
}
assertEquals(0, iterator.getOffset());
}
示例3: testReset
import java.text.CollationElementIterator; //导入依赖的package包/类
public void testReset() {
String text = "abc";
CollationElementIterator iterator = coll
.getCollationElementIterator(text);
int[] orders = new int[text.length()];
int order = iterator.next();
int i = 0;
while (order != CollationElementIterator.NULLORDER) {
orders[i++] = order;
order = iterator.next();
}
int offset = iterator.getOffset();
assertEquals(text.length(), offset);
iterator.reset();
assertEquals(0, iterator.getOffset());
}
示例4: testTertiaryOrder
import java.text.CollationElementIterator; //导入依赖的package包/类
public void testTertiaryOrder() {
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
.getInstance(new Locale("fr", "FR"));
String text = "abAB";
CollationElementIterator iterator = rbColl
.getCollationElementIterator(text);
int order = iterator.next();
int tOrder1 = CollationElementIterator.tertiaryOrder(order);
order = iterator.next();
int tOrder2 = CollationElementIterator.tertiaryOrder(order);
assertEquals(tOrder1, tOrder2);
order = iterator.next();
tOrder1 = CollationElementIterator.tertiaryOrder(order);
order = iterator.next();
tOrder2 = CollationElementIterator.tertiaryOrder(order);
assertEquals(tOrder1, tOrder2);
}
示例5: assertCollationElementIterator
import java.text.CollationElementIterator; //导入依赖的package包/类
private void assertCollationElementIterator(CollationElementIterator it, Integer... offsets) {
for (int offset : offsets) {
assertEquals(offset, it.getOffset());
it.next();
}
assertEquals(CollationElementIterator.NULLORDER, it.next());
}
示例6: testGetOffset
import java.text.CollationElementIterator; //导入依赖的package包/类
public void testGetOffset() {
String text = "abc";
CollationElementIterator iterator = coll
.getCollationElementIterator(text);
int[] offsets = { 0, 1, 2, 3 };
int offset = iterator.getOffset();
int i = 0;
assertEquals(offsets[i++], offset);
while (offset != text.length()) {
iterator.next();
offset = iterator.getOffset();
assertEquals(offsets[i++], offset);
}
}
示例7: testGetMaxExpansion
import java.text.CollationElementIterator; //导入依赖的package包/类
public void testGetMaxExpansion() {
String text = "cha";
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
.getInstance(new Locale("es", "", "TRADITIONAL"));
CollationElementIterator iterator = rbColl
.getCollationElementIterator(text);
int order = iterator.next();
while (order != CollationElementIterator.NULLORDER) {
assertEquals(1, iterator.getMaxExpansion(order));
order = iterator.next();
}
}
示例8: testPrimaryOrder
import java.text.CollationElementIterator; //导入依赖的package包/类
public void testPrimaryOrder() {
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
.getInstance(new Locale("de", "DE"));
String text = "\u00e6";
CollationElementIterator iterator = rbColl
.getCollationElementIterator(text);
int order = iterator.next();
int pOrder = CollationElementIterator.primaryOrder(order);
CollationElementIterator iterator2 = rbColl
.getCollationElementIterator("ae");
int order2 = iterator2.next();
int pOrder2 = CollationElementIterator.primaryOrder(order2);
assertEquals(pOrder, pOrder2);
}
示例9: testSecondaryOrder
import java.text.CollationElementIterator; //导入依赖的package包/类
public void testSecondaryOrder() {
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
.getInstance(new Locale("fr", "FR"));
String text = "a\u00e0";
CollationElementIterator iterator = rbColl
.getCollationElementIterator(text);
int order = iterator.next();
int sOrder1 = CollationElementIterator.secondaryOrder(order);
order = iterator.next();
int sOrder2 = CollationElementIterator.secondaryOrder(order);
assertEquals(sOrder1, sOrder2);
}
示例10: testSetOffset
import java.text.CollationElementIterator; //导入依赖的package包/类
public void testSetOffset() {
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
.getInstance(new Locale("es", "", "TRADITIONAL"));
String text = "cha";
CollationElementIterator iterator = rbColl
.getCollationElementIterator(text);
iterator.setOffset(1);
assertEquals(1, iterator.getOffset());
}
示例11: testSetTextString
import java.text.CollationElementIterator; //导入依赖的package包/类
public void testSetTextString() {
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
.getInstance(new Locale("es", "", "TRADITIONAL"));
String text = "caa";
CollationElementIterator iterator = rbColl
.getCollationElementIterator(text);
iterator.setOffset(1);
assertEquals(1, iterator.getOffset());
iterator.setText("cha");
iterator.setOffset(1);
assertEquals(1, iterator.getOffset());
}
示例12: testSetTextCharacterIterator
import java.text.CollationElementIterator; //导入依赖的package包/类
public void testSetTextCharacterIterator() {
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
.getInstance(new Locale("es", "", "TRADITIONAL"));
String text = "caa";
CollationElementIterator iterator = rbColl
.getCollationElementIterator(text);
iterator.setOffset(1);
assertEquals(1, iterator.getOffset());
iterator.setText(new StringCharacterIterator("cha"));
iterator.setOffset(1);
assertEquals(1, iterator.getOffset());
}
示例13: testSetOffset
import java.text.CollationElementIterator; //导入依赖的package包/类
public void testSetOffset() {
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
.getInstance(new Locale("es", "", "TRADITIONAL"));
String text = "cha";
CollationElementIterator iterator = rbColl
.getCollationElementIterator(text);
iterator.setOffset(1);
assertEquals(0, iterator.getOffset());
}
示例14: testSetTextString
import java.text.CollationElementIterator; //导入依赖的package包/类
public void testSetTextString() {
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
.getInstance(new Locale("es", "", "TRADITIONAL"));
String text = "caa";
CollationElementIterator iterator = rbColl
.getCollationElementIterator(text);
iterator.setOffset(1);
assertEquals(1, iterator.getOffset());
iterator.setText("cha");
iterator.setOffset(1);
assertEquals(0, iterator.getOffset());
}
示例15: testSetTextCharacterIterator
import java.text.CollationElementIterator; //导入依赖的package包/类
public void testSetTextCharacterIterator() {
RuleBasedCollator rbColl = (RuleBasedCollator) Collator
.getInstance(new Locale("es", "", "TRADITIONAL"));
String text = "caa";
CollationElementIterator iterator = rbColl
.getCollationElementIterator(text);
iterator.setOffset(1);
assertEquals(1, iterator.getOffset());
iterator.setText(new StringCharacterIterator("cha"));
iterator.setOffset(1);
assertEquals(0, iterator.getOffset());
}