Package com.ibm.icu.text

Examples of com.ibm.icu.text.Collator$ServiceShim


    /*
     * Test method for 'com.ibm.icu.text.Collator.equals(String, String)'
     */
    public void testEqualsStringString() {
        Collator c = Collator.getInstance();
        c.setStrength(Collator.PRIMARY);
        assertTrue(c.equals(s1, s2));
    }
View Full Code Here


    /*
     * Test method for 'com.ibm.icu.text.Collator.compare(String, String)'
     */
    public void testCompareStringString() {
        Collator c = Collator.getInstance();
        c.setStrength(Collator.PRIMARY);
        assertTrue(0 == c.compare(s1, s2));
    }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.Collator.getCollationKey(String)'
     */
    public void testGetCollationKey() {
        Collator c = Collator.getInstance();
        c.setStrength(Collator.PRIMARY);
        CollationKey k1 = c.getCollationKey(s1);
        CollationKey k2 = c.getCollationKey(s2);
        assertTrue(k1.equals(k2));
        c.setStrength(Collator.TERTIARY);
        k1 = c.getCollationKey(s1);
        k2 = c.getCollationKey(s2);
        assertFalse(k1.equals(k2));
    }
View Full Code Here

 
  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));
    }
  }
View Full Code Here

  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();
View Full Code Here

 
  public void testThreadSafe() throws Exception {
    int iters = 20 * RANDOM_MULTIPLIER;
    for (int i = 0; i < iters; i++) {
      Locale locale = randomLocale(random);
      Collator collator = Collator.getInstance(locale);
      collator.setStrength(Collator.IDENTICAL);
      assertThreadSafe(new ICUCollationKeyAnalyzer(collator));
    }
  }
View Full Code Here

TOP

Related Classes of com.ibm.icu.text.Collator$ServiceShim

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.