use of java.text.RuleBasedCollator in project robovm by robovm.
the class CollatorTest method test_Harmony_1352.
public void test_Harmony_1352() throws Exception {
// of an earlier failure.
try {
new RuleBasedCollator("< a< b< c< d").getCollationElementIterator((CharacterIterator) null);
fail("NullPointerException expected");
} catch (NullPointerException expected) {
}
}
use of java.text.RuleBasedCollator in project robovm by robovm.
the class CollatorTest method assertGetCollationElementIteratorCharacterIterator.
private void assertGetCollationElementIteratorCharacterIterator(Locale l, String s, Integer... offsets) {
RuleBasedCollator coll = (RuleBasedCollator) Collator.getInstance(l);
CharacterIterator it = new StringCharacterIterator(s);
assertCollationElementIterator(coll.getCollationElementIterator(it), offsets);
}
use of java.text.RuleBasedCollator in project robovm by robovm.
the class CollatorTest method testEqualsObject.
public void testEqualsObject() throws ParseException {
String rule = "< a < b < c < d < e";
RuleBasedCollator coll = new RuleBasedCollator(rule);
assertEquals(Collator.TERTIARY, coll.getStrength());
assertEquals(Collator.NO_DECOMPOSITION, coll.getDecomposition());
RuleBasedCollator other = new RuleBasedCollator(rule);
assertTrue(coll.equals(other));
coll.setStrength(Collator.PRIMARY);
assertFalse(coll.equals(other));
coll.setStrength(Collator.TERTIARY);
coll.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
// See comment above.
other.setDecomposition(Collator.NO_DECOMPOSITION);
assertFalse(coll.equals(other));
}
use of java.text.RuleBasedCollator in project lucene-solr by apache.
the class TestCollationField method setupSolrHome.
/**
* Ugly: but what to do? We want to test custom sort, which reads rules in as a resource.
* These are largish files, and jvm-specific (as our documentation says, you should always
* look out for jvm differences with collation).
* So it's preferable to create this file on-the-fly.
*/
public static String setupSolrHome() throws Exception {
// make a solr home underneath the test's TEMP_DIR
File tmpFile = createTempDir("collation1").toFile();
// make data and conf dirs
new File(tmpFile, "data").mkdir();
File confDir = new File(tmpFile + "/collection1", "conf");
confDir.mkdirs();
// copy over configuration files
FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-basic.xml"), new File(confDir, "solrconfig.xml"));
FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig.snippet.randomindexconfig.xml"), new File(confDir, "solrconfig.snippet.randomindexconfig.xml"));
FileUtils.copyFile(getFile("solr/collection1/conf/schema-collate.xml"), new File(confDir, "schema.xml"));
// generate custom collation rules (DIN 5007-2), saving to customrules.dat
RuleBasedCollator baseCollator = (RuleBasedCollator) Collator.getInstance(new Locale("de", "DE"));
String DIN5007_2_tailorings = "& ae , ä & AE , Ä" + "& oe , ö & OE , Ö" + "& ue , ü & UE , ü";
RuleBasedCollator tailoredCollator = new RuleBasedCollator(baseCollator.getRules() + DIN5007_2_tailorings);
String tailoredRules = tailoredCollator.getRules();
FileOutputStream os = new FileOutputStream(new File(confDir, "customrules.dat"));
IOUtils.write(tailoredRules, os, "UTF-8");
os.close();
return tmpFile.getAbsolutePath();
}
use of java.text.RuleBasedCollator in project lucene-solr by apache.
the class TestCollationFieldDocValues method setupSolrHome.
/**
* Ugly: but what to do? We want to test custom sort, which reads rules in as a resource.
* These are largish files, and jvm-specific (as our documentation says, you should always
* look out for jvm differences with collation).
* So it's preferable to create this file on-the-fly.
*/
public static String setupSolrHome() throws Exception {
// make a solr home underneath the test's TEMP_DIR
File tmpFile = createTempDir("collation1").toFile();
// make data and conf dirs
new File(tmpFile, "data").mkdir();
File confDir = new File(tmpFile + "/collection1", "conf");
confDir.mkdirs();
// copy over configuration files
FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-basic.xml"), new File(confDir, "solrconfig.xml"));
FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig.snippet.randomindexconfig.xml"), new File(confDir, "solrconfig.snippet.randomindexconfig.xml"));
FileUtils.copyFile(getFile("solr/collection1/conf/schema-collate-dv.xml"), new File(confDir, "schema.xml"));
// generate custom collation rules (DIN 5007-2), saving to customrules.dat
RuleBasedCollator baseCollator = (RuleBasedCollator) Collator.getInstance(new Locale("de", "DE"));
String DIN5007_2_tailorings = "& ae , ä & AE , Ä" + "& oe , ö & OE , Ö" + "& ue , ü & UE , ü";
RuleBasedCollator tailoredCollator = new RuleBasedCollator(baseCollator.getRules() + DIN5007_2_tailorings);
String tailoredRules = tailoredCollator.getRules();
FileOutputStream os = new FileOutputStream(new File(confDir, "customrules.dat"));
IOUtils.write(tailoredRules, os, "UTF-8");
os.close();
return tmpFile.getAbsolutePath();
}
Aggregations