001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.api.ldap.model.message.controls; 021 022/** 023 * Implementation of SortResponseControl. 024 * 025 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 026 */ 027public class SortResponseImpl extends AbstractControl implements SortResponse 028{ 029 /** the sort operations result code */ 030 private SortResultCode result; 031 032 /** name of the first offending attribute */ 033 private String attributeName; 034 035 /** 036 * Creates a new SortResponseControlImpl instance 037 */ 038 public SortResponseImpl() 039 { 040 super( OID ); 041 } 042 043 044 /** 045 * {@inheritDoc} 046 */ 047 @Override 048 public void setSortResult( SortResultCode result ) 049 { 050 this.result = result; 051 } 052 053 054 /** 055 * {@inheritDoc} 056 */ 057 @Override 058 public SortResultCode getSortResult() 059 { 060 return result; 061 } 062 063 064 /** 065 * {@inheritDoc} 066 */ 067 @Override 068 public void setAttributeName( String attributeName ) 069 { 070 this.attributeName = attributeName; 071 } 072 073 074 /** 075 * {@inheritDoc} 076 */ 077 @Override 078 public String getAttributeName() 079 { 080 return attributeName; 081 } 082 083 084 /** 085 * {@inheritDoc} 086 */ 087 @Override 088 public int hashCode() 089 { 090 int hash = super.hashCode(); 091 092 hash = 37 * hash + ( ( attributeName == null ) ? 0 : attributeName.hashCode() ); 093 hash = 37 * hash + ( ( this.result == null ) ? 0 : this.result.hashCode() ); 094 095 return hash; 096 } 097 098 099 /** 100 * {@inheritDoc} 101 */ 102 @Override 103 public boolean equals( Object o ) 104 { 105 if ( this == o ) 106 { 107 return true; 108 } 109 110 if ( !( o instanceof SortResponse ) ) 111 { 112 return false; 113 } 114 115 SortResponse that = ( SortResponse ) o; 116 117 if ( !super.equals( o ) ) 118 { 119 return false; 120 } 121 122 if ( result != that.getSortResult() ) 123 { 124 return false; 125 } 126 127 if ( attributeName != null ) 128 { 129 return attributeName.equalsIgnoreCase( that.getAttributeName() ); 130 } 131 else if ( that.getAttributeName() == null ) 132 { 133 return true; 134 } 135 136 return false; 137 } 138 139 140 /** 141 * {@inheritDoc} 142 */ 143 @Override 144 public String toString() 145 { 146 return "SortResponseControlImpl [result=" + result + ", attributeName=" + attributeName + "]"; 147 } 148}