View Javadoc
1   /*
2    *   Licensed to the Apache Software Foundation (ASF) under one
3    *   or more contributor license agreements.  See the NOTICE file
4    *   distributed with this work for additional information
5    *   regarding copyright ownership.  The ASF licenses this file
6    *   to you under the Apache License, Version 2.0 (the
7    *   "License"); you may not use this file except in compliance
8    *   with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing,
13   *   software distributed under the License is distributed on an
14   *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *   KIND, either express or implied.  See the License for the
16   *   specific language governing permissions and limitations
17   *   under the License.
18   *
19   */
20  package org.apache.directory.api.ldap.model.message.controls;
21  
22  /**
23   * Implementation of SortResponseControl.
24   *
25   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
26   */
27  public class SortResponseControlImpl extends AbstractControl  implements SortResponse
28  {
29      /** the sort operations result code */
30      private SortResultCode result;
31      
32      /** name of the first offending attribute */
33      private String attributeName;
34      
35      public SortResponseControlImpl()
36      {
37          super( OID );
38      }
39  
40      @Override
41      public void setSortResult( SortResultCode result )
42      {
43          this.result = result;
44      }
45  
46      @Override
47      public SortResultCode getSortResult()
48      {
49          return result;
50      }
51  
52      @Override
53      public void setAttributeName( String attributeName )
54      {
55          this.attributeName = attributeName;
56      }
57  
58      @Override
59      public String getAttributeName()
60      {
61          return attributeName;
62      }
63  
64      @Override
65      public int hashCode()
66      {
67          final int prime = 31;
68          int result = super.hashCode();
69          result = prime * result + ( ( attributeName == null ) ? 0 : attributeName.hashCode() );
70          result = prime * result + ( ( this.result == null ) ? 0 : this.result.hashCode() );
71          return result;
72      }
73  
74      @Override
75      public boolean equals( Object o )
76      {
77          if( !super.equals( o ) )
78          {
79              return false;
80          }
81          
82          SortResponse that = ( SortResponse ) o;
83          
84          if( result != that.getSortResult() )
85          {
86              return false;
87          }
88          
89          if( attributeName != null )
90          {
91              return ( attributeName.equalsIgnoreCase( that.getAttributeName() ) );
92          }
93          else if( that.getAttributeName() == null )
94          {
95              return true;
96          }
97          
98          return false;
99      }
100 
101     @Override
102     public String toString()
103     {
104         return "SortResponseControlImpl [result=" + result + ", attributeName=" + attributeName + "]";
105     }
106     
107 }