src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecord.java
changeset 47359 e1a6c0168741
parent 47312 d4f959806fe9
child 48409 5ab69533994b
equal deleted inserted replaced
47358:d07d5f7cab35 47359:e1a6c0168741
     1 /*
     1 /*
     2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     3  * @LastModified: Sep 2017
     3  * @LastModified: Oct 2017
     4  */
     4  */
     5 /*
     5 /*
     6  * Licensed to the Apache Software Foundation (ASF) under one or more
     6  * Licensed to the Apache Software Foundation (ASF) under one or more
     7  * contributor license agreements.  See the NOTICE file distributed with
     7  * contributor license agreements.  See the NOTICE file distributed with
     8  * this work for additional information regarding copyright ownership.
     8  * this work for additional information regarding copyright ownership.
    25 import com.sun.org.apache.xalan.internal.xsltc.CollatorFactory;
    25 import com.sun.org.apache.xalan.internal.xsltc.CollatorFactory;
    26 import com.sun.org.apache.xalan.internal.xsltc.DOM;
    26 import com.sun.org.apache.xalan.internal.xsltc.DOM;
    27 import com.sun.org.apache.xalan.internal.xsltc.TransletException;
    27 import com.sun.org.apache.xalan.internal.xsltc.TransletException;
    28 import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
    28 import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
    29 import com.sun.org.apache.xml.internal.utils.StringComparable;
    29 import com.sun.org.apache.xml.internal.utils.StringComparable;
    30 import java.text.CollationKey;
       
    31 import java.text.Collator;
    30 import java.text.Collator;
    32 import java.util.Locale;
    31 import java.util.Locale;
    33 import jdk.xml.internal.SecuritySupport;
    32 import jdk.xml.internal.SecuritySupport;
    34 
    33 
    35 /**
    34 /**
   155     /**
   154     /**
   156      * Get the string or numeric value of a specific level key for this sort
   155      * Get the string or numeric value of a specific level key for this sort
   157      * element. The value is extracted from the DOM if it is not already in
   156      * element. The value is extracted from the DOM if it is not already in
   158      * our sort key vector.
   157      * our sort key vector.
   159      */
   158      */
       
   159     @SuppressWarnings({"rawtypes", "unchecked"})
   160     private final Comparable stringValue(int level) {
   160     private final Comparable stringValue(int level) {
   161         // Get value from our array if possible
   161         // Get value from our array if possible
   162         if (_scanned <= level) {
   162         if (_scanned <= level) {
   163             AbstractTranslet translet = _settings.getTranslet();
   163             AbstractTranslet translet = _settings.getTranslet();
   164             Locale[] locales = _settings.getLocales();
   164             Locale[] locales = _settings.getLocales();
   165             String[] caseOrder = _settings.getCaseOrders();
   165             String[] caseOrder = _settings.getCaseOrders();
   166 
   166 
   167             // Get value from DOM if accessed for the first time
   167             // Get value from DOM if accessed for the first time
   168             final String str = extractValueFromDOM(_dom, _node, level,
   168             final String str = extractValueFromDOM(_dom, _node, level,
   169                                                    translet, _last);
   169                                                    translet, _last);
   170             final Comparable key =
   170             final Comparable key = StringComparable.getComparator(
   171                 StringComparable.getComparator(str, locales[level],
   171                     str, locales[level], _collators[level], caseOrder[level]);
   172                                                _collators[level],
       
   173                                                caseOrder[level]);
       
   174             _values[_scanned++] = key;
   172             _values[_scanned++] = key;
   175             return(key);
   173             return(key);
   176         }
   174         }
   177         return((Comparable)_values[level]);
   175         return((Comparable)_values[level]);
   178   }
   176   }
   204      * and we proceed to the next level only if the first level keys are
   202      * and we proceed to the next level only if the first level keys are
   205      * identical (and so the key values may not even be extracted from the DOM)
   203      * identical (and so the key values may not even be extracted from the DOM)
   206      *
   204      *
   207      * !!!!MUST OPTIMISE - THIS IS REALLY, REALLY SLOW!!!!
   205      * !!!!MUST OPTIMISE - THIS IS REALLY, REALLY SLOW!!!!
   208      */
   206      */
       
   207     @SuppressWarnings({"rawtypes", "unchecked"})
   209     public int compareTo(NodeSortRecord other) {
   208     public int compareTo(NodeSortRecord other) {
   210         int cmp, level;
   209         int cmp, level;
   211         int[] sortOrder = _settings.getSortOrders();
   210         int[] sortOrder = _settings.getSortOrders();
   212         int levels = _settings.getSortOrders().length;
   211         int levels = _settings.getSortOrders().length;
   213         int[] compareTypes = _settings.getTypes();
   212         int[] compareTypes = _settings.getTypes();