Java Code Examples for java.text.RuleBasedCollator#getRules()
The following examples show how to use
java.text.RuleBasedCollator#getRules() .
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: SurrogatesTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private Collator getCollator() { RuleBasedCollator base = (RuleBasedCollator)Collator.getInstance(); String rule = base.getRules(); try { return new RuleBasedCollator(rule + "&B < \ud800\udc01 < \ud800\udc00" + ", \ud800\udc02, \ud800\udc03" + "; \ud800\udc04, \ud800\udc05" + "< \ud800\udc06 < \ud800\udc07" + "&FE < \ud800\udc08" + "&PE, \ud800\udc09" + "&Z < \ud800\udc0a < \ud800\udc0b < \ud800\udc0c" + "&\ud800\udc0a < x, X" + "&A < \ud800\udc04\ud800\udc05"); } catch (Exception e) { errln("Failed to create new RulebasedCollator object"); return null; } }
Example 2
Source File: SurrogatesTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private Collator getCollator() { RuleBasedCollator base = (RuleBasedCollator)Collator.getInstance(); String rule = base.getRules(); try { return new RuleBasedCollator(rule + "&B < \ud800\udc01 < \ud800\udc00" + ", \ud800\udc02, \ud800\udc03" + "; \ud800\udc04, \ud800\udc05" + "< \ud800\udc06 < \ud800\udc07" + "&FE < \ud800\udc08" + "&PE, \ud800\udc09" + "&Z < \ud800\udc0a < \ud800\udc0b < \ud800\udc0c" + "&\ud800\udc0a < x, X" + "&A < \ud800\udc04\ud800\udc05"); } catch (Exception e) { errln("Failed to create new RulebasedCollator object"); return null; } }
Example 3
Source File: SurrogatesTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private Collator getCollator() { RuleBasedCollator base = (RuleBasedCollator)Collator.getInstance(); String rule = base.getRules(); try { return new RuleBasedCollator(rule + "&B < \ud800\udc01 < \ud800\udc00" + ", \ud800\udc02, \ud800\udc03" + "; \ud800\udc04, \ud800\udc05" + "< \ud800\udc06 < \ud800\udc07" + "&FE < \ud800\udc08" + "&PE, \ud800\udc09" + "&Z < \ud800\udc0a < \ud800\udc0b < \ud800\udc0c" + "&\ud800\udc0a < x, X" + "&A < \ud800\udc04\ud800\udc05"); } catch (Exception e) { errln("Failed to create new RulebasedCollator object"); return null; } }
Example 4
Source File: SurrogatesTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private Collator getCollator() { RuleBasedCollator base = (RuleBasedCollator)Collator.getInstance(); String rule = base.getRules(); try { return new RuleBasedCollator(rule + "&B < \ud800\udc01 < \ud800\udc00" + ", \ud800\udc02, \ud800\udc03" + "; \ud800\udc04, \ud800\udc05" + "< \ud800\udc06 < \ud800\udc07" + "&FE < \ud800\udc08" + "&PE, \ud800\udc09" + "&Z < \ud800\udc0a < \ud800\udc0b < \ud800\udc0c" + "&\ud800\udc0a < x, X" + "&A < \ud800\udc04\ud800\udc05"); } catch (Exception e) { errln("Failed to create new RulebasedCollator object"); return null; } }
Example 5
Source File: SurrogatesTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private Collator getCollator() { RuleBasedCollator base = (RuleBasedCollator)Collator.getInstance(); String rule = base.getRules(); try { return new RuleBasedCollator(rule + "&B < \ud800\udc01 < \ud800\udc00" + ", \ud800\udc02, \ud800\udc03" + "; \ud800\udc04, \ud800\udc05" + "< \ud800\udc06 < \ud800\udc07" + "&FE < \ud800\udc08" + "&PE, \ud800\udc09" + "&Z < \ud800\udc0a < \ud800\udc0b < \ud800\udc0c" + "&\ud800\udc0a < x, X" + "&A < \ud800\udc04\ud800\udc05"); } catch (Exception e) { errln("Failed to create new RulebasedCollator object"); return null; } }
Example 6
Source File: CollationTest2.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * RESOLVE - unfinished LIKE test with dataset of all unicode characters **/ private static final void printRuleBasedCollator() { // get en_US Collator rules RuleBasedCollator en_USCollator = (RuleBasedCollator)Collator.getInstance(Locale.US); String en_rules = en_USCollator.getRules(); System.out.println("ENGLISH RULES: " + en_rules); System.out.println("ENGLISH RULES: " + formatString(en_rules, true)); System.out.println("ENGLISH RULES: " + formatString(en_rules, false)); }
Example 7
Source File: TestCollationField.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * 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 , a\u0308 & AE , A\u0308"+ "& oe , o\u0308 & OE , O\u0308"+ "& ue , u\u0308 & UE , u\u0308"; 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(); }
Example 8
Source File: TestCollationFieldDocValues.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * 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 , a\u0308 & AE , A\u0308"+ "& oe , o\u0308 & OE , O\u0308"+ "& ue , u\u0308 & UE , u\u0308"; 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(); }
Example 9
Source File: CollationTest2.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * RESOLVE - unfinished LIKE test with dataset of all unicode characters **/ private static final void printRuleBasedCollator() { // get en_US Collator rules RuleBasedCollator en_USCollator = (RuleBasedCollator)Collator.getInstance(Locale.US); String en_rules = en_USCollator.getRules(); System.out.println("ENGLISH RULES: " + en_rules); System.out.println("ENGLISH RULES: " + formatString(en_rules, true)); System.out.println("ENGLISH RULES: " + formatString(en_rules, false)); }
Example 10
Source File: ImportFileScanner.java From proarc with GNU General Public License v3.0 | 5 votes |
private static RuleBasedCollator createCzechCollator() { RuleBasedCollator czechDefault = (RuleBasedCollator) Collator.getInstance(new Locale("cs")); try { return new RuleBasedCollator( // Space before 0 results to "on", "on board", "online" // instead of "on", "online", "on board" // '&' to reset definition does not work for space "'\u0020' < 0" + czechDefault.getRules()); } catch (ParseException ex) { throw new IllegalStateException(ex); } }
Example 11
Source File: CollationTest2.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
/** * RESOLVE - unfinished LIKE test with dataset of all unicode characters **/ private static final void printRuleBasedCollator() { // get en_US Collator rules RuleBasedCollator en_USCollator = (RuleBasedCollator)Collator.getInstance(Locale.US); String en_rules = en_USCollator.getRules(); System.out.println("ENGLISH RULES: " + en_rules); System.out.println("ENGLISH RULES: " + formatString(en_rules, true)); System.out.println("ENGLISH RULES: " + formatString(en_rules, false)); }
Example 12
Source File: SiteComparator.java From sakai with Educational Community License v2.0 | 4 votes |
public SiteComparator(String criterion, String asc, Locale locale) { this(criterion, asc); m_loc = locale; try { RuleBasedCollator defaultCollator = (RuleBasedCollator) Collator.getInstance(locale); String rules = defaultCollator.getRules(); localeCollator = new RuleBasedCollator(rules.replaceAll("<'\u005f'", "<' '<'\u005f'")); localeCollator.setStrength(Collator.TERTIARY); } catch (Exception e) { log.warn("SiteComparator failed to create RuleBasedCollator for locale " + locale.toString(), e); localeCollator = null; } }
Example 13
Source File: SiteComparator.java From sakai with Educational Community License v2.0 | 4 votes |
public SiteComparator(String criterion, String asc, Locale locale) { this(criterion, asc); m_loc = locale; try { RuleBasedCollator defaultCollator = (RuleBasedCollator) Collator.getInstance(locale); String rules = defaultCollator.getRules(); localeCollator = new RuleBasedCollator(rules.replaceAll("<'\u005f'", "<' '<'\u005f'")); localeCollator.setStrength(Collator.TERTIARY); } catch (Exception e) { log.warn("SiteComparator failed to create RuleBasedCollator for locale " + locale.toString(), e); localeCollator = null; } }