当前位置: 首页>>代码示例>>Java>>正文


Java Collator.setStrength方法代码示例

本文整理汇总了Java中com.ibm.icu.text.Collator.setStrength方法的典型用法代码示例。如果您正苦于以下问题:Java Collator.setStrength方法的具体用法?Java Collator.setStrength怎么用?Java Collator.setStrength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ibm.icu.text.Collator的用法示例。


在下文中一共展示了Collator.setStrength方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCollator

import com.ibm.icu.text.Collator; //导入方法依赖的package包/类
private Collator createCollator(SeriesDefinition sd )
{
	// If sort strength is ASCII(-1), then just use default compare of
	// String class to do collator, so here just return null;
	if ( sd.isSetSortStrength( ) && sd.getSortStrength( ) < 0 )
	{
		return null;
	}
	Collator c = null;
	if ( sd.getSortLocale( ) != null )
	{
		c = Collator.getInstance( new ULocale( sd.getSortLocale( ) ) );
	}
	else {
		c = Collator.getInstance( );	
	}
	
	if ( sd.isSetSortStrength( ) )
	{
		c.setStrength( sd.getSortStrength( ) );
	}
	
	return c;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:25,代码来源:ResultSetWrapper.java

示例2: testThreadSafe

import com.ibm.icu.text.Collator; //导入方法依赖的package包/类
@Test
public void testThreadSafe() throws Exception {
    int iters = 20;
    for (int i = 0; i < iters; i++) {
        Locale locale = Locale.GERMAN;
        Collator collator = Collator.getInstance(locale);
        collator.setStrength(Collator.IDENTICAL);
        assertThreadSafe(new Random(), new ICUCollationKeyAnalyzer(collator));
    }
}
 
开发者ID:jprante,项目名称:elasticsearch-icu,代码行数:11,代码来源:IcuCollationKeyAnalyzerTests.java

示例3: testThreadSafe

import com.ibm.icu.text.Collator; //导入方法依赖的package包/类
public void testThreadSafe() throws Exception {
  int iters = 20 * RANDOM_MULTIPLIER;
  for (int i = 0; i < iters; i++) {
    Locale locale = Locale.GERMAN;
    Collator collator = Collator.getInstance(locale);
    collator.setStrength(Collator.IDENTICAL);
    assertThreadSafe(new ICUCollationKeyAnalyzer(TEST_VERSION_CURRENT, collator));
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:TestICUCollationKeyAnalyzer.java

示例4: testRanges

import com.ibm.icu.text.Collator; //导入方法依赖的package包/类
public void testRanges() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
  Document doc = new Document();
  Field field = newField("field", "", StringField.TYPE_STORED);
  Collator collator = Collator.getInstance(); // uses -Dtests.locale
  if (random().nextBoolean()) {
    collator.setStrength(Collator.PRIMARY);
  }
  ICUCollationDocValuesField collationField = new ICUCollationDocValuesField("collated", collator);
  doc.add(field);
  doc.add(collationField);
  
  int numDocs = atLeast(500);
  for (int i = 0; i < numDocs; i++) {
    String value = TestUtil.randomSimpleString(random());
    field.setStringValue(value);
    collationField.setStringValue(value);
    iw.addDocument(doc);
  }
  
  IndexReader ir = iw.getReader();
  iw.close();
  IndexSearcher is = newSearcher(ir);
  
  int numChecks = atLeast(100);
  for (int i = 0; i < numChecks; i++) {
    String start = TestUtil.randomSimpleString(random());
    String end = TestUtil.randomSimpleString(random());
    BytesRef lowerVal = new BytesRef(collator.getCollationKey(start).toByteArray());
    BytesRef upperVal = new BytesRef(collator.getCollationKey(end).toByteArray());
    Query query = new ConstantScoreQuery(FieldCacheRangeFilter.newBytesRefRange("collated", lowerVal, upperVal, true, true));
    doTestRanges(is, start, end, query, collator);
  }
  
  ir.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:39,代码来源:TestICUCollationDocValuesField.java

示例5: testRanges

import com.ibm.icu.text.Collator; //导入方法依赖的package包/类
public void testRanges() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
  Document doc = new Document();
  Field field = newField("field", "", StringField.TYPE_STORED);
  Collator collator = Collator.getInstance(); // uses -Dtests.locale
  if (random().nextBoolean()) {
    collator.setStrength(Collator.PRIMARY);
  }
  ICUCollationDocValuesField collationField = new ICUCollationDocValuesField("collated", collator);
  doc.add(field);
  doc.add(collationField);
  
  int numDocs = atLeast(500);
  for (int i = 0; i < numDocs; i++) {
    String value = _TestUtil.randomSimpleString(random());
    field.setStringValue(value);
    collationField.setStringValue(value);
    iw.addDocument(doc);
  }
  
  IndexReader ir = iw.getReader();
  iw.close();
  IndexSearcher is = newSearcher(ir);
  
  int numChecks = atLeast(100);
  for (int i = 0; i < numChecks; i++) {
    String start = _TestUtil.randomSimpleString(random());
    String end = _TestUtil.randomSimpleString(random());
    BytesRef lowerVal = new BytesRef(collator.getCollationKey(start).toByteArray());
    BytesRef upperVal = new BytesRef(collator.getCollationKey(end).toByteArray());
    Query query = new ConstantScoreQuery(FieldCacheRangeFilter.newBytesRefRange("collated", lowerVal, upperVal, true, true));
    doTestRanges(is, start, end, query, collator);
  }
  
  ir.close();
  dir.close();
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:39,代码来源:TestICUCollationDocValuesField.java

示例6: testThreadSafe

import com.ibm.icu.text.Collator; //导入方法依赖的package包/类
@Test
public void testThreadSafe() throws Exception {
    int iters = 20;
    for (int i = 0; i < iters; i++) {
        Locale locale = Locale.GERMAN;
        Collator collator = Collator.getInstance(locale);
        collator.setStrength(Collator.IDENTICAL);
        assertThreadSafe(new Random(), new IcuCollationKeyAnalyzer(collator));
    }
}
 
开发者ID:jprante,项目名称:elasticsearch-plugin-bundle,代码行数:11,代码来源:IcuCollationKeyAnalyzerTests.java

示例7: createCollator

import com.ibm.icu.text.Collator; //导入方法依赖的package包/类
private Collator createCollator( ISortDefinition sd )
{
	if ( sd.getSortStrength( ) != -1 )
	{
		Collator c = Collator.getInstance( sd.getSortLocale( ) == null
						? session.getEngineContext( ).getLocale( )
								: sd.getSortLocale( ) );
		c.setStrength( sd.getSortStrength( ) );
		return c;
	}
	return null;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:13,代码来源:QueryExecutor.java

示例8: getInstanceStrengthIdentical

import com.ibm.icu.text.Collator; //导入方法依赖的package包/类
static public Collator getInstanceStrengthIdentical(Locale l) {
    Collator c = Collator.getInstance(l);
    c.setStrength(Collator.IDENTICAL);
    return c;
}
 
开发者ID:rdoeffinger,项目名称:DictionaryPC,代码行数:6,代码来源:CollatorWrapper.java

示例9: makeCheck

import com.ibm.icu.text.Collator; //导入方法依赖的package包/类
@Override
protected void makeCheck(Placeholder target, ImmutableList<String> tokenizedInput, ULocale locale,
    String message) {
  if (tokenizedInput.size() < 2) {
    // Test passed. Nothing to sort.
    return;
  }

  int strength = Collator.SECONDARY;
  if (!target.isLenient()) {
    if (!target.isStrict()) {
      strength = Collator.TERTIARY;
    } else {
      strength = Collator.IDENTICAL;
    }
  }
  // Init collators.
  Collator collator = Collator.getInstance(locale);
  ImmutableList.Builder<Collator> collators = ImmutableList.builder();
  collators.add(collator);
  try {
    Collator collator2 = (RuleBasedCollator) collator.clone();
    collator2.setStrength(strength);
    collators.add(collator2);
    RuleBasedCollator collator3 = (RuleBasedCollator) collator.clone();
    collator3.setStrength(strength);
    collator3.setAlternateHandlingShifted(true);
    collators.add(collator3);
    RuleBasedCollator collator4 = (RuleBasedCollator) collator.clone();
    collator4.setStrength(strength);
    collator4.setNumericCollation(true);
    collators.add(collator4);
    RuleBasedCollator collator5 = (RuleBasedCollator) collator.clone();
    collator5.setStrength(strength);
    collator5.setAlternateHandlingShifted(true);
    collator5.setNumericCollation(true);
    collators.add(collator5);
  } catch (CloneNotSupportedException e) {
    // Do nothing.
  }
  makeCheck(collators.build(), tokenizedInput, locale, message);
}
 
开发者ID:googlei18n,项目名称:i18n_sanitycheck,代码行数:43,代码来源:OrderingChecker.java


注:本文中的com.ibm.icu.text.Collator.setStrength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。