Package com.ibm.icu.text

Examples of com.ibm.icu.text.RuleBasedCollator$CollationBuffer


      else
        throw new IllegalArgumentException("Invalid decomposition: " + decomposition);
    }
   
    // expert options: concrete subclasses are always a RuleBasedCollator
    RuleBasedCollator rbc = (RuleBasedCollator) collator;
    if (alternate != null) {
      if (alternate.equalsIgnoreCase("shifted")) {
        rbc.setAlternateHandlingShifted(true);
      } else if (alternate.equalsIgnoreCase("non-ignorable")) {
        rbc.setAlternateHandlingShifted(false);
      } else {
        throw new IllegalArgumentException("Invalid alternate: " + alternate);
      }
    }
    if (caseLevel != null) {
      rbc.setCaseLevel(Boolean.parseBoolean(caseLevel));
    }
    if (caseFirst != null) {
      if (caseFirst.equalsIgnoreCase("lower")) {
        rbc.setLowerCaseFirst(true);
      } else if (caseFirst.equalsIgnoreCase("upper")) {
        rbc.setUpperCaseFirst(true);
      } else {
        throw new IllegalArgumentException("Invalid caseFirst: " + caseFirst);
      }
    }
    if (numeric != null) {
      rbc.setNumericCollation(Boolean.parseBoolean(numeric));
    }
    if (variableTop != null) {
      rbc.setVariableTop(variableTop);
    }
  }
View Full Code Here


  private Collator createFromRules(String fileName, ResourceLoader loader) {
    InputStream input = null;
    try {
     input = loader.openResource(fileName);
     String rules = toUTF8String(input);
     return new RuleBasedCollator(rules);
    } catch (Exception e) {
      // io error or invalid rules
      throw new RuntimeException(e);
    } finally {
      IOUtils.closeWhileHandlingException(input);
View Full Code Here

   *
   * The default is DIN 5007-1, this shows how to tailor a collator to get DIN 5007-2 behavior.
   *  http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4423383
   */
  public void testCustomRules() throws Exception {
    RuleBasedCollator baseCollator = (RuleBasedCollator) Collator.getInstance(new ULocale("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";
View Full Code Here

     * @param str The string to parse
     * @return String the sort ordering text
     */
    public String filter(String str)
    {
        RuleBasedCollator collator = getCollator();

        // Have we got a collator?
        if (collator != null)
        {
            int element;
            StringBuffer buf = new StringBuffer();

            // Iterate through the elements of the collator
            CollationElementIterator iter = collator.getCollationElementIterator(str);
           
            while ((element = iter.next()) != CollationElementIterator.NULLORDER)
            {
                // Generate a hexadecimal string representation of the Collation element
                // This can then be compared in a text sort ;-)
View Full Code Here

        Locale locale = getSortLocale();
       
        if (locale != null)
        {
            // Get collator for the supplied Locale
            RuleBasedCollator collator = (RuleBasedCollator)Collator.getInstance(locale);
           
            if (collator != null)
            {
                return collator;
            }
View Full Code Here

    public RuleBasedCollator createCollator() {
        ULocale ulocale = new ULocale(locale);
        checkLocale(ulocale, scheme);
        ulocale = setKeywords(ulocale, keywordsToValues);

        RuleBasedCollator collator = (RuleBasedCollator) RuleBasedCollator.getInstance(ulocale);
        checkKeywords(collator.getLocale(ULocale.VALID_LOCALE), keywordsToValues,
                scheme);

        if (shouldSetStrength()) {
            setCollatorStrength(collator, this);
        }
View Full Code Here

    /**
     * Construct an actual ICU Collator given a collation specifier. The
     * result is a Collator that must be use in a thread-private manner.
     */
    static synchronized Collator forScheme(final CollationSpecifier specifier) {
        RuleBasedCollator collator = (RuleBasedCollator) sourceMap.get(specifier.toString());
        if (collator == null) {
            collator = specifier.createCollator();
            sourceMap.put(specifier.toString(), collator);
        }
        collator = collator.cloneAsThawed();
        return collator;
    }
View Full Code Here

TOP

Related Classes of com.ibm.icu.text.RuleBasedCollator$CollationBuffer

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.