Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 486E9106E5 for ; Mon, 17 Jun 2013 10:06:54 +0000 (UTC) Received: (qmail 2696 invoked by uid 500); 17 Jun 2013 10:06:53 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 2638 invoked by uid 500); 17 Jun 2013 10:06:47 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 2628 invoked by uid 99); 17 Jun 2013 10:06:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Jun 2013 10:06:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Jun 2013 10:06:43 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9955D23888E3; Mon, 17 Jun 2013 10:06:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1493705 - /directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortKey.java Date: Mon, 17 Jun 2013 10:06:24 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130617100624.9955D23888E3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Mon Jun 17 10:06:24 2013 New Revision: 1493705 URL: http://svn.apache.org/r1493705 Log: Added the data structure to store the AttributeType in the SSS control Added: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortKey.java Added: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortKey.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortKey.java?rev=1493705&view=auto ============================================================================== --- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortKey.java (added) +++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortKey.java Mon Jun 17 10:06:24 2013 @@ -0,0 +1,269 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.api.ldap.model.message.controls; + + +import org.apache.directory.api.ldap.model.schema.AttributeType; + + +/** + * Store the Attribute + * @author Apache Directory Project + */ +public class SortKey +{ + /** + * The name of AttributeType we want to use as a key for the sort + */ + private String attributeTypeOid; + + /** + * The AttributeType we want to use as a key for the sort + */ + private AttributeType attributeType; + + /** + * The matching rule to use to order the result + */ + private String matchingRuleId; + + /** + * A flag to set to true to get the result in reverse order + */ + private boolean reverseOrder; + + + /** + * Create a new instance of a SortKey for a give AttributeType + * + * @param attributeType The AttributeType to use + */ + public SortKey( AttributeType attributeType ) + { + this.attributeType = attributeType; + matchingRuleId = attributeType.getOrderingOid(); + reverseOrder = false; + } + + + /** + * Create a new instance of a SortKey for a give AttributeType + * + * @param attributeTypeOid The AttributeType OID to use + */ + public SortKey( String attributeTypeOid ) + { + this.attributeTypeOid = attributeTypeOid; + matchingRuleId = null; + reverseOrder = false; + } + + + /** + * Create a new instance of a SortKey for a give AttributeType + * + * @param attributeType The AttributeType to use + * @param matchingRuleId The MatchingRule to use + */ + public SortKey( AttributeType attributeType, String matchingRuleId ) + { + this.attributeType = attributeType; + this.matchingRuleId = matchingRuleId; + reverseOrder = false; + } + + + /** + * Create a new instance of a SortKey for a give AttributeType + * + * @param attributeTypeOid The AttributeType OID to use + * @param matchingRuleId The MatchingRule to use + */ + public SortKey( String attributeTypeOid, String matchingRuleId ) + { + this.attributeTypeOid = attributeTypeOid; + this.matchingRuleId = matchingRuleId; + reverseOrder = false; + } + + + /** + * Create a new instance of a SortKey for a give AttributeType + * + * @param attributeType The AttributeType to use + * @param matchingRuleId The MatchingRule to use + * @param reverseOrder The reverseOrder flag + */ + public SortKey( AttributeType attributeType, String matchingRuleId, boolean reverseOrder ) + { + this.attributeType = attributeType; + this.matchingRuleId = matchingRuleId; + this.reverseOrder = reverseOrder; + } + + + /** + * Create a new instance of a SortKey for a give AttributeType + * + * @param attributeTypeOid The AttributeType OID to use + * @param matchingRuleId The MatchingRule to use + * @param reverseOrder The reverseOrder flag + */ + public SortKey( String attributeTypeOid, String matchingRuleId, boolean reverseOrder ) + { + this.attributeTypeOid = attributeTypeOid; + this.matchingRuleId = matchingRuleId; + this.reverseOrder = reverseOrder; + } + + + /** + * Create a new instance of a SortKey for a give AttributeType + * + * @param attributeType The AttributeType to use + * @param reverseOrder The reverseOrder flag + */ + public SortKey( AttributeType attributeType, boolean reverseOrder ) + { + this.attributeType = attributeType; + this.matchingRuleId = attributeType.getOrderingOid(); + this.reverseOrder = reverseOrder; + } + + + /** + * Create a new instance of a SortKey for a give AttributeType + * + * @param attributeTypeOid The AttributeType OID to use + * @param reverseOrder The reverseOrder flag + */ + public SortKey( String attributeTypeOid, boolean reverseOrder ) + { + this.attributeTypeOid = attributeTypeOid; + this.reverseOrder = reverseOrder; + } + + + /** + * @return the attributeType + */ + public AttributeType getAttributeType() + { + return attributeType; + } + + + /** + * @param attributeType the attributeType to set + */ + public void setAttributeType( AttributeType attributeType ) + { + this.attributeType = attributeType; + this.attributeTypeOid = attributeType.getOid(); + } + + + /** + * @return the attributeType OID + */ + public String getAttributeTypeOid() + { + return attributeTypeOid; + } + + + /** + * @param attributeType the attributeType to set + */ + public void setAttributeType( String attributeTypeOid ) + { + this.attributeTypeOid = attributeTypeOid; + } + + + /** + * @return the matchingRuleId + */ + public String getMatchingRuleId() + { + return matchingRuleId; + } + + + /** + * @param matchingRuleId the matchingRuleId to set + */ + public void setMatchingRuleId( String matchingRuleId ) + { + this.matchingRuleId = matchingRuleId; + } + + + /** + * @return the reverseOrder + */ + public boolean isReverseOrder() + { + return reverseOrder; + } + + + /** + * @param reverseOrder the reverseOrder to set + */ + public void setReverseOrder( boolean reverseOrder ) + { + this.reverseOrder = reverseOrder; + } + + + /** + * @see String#toString() + */ + public String toString() + { + StringBuilder sb = new StringBuilder(); + + sb.append( "SortKey : [" ); + + if ( attributeType != null ) + { + sb.append( attributeType.getName() ).append( ',' ); + sb.append( matchingRuleId ); + } + else + { + sb.append( attributeTypeOid ); + + if ( matchingRuleId != null ) + { + sb.append( ", " ).append( matchingRuleId ); + } + } + + if ( reverseOrder ) + { + sb.append( ", reverse" ); + } + + sb.append( ']' ); + return sb.toString(); + } +}