Package java.text

Examples of java.text.RuleBasedCollator$CollationElement


{
  public void test(TestHarness harness)
  {
    try
      {
  RuleBasedCollator collator = new RuleBasedCollator("<a,A<AB,ab<ABC,abc");
  CollationElementIterator iter;
 
  iter = collator.getCollationElementIterator("abaaABC");
  iter.setOffset(1);
  harness.check(iter.getOffset(), 0);

  iter.setOffset(0);
  iter.next();
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 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";
View Full Code Here

            // StringDataValue returned for (V AS CLOB) should consider the
            // passed collation type in determining whether we should
            // generate SQLChar vs CollatorSQLChar for instance. Keep in mind
            // that collation applies only to character string types.
            try {
                RuleBasedCollator rbs = ConnectionUtil.getCurrentLCC().getDataValueFactory().
                getCharacterCollator(targetCollationType);
                result = ((StringDataValue)result).getValue(rbs);
            }
            catch( java.sql.SQLException sqle)
            {
View Full Code Here

    }


    @Test
    public void testRuleComparator() {
        RuleBasedCollator comp = (RuleBasedCollator)RuleBasedCollator.getInstance();
        doTest(comp);
    }
View Full Code Here

    while (lastNonspaceChar > 0 &&
         rawData[lastNonspaceChar - 1] == '\u0020')
      lastNonspaceChar--;      // count off the trailing spaces.

    RuleBasedCollator rbc = getLocaleFinder().getCollator();   
    cKey = rbc.getCollationKey(new String(rawData, 0, lastNonspaceChar));

    return cKey;
  }
View Full Code Here

      }
    }

    intArray = new int[getLength()];

    RuleBasedCollator rbc = getLocaleFinder().getCollator();
    CollationElementIterator cei = rbc.getCollationElementIterator(getString());
    int nextInt;
    while ((nextInt = cei.next()) != CollationElementIterator.NULLORDER)
    {
      /* Believe it or not, a String might have more
       * collation elements than characters.
View Full Code Here

    //If we are dealing with territory based collation and returnDVD is
    //of type StringDataValue, then we need to return a StringDataValue  
    //with territory based collation.
    if (returnDVD instanceof StringDataValue) {
      try {
        RuleBasedCollator rbs = ConnectionUtil.getCurrentLCC().getDataValueFactory().
        getCharacterCollator(typeDescriptor.getCollationType());
        return ((StringDataValue)returnDVD).getValue(rbs);
      }
      catch( java.sql.SQLException sqle)
      {
View Full Code Here

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

    throw noLocale();
  }

  /** @exception StandardException  Thrown on error */
  public RuleBasedCollator getCollator() throws StandardException {
    RuleBasedCollator retval = ruleBasedCollator;

    if (retval == null) {
      if (databaseLocale != null) {
        retval = ruleBasedCollator =
          (RuleBasedCollator) Collator.getInstance(databaseLocale);
View Full Code Here

     * Test program to output the sequence of collation element iterators for a given input string
     * @param args command line arguments (collationURI, test-string)
     */
    public static void main(String[] args) throws Exception {
        String rules = " ='-'='*'< a < b < c < d < e < f < g < h < i < j < k < l < m < n < o < p < q < r < s < t < u < v < w < x < y < z";
        RuleBasedCollator collator = new RuleBasedCollator(rules);

        for (int i=0; i<args.length; i++) {
            System.err.println(args[i]);
            FastStringBuffer sb = new FastStringBuffer(FastStringBuffer.MEDIUM);
            CollationElementIterator iter = collator.getCollationElementIterator(args[i]);
            while (true) {
                int e = iter.next();
                if (e==-1) {
                    break;
                }
View Full Code Here

TOP

Related Classes of java.text.RuleBasedCollator$CollationElement

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.