本文整理匯總了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;
}
}
示例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));
}
示例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);
}
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
}