當前位置: 首頁>>代碼示例>>Java>>正文


Java RuleBasedCollator.getRules方法代碼示例

本文整理匯總了Java中java.text.RuleBasedCollator.getRules方法的典型用法代碼示例。如果您正苦於以下問題:Java RuleBasedCollator.getRules方法的具體用法?Java RuleBasedCollator.getRules怎麽用?Java RuleBasedCollator.getRules使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.text.RuleBasedCollator的用法示例。


在下文中一共展示了RuleBasedCollator.getRules方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCollator

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
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;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:SurrogatesTest.java

示例2: printRuleBasedCollator

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
/**
 * 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));
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:15,代碼來源:CollationTest2.java

示例3: createCzechCollator

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:proarc,項目名稱:proarc,代碼行數:14,代碼來源:ImportFileScanner.java

示例4: testCustomRules

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
public void testCustomRules() throws Exception {
  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();
  //
  // at this point, you would save these tailoredRules to a file, 
  // and use the custom parameter.
  //
  String germanUmlaut = "Töne";
  String germanOE = "Toene";
  Map<String,String> args = new HashMap<>();
  args.put("custom", "rules.txt");
  args.put("strength", "primary");
  CollationKeyFilterFactory factory = new CollationKeyFilterFactory(args);
  factory.inform(new StringMockResourceLoader(tailoredRules));
  TokenStream tsUmlaut = factory.create(
      new MockTokenizer(new StringReader(germanUmlaut), MockTokenizer.KEYWORD, false));
  TokenStream tsOE = factory.create(
      new MockTokenizer(new StringReader(germanOE), MockTokenizer.KEYWORD, false));

  assertCollatesToSame(tsUmlaut, tsOE);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:29,代碼來源:TestCollationKeyFilterFactory.java

示例5: setupSolrHome

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
/**
 * 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 its 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");
  tmpFile.delete();
  tmpFile.mkdir();
  
  // 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();
}
 
開發者ID:europeana,項目名稱:search,代碼行數:39,代碼來源:TestCollationField.java

示例6: setupSolrHome

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
/**
 * 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 its 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");
  tmpFile.delete();
  tmpFile.mkdir();
  
  // 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();
}
 
開發者ID:europeana,項目名稱:search,代碼行數:39,代碼來源:TestCollationFieldDocValues.java

示例7: testCustomRules

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
public void testCustomRules() throws Exception {
  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();
  //
  // at this point, you would save these tailoredRules to a file, 
  // and use the custom parameter.
  //
  String germanUmlaut = "Töne";
  String germanOE = "Toene";
  CollationKeyFilterFactory factory = new CollationKeyFilterFactory();
  Map<String,String> args = new HashMap<String,String>();
  args.put("custom", "rules.txt");
  args.put("strength", "primary");
  factory.init(args);
  factory.inform(new StringMockResourceLoader(tailoredRules));
  TokenStream tsUmlaut = factory.create(
      new MockTokenizer(new StringReader(germanUmlaut), MockTokenizer.KEYWORD, false));
  TokenStream tsOE = factory.create(
      new MockTokenizer(new StringReader(germanOE), MockTokenizer.KEYWORD, false));

  assertCollatesToSame(tsUmlaut, tsOE);
}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:30,代碼來源:TestCollationKeyFilterFactory.java

示例8: setupSolrHome

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
/**
 * 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 its 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 = _TestUtil.getTempDir("collation1");
  tmpFile.delete();
  tmpFile.mkdir();
  
  // 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/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();
}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:38,代碼來源:TestCollationField.java

示例9: testCustomRules

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
public void testCustomRules() throws Exception {
  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();
  //
  // at this point, you would save these tailoredRules to a file, 
  // and use the custom parameter.
  //
  String germanUmlaut = "Töne";
  String germanOE = "Toene";
  Map<String,String> args = new HashMap<String,String>();
  args.put("custom", "rules.txt");
  args.put("strength", "primary");
  CollationKeyFilterFactory factory = new CollationKeyFilterFactory(args);
  factory.inform(new StringMockResourceLoader(tailoredRules));
  TokenStream tsUmlaut = factory.create(
      new MockTokenizer(new StringReader(germanUmlaut), MockTokenizer.KEYWORD, false));
  TokenStream tsOE = factory.create(
      new MockTokenizer(new StringReader(germanOE), MockTokenizer.KEYWORD, false));

  assertCollatesToSame(tsUmlaut, tsOE);
}
 
開發者ID:jimaguere,項目名稱:Maskana-Gestor-de-Conocimiento,代碼行數:29,代碼來源:TestCollationKeyFilterFactory.java

示例10: SiteComparator

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
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;

               }

       }
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:25,代碼來源:SiteComparator.java


注:本文中的java.text.RuleBasedCollator.getRules方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。