Package java.text

Examples of java.text.CollationKey


            // This happens if the object at rowIndex zero is null.
            // So test before we cast:
           
            if (value1 instanceof String) {
              //if the object is a String we best compare locale-sesitive
              CollationKey collationKey1 = getCollationKey((String)value1);
              CollationKey collationKey2 = getCollationKey((String)value2);
             
              return collationKey1.compareTo(collationKey2);
            }
            else if (value1 instanceof Comparable)
            {
View Full Code Here


                return value1.toString().compareTo(value2.toString());
            }
        }        
       
        private CollationKey getCollationKey(String propertyValue) {
          CollationKey key = (CollationKey)_collationKeys.get(propertyValue);
          if (key == null) {
            key = _collator.getCollationKey(propertyValue);
            _collationKeys.put(propertyValue, key);
          }
           
View Full Code Here

    final Double our = numericValue(level);
    final Double their = other.numericValue(level);
    cmp = our.compareTo(their);
      }
      else {
    final CollationKey our = stringValue(level);
    final CollationKey their = other.stringValue(level);
    cmp = our.compareTo(their);
      }
     
      // Return inverse compare value if inverse sort order
      if (cmp != 0) {
View Full Code Here

    int result;


    if (comparator instanceof Collator) {
      CollationKey collationKey1
          = ((Collator) comparator).getCollationKey(obj1.toString());
      CollationKey collationKey2
          = ((Collator) comparator).getCollationKey(obj2.toString());
      result = collationKey1.compareTo(collationKey2);

    } else if (comparator != null) {
      result = comparator.compare(obj1, obj2);
View Full Code Here

                        : (diff > 0.0) ? (k.m_descending ? -1 : 1) : 0);
      }
    }  // end treat as numbers
    else
    {
      CollationKey n1String, n2String;

      if (kIndex == 0)
      {
        n1String = (CollationKey) n1.m_key1Value;
        n2String = (CollationKey) n2.m_key1Value;
      }
      else if (kIndex == 1)
      {
        n1String = (CollationKey) n1.m_key2Value;
        n2String = (CollationKey) n2.m_key2Value;
      }

      /* Leave this in case we decide to use an array later
      if (kIndex < maxkey)
      {
        String n1String = (String)n1.m_keyValue[kIndex];
        String n2String = (String)n2.m_keyValue[kIndex];
      }*/
      else
      {

        // Get values dynamically
        XObject r1 = k.m_selectPat.execute(m_execContext, n1.m_node,
                                           k.m_namespaceContext);
        XObject r2 = k.m_selectPat.execute(m_execContext, n2.m_node,
                                           k.m_namespaceContext);

        n1String = k.m_col.getCollationKey(r1.str());
        n2String = k.m_col.getCollationKey(r2.str());
      }

      // Use collation keys for faster compare, but note that whitespaces
      // etc... are treated differently from if we were comparing Strings.
      result = n1String.compareTo(n2String);

      //Process caseOrder parameter
      if (k.m_caseOrderUpper)
      {
        String tempN1 = n1String.getSourceString().toLowerCase();
        String tempN2 = n2String.getSourceString().toLowerCase();

        if (tempN1.equals(tempN2))
        {

View Full Code Here

    int result;


    if (comparator instanceof Collator) {
      CollationKey collationKey1
          = ((Collator) comparator).getCollationKey(obj1.toString());
      CollationKey collationKey2
          = ((Collator) comparator).getCollationKey(obj2.toString());
      result = collationKey1.compareTo(collationKey2);

    } else if (comparator != null) {
      result = comparator.compare(obj1, obj2);
View Full Code Here

   * Implementation of hashCode() for the national character types,
   * put here to make it accessible to all the national types.
   */
  protected int nationalHashCode()
  {
    CollationKey tmpCKey = null;

    try
    {
      tmpCKey = getCollationKey();
    }
    catch (StandardException se)
    {
      if (SanityManager.DEBUG)
      {
        SanityManager.THROWASSERT("Unexpected exception", se);
      }
    }

    if (tmpCKey == null)
      return 0;
    return tmpCKey.hashCode();
  }
View Full Code Here

  // Get value from our array if possible
  if (_scanned <= level) {
      // Get value from DOM if accessed for the first time
      final String str = extractValueFromDOM(_dom, _node, level,
               _translet, _last);
      final CollationKey key = _collator.getCollationKey(str);
      _values[_scanned++] = key;
      return(key);
  }
  return((CollationKey)_values[level]);
    }
View Full Code Here

    final Double our = numericValue(level);
    final Double their = other.numericValue(level);
    cmp = our.compareTo(their);
      }
      else {
    final CollationKey our = stringValue(level);
    final CollationKey their = other.stringValue(level);
    cmp = our.compareTo(their);
      }
     
      // Return inverse compare value if inverse sort order
      if (cmp != 0) {
View Full Code Here

    /**
     * Hash code implementation for collator sensitive subclasses.
     */
    int hashCodeForCollation() {
        CollationKey key = null;

        try {
            key = getCollationKey();
        } catch (StandardException se) {
            // ignore exceptions, like we do in hashCode()
            if (SanityManager.DEBUG) {
                SanityManager.THROWASSERT("Unexpected exception", se);
            }
        }

        return key == null ? 0 : key.hashCode();
    }
View Full Code Here

TOP

Related Classes of java.text.CollationKey

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.