src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/NodeSortRecord.java
author joehw
Wed, 18 Oct 2017 13:25:49 -0700
changeset 47359 e1a6c0168741
parent 47312 d4f959806fe9
child 48409 5ab69533994b
permissions -rw-r--r--
8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked Reviewed-by: lancea, rriggs, mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
45490
dc68478b53b9 8181153: Fix lint warnings in JAXP repo: dep-ann
joehw
parents: 44797
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
     3
 * @LastModified: Oct 2017
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
/*
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     6
 * Licensed to the Apache Software Foundation (ASF) under one or more
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     7
 * contributor license agreements.  See the NOTICE file distributed with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     8
 * this work for additional information regarding copyright ownership.
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     9
 * The ASF licenses this file to You under the Apache License, Version 2.0
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    10
 * (the "License"); you may not use this file except in compliance with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    11
 * the License.  You may obtain a copy of the License at
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 *
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    13
 *      http://www.apache.org/licenses/LICENSE-2.0
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * Unless required by applicable law or agreed to in writing, software
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 * distributed under the License is distributed on an "AS IS" BASIS,
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * See the License for the specific language governing permissions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 * limitations under the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
package com.sun.org.apache.xalan.internal.xsltc.dom;
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
47312
d4f959806fe9 8187593: Cleanup: removing SecuritySupport files
joehw
parents: 47216
diff changeset
    24
import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
import com.sun.org.apache.xalan.internal.xsltc.CollatorFactory;
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
import com.sun.org.apache.xalan.internal.xsltc.DOM;
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
import com.sun.org.apache.xalan.internal.xsltc.TransletException;
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
import com.sun.org.apache.xml.internal.utils.StringComparable;
47312
d4f959806fe9 8187593: Cleanup: removing SecuritySupport files
joehw
parents: 47216
diff changeset
    30
import java.text.Collator;
d4f959806fe9 8187593: Cleanup: removing SecuritySupport files
joehw
parents: 47216
diff changeset
    31
import java.util.Locale;
d4f959806fe9 8187593: Cleanup: removing SecuritySupport files
joehw
parents: 47216
diff changeset
    32
import jdk.xml.internal.SecuritySupport;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
 * Base class for sort records containing application specific sort keys
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
public abstract class NodeSortRecord {
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
    public static final int COMPARE_STRING     = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
    public static final int COMPARE_NUMERIC    = 1;
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
    public static final int COMPARE_ASCENDING  = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
    public static final int COMPARE_DESCENDING = 1;
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
     * A reference to a collator. May be updated by subclass if the stylesheet
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
     * specifies a different language (will be updated iff _locale is updated).
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
     * @deprecated This field continues to exist for binary compatibility.
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
     *             New code should not refer to it.
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
     */
45490
dc68478b53b9 8181153: Fix lint warnings in JAXP repo: dep-ann
joehw
parents: 44797
diff changeset
    50
    @Deprecated
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
    private static final Collator DEFAULT_COLLATOR = Collator.getInstance();
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
     * A reference to the first Collator
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
     * @deprecated This field continues to exist for binary compatibility.
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
     *             New code should not refer to it.
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
     */
45490
dc68478b53b9 8181153: Fix lint warnings in JAXP repo: dep-ann
joehw
parents: 44797
diff changeset
    58
    @Deprecated
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
    protected Collator _collator = DEFAULT_COLLATOR;
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
    protected Collator[] _collators;
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
     * A locale field that might be set by an instance of a subclass.
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
     * @deprecated This field continues to exist for binary compatibility.
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
     *             New code should not refer to it.
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
     */
45490
dc68478b53b9 8181153: Fix lint warnings in JAXP repo: dep-ann
joehw
parents: 44797
diff changeset
    67
    @Deprecated
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
    protected Locale _locale;
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
    protected CollatorFactory _collatorFactory;
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
    protected SortSettings _settings;
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
    private DOM    _dom = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
    private int    _node;           // The position in the current iterator
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
    private int    _last = 0;       // Number of nodes in the current iterator
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
    private int    _scanned = 0;    // Number of key levels extracted from DOM
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
    private Object[] _values; // Contains Comparable  objects
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
     * This constructor is run by a call to ClassLoader in the
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
     * makeNodeSortRecord method in the NodeSortRecordFactory class. Since we
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
     * cannot pass any parameters to the constructor in that case we just set
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
     * the default values here and wait for new values through initialize().
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
    public NodeSortRecord(int node) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
        _node = node;
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
    public NodeSortRecord() {
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
        this(0);
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
     * This method allows the caller to set the values that could not be passed
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
     * to the default constructor.
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
    public final void initialize(int node, int last, DOM dom,
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
         SortSettings settings)
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
        throws TransletException
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
        _dom = dom;
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
        _node = node;
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
        _last = last;
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
        _settings = settings;
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
        int levels = settings.getSortOrders().length;
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
        _values = new Object[levels];
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
        String colFactClassname = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
        try {
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
            // -- W. Eliot Kimber (eliot@isogen.com)
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
            colFactClassname =
16953
a44e04deb948 6657673: Issues with JAXP
joehw
parents: 12458
diff changeset
   115
                SecuritySupport.getSystemProperty("com.sun.org.apache.xalan.internal.xsltc.COLLATOR_FACTORY");
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
        catch (SecurityException e) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
            // If we can't read the propery, just use default collator
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
        if (colFactClassname != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
            try {
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   123
                Object candObj = ObjectFactory.findProviderClass(colFactClassname, true);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
                _collatorFactory = (CollatorFactory)candObj;
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
            } catch (ClassNotFoundException e) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
                throw new TransletException(e);
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
            Locale[] locales = settings.getLocales();
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
            _collators = new Collator[levels];
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
            for (int i = 0; i < levels; i++){
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
                _collators[i] = _collatorFactory.getCollator(locales[i]);
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
            _collator = _collators[0];
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
        } else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
            _collators = settings.getCollators();
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
            _collator = _collators[0];
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
     * Returns the node for this sort object
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
    public final int getNode() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
        return _node;
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
    public final int compareDocOrder(NodeSortRecord other) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
        return _node - other._node;
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
     * Get the string or numeric value of a specific level key for this sort
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
     * element. The value is extracted from the DOM if it is not already in
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
     * our sort key vector.
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
     */
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   159
    @SuppressWarnings({"rawtypes", "unchecked"})
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   160
    private final Comparable stringValue(int level) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   161
        // Get value from our array if possible
7f561c08de6b Initial load
duke
parents:
diff changeset
   162
        if (_scanned <= level) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   163
            AbstractTranslet translet = _settings.getTranslet();
7f561c08de6b Initial load
duke
parents:
diff changeset
   164
            Locale[] locales = _settings.getLocales();
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
            String[] caseOrder = _settings.getCaseOrders();
7f561c08de6b Initial load
duke
parents:
diff changeset
   166
7f561c08de6b Initial load
duke
parents:
diff changeset
   167
            // Get value from DOM if accessed for the first time
7f561c08de6b Initial load
duke
parents:
diff changeset
   168
            final String str = extractValueFromDOM(_dom, _node, level,
7f561c08de6b Initial load
duke
parents:
diff changeset
   169
                                                   translet, _last);
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   170
            final Comparable key = StringComparable.getComparator(
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   171
                    str, locales[level], _collators[level], caseOrder[level]);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   172
            _values[_scanned++] = key;
7f561c08de6b Initial load
duke
parents:
diff changeset
   173
            return(key);
7f561c08de6b Initial load
duke
parents:
diff changeset
   174
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   175
        return((Comparable)_values[level]);
7f561c08de6b Initial load
duke
parents:
diff changeset
   176
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   177
7f561c08de6b Initial load
duke
parents:
diff changeset
   178
    private final Double numericValue(int level) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   179
        // Get value from our vector if possible
7f561c08de6b Initial load
duke
parents:
diff changeset
   180
        if (_scanned <= level) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   181
            AbstractTranslet translet = _settings.getTranslet();
7f561c08de6b Initial load
duke
parents:
diff changeset
   182
7f561c08de6b Initial load
duke
parents:
diff changeset
   183
            // Get value from DOM if accessed for the first time
7f561c08de6b Initial load
duke
parents:
diff changeset
   184
            final String str = extractValueFromDOM(_dom, _node, level,
7f561c08de6b Initial load
duke
parents:
diff changeset
   185
                                                   translet, _last);
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
            Double num;
7f561c08de6b Initial load
duke
parents:
diff changeset
   187
            try {
45853
bfa06be36a17 8181154: Fix lint warnings in JAXP repo: deprecation
joehw
parents: 45490
diff changeset
   188
                num = Double.parseDouble(str);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   189
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   190
            // Treat number as NaN if it cannot be parsed as a double
7f561c08de6b Initial load
duke
parents:
diff changeset
   191
            catch (NumberFormatException e) {
45853
bfa06be36a17 8181154: Fix lint warnings in JAXP repo: deprecation
joehw
parents: 45490
diff changeset
   192
                num = Double.NEGATIVE_INFINITY;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   193
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   194
            _values[_scanned++] = num;
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
            return(num);
7f561c08de6b Initial load
duke
parents:
diff changeset
   196
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   197
        return((Double)_values[level]);
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   199
7f561c08de6b Initial load
duke
parents:
diff changeset
   200
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   201
     * Compare this sort element to another. The first level is checked first,
7f561c08de6b Initial load
duke
parents:
diff changeset
   202
     * and we proceed to the next level only if the first level keys are
7f561c08de6b Initial load
duke
parents:
diff changeset
   203
     * identical (and so the key values may not even be extracted from the DOM)
7f561c08de6b Initial load
duke
parents:
diff changeset
   204
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   205
     * !!!!MUST OPTIMISE - THIS IS REALLY, REALLY SLOW!!!!
7f561c08de6b Initial load
duke
parents:
diff changeset
   206
     */
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   207
    @SuppressWarnings({"rawtypes", "unchecked"})
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   208
    public int compareTo(NodeSortRecord other) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   209
        int cmp, level;
7f561c08de6b Initial load
duke
parents:
diff changeset
   210
        int[] sortOrder = _settings.getSortOrders();
7f561c08de6b Initial load
duke
parents:
diff changeset
   211
        int levels = _settings.getSortOrders().length;
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
        int[] compareTypes = _settings.getTypes();
7f561c08de6b Initial load
duke
parents:
diff changeset
   213
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
        for (level = 0; level < levels; level++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   215
            // Compare the two nodes either as numeric or text values
7f561c08de6b Initial load
duke
parents:
diff changeset
   216
            if (compareTypes[level] == COMPARE_NUMERIC) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
                final Double our = numericValue(level);
7f561c08de6b Initial load
duke
parents:
diff changeset
   218
                final Double their = other.numericValue(level);
7f561c08de6b Initial load
duke
parents:
diff changeset
   219
                cmp = our.compareTo(their);
7f561c08de6b Initial load
duke
parents:
diff changeset
   220
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   221
            else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   222
                final Comparable our = stringValue(level);
7f561c08de6b Initial load
duke
parents:
diff changeset
   223
                final Comparable their = other.stringValue(level);
7f561c08de6b Initial load
duke
parents:
diff changeset
   224
                cmp = our.compareTo(their);
7f561c08de6b Initial load
duke
parents:
diff changeset
   225
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   226
7f561c08de6b Initial load
duke
parents:
diff changeset
   227
            // Return inverse compare value if inverse sort order
7f561c08de6b Initial load
duke
parents:
diff changeset
   228
            if (cmp != 0) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   229
                return sortOrder[level] == COMPARE_DESCENDING ? 0 - cmp : cmp;
7f561c08de6b Initial load
duke
parents:
diff changeset
   230
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   231
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   232
        // Compare based on document order if all sort keys are equal
7f561c08de6b Initial load
duke
parents:
diff changeset
   233
        return(_node - other._node);
7f561c08de6b Initial load
duke
parents:
diff changeset
   234
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   235
7f561c08de6b Initial load
duke
parents:
diff changeset
   236
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   237
     * Returns the array of Collators used for text comparisons in this object.
7f561c08de6b Initial load
duke
parents:
diff changeset
   238
     * May be overridden by inheriting classes
7f561c08de6b Initial load
duke
parents:
diff changeset
   239
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
    public Collator[] getCollator() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   241
        return _collators;
7f561c08de6b Initial load
duke
parents:
diff changeset
   242
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   243
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   245
     * Extract the sort value for a level of this key.
7f561c08de6b Initial load
duke
parents:
diff changeset
   246
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   247
    public abstract String extractValueFromDOM(DOM dom, int current, int level,
7f561c08de6b Initial load
duke
parents:
diff changeset
   248
                                               AbstractTranslet translet,
7f561c08de6b Initial load
duke
parents:
diff changeset
   249
                                               int last);
7f561c08de6b Initial load
duke
parents:
diff changeset
   250
7f561c08de6b Initial load
duke
parents:
diff changeset
   251
}