src/java.naming/share/classes/javax/naming/ldap/SortKey.java
author stefank
Mon, 25 Nov 2019 15:00:32 +0100
changeset 59255 a74627659f96
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234602: ZGC: Windows compile error in ZHeuristic Reviewed-by: pliden, eosterlund
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.naming.ldap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * A sort key and its associated sort parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * This class implements a sort key which is used by the LDAPv3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * Control for server-side sorting of search results as defined in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * <a href="http://www.ietf.org/rfc/rfc2891.txt">RFC 2891</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * @see SortControl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * @author Vincent Ryan
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
public class SortKey {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
     * The ID of the attribute to sort by.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    private String attrID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * The sort order. Ascending order, by default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private boolean reverseOrder = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * The ID of the matching rule to use for ordering attribute values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private String matchingRuleID = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * Creates the default sort key for an attribute. Entries will be sorted
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * according to the specified attribute in ascending order using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * ordering matching rule defined for use with that attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * @param   attrID  The non-null ID of the attribute to be used as a sort
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     *          key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    public SortKey(String attrID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        this.attrID = attrID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * Creates a sort key for an attribute. Entries will be sorted according to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * the specified attribute in the specified sort order and using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * specified matching rule, if supplied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @param   attrID          The non-null ID of the attribute to be used as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *                          a sort key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @param   ascendingOrder  If true then entries are arranged in ascending
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     *                          order. Otherwise there are arranged in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     *                          descending order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @param   matchingRuleID  The possibly null ID of the matching rule to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     *                          use to order the attribute values. If not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *                          specified then the ordering matching rule
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     *                          defined for the sort key attribute is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    public SortKey(String attrID, boolean ascendingOrder,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                    String matchingRuleID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        this.attrID = attrID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        reverseOrder = (! ascendingOrder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        this.matchingRuleID = matchingRuleID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * Retrieves the attribute ID of the sort key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @return    The non-null Attribute ID of the sort key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public String getAttributeID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        return attrID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Determines the sort order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @return    true if the sort order is ascending, false if descending.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public boolean isAscending() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        return (! reverseOrder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * Retrieves the matching rule ID used to order the attribute values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @return    The possibly null matching rule ID. If null then the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *            ordering matching rule defined for the sort key attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *            is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public String getMatchingRuleID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        return matchingRuleID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
}