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 SortResponseControlImpl 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 SortResponseControlImpl() 039 { 040 super( OID ); 041 } 042 043 /** 044 * {@inheritDoc} 045 */ 046 @Override 047 public void setSortResult( SortResultCode result ) 048 { 049 this.result = result; 050 } 051 052 /** 053 * {@inheritDoc} 054 */ 055 @Override 056 public SortResultCode getSortResult() 057 { 058 return result; 059 } 060 061 /** 062 * {@inheritDoc} 063 */ 064 @Override 065 public void setAttributeName( String attributeName ) 066 { 067 this.attributeName = attributeName; 068 } 069 070 /** 071 * {@inheritDoc} 072 */ 073 @Override 074 public String getAttributeName() 075 { 076 return attributeName; 077 } 078 079 /** 080 * {@inheritDoc} 081 */ 082 @Override 083 public int hashCode() 084 { 085 final int prime = 31; 086 int hash = super.hashCode(); 087 hash = prime * hash + ( ( attributeName == null ) ? 0 : attributeName.hashCode() ); 088 hash = prime * hash + ( ( this.result == null ) ? 0 : this.result.hashCode() ); 089 090 return hash; 091 } 092 093 /** 094 * {@inheritDoc} 095 */ 096 @Override 097 public boolean equals( Object o ) 098 { 099 if ( !super.equals( o ) ) 100 { 101 return false; 102 } 103 104 SortResponse that = ( SortResponse ) o; 105 106 if ( result != that.getSortResult() ) 107 { 108 return false; 109 } 110 111 if ( attributeName != null ) 112 { 113 return attributeName.equalsIgnoreCase( that.getAttributeName() ); 114 } 115 else if ( that.getAttributeName() == null ) 116 { 117 return true; 118 } 119 120 return false; 121 } 122 123 /** 124 * {@inheritDoc} 125 */ 126 @Override 127 public String toString() 128 { 129 return "SortResponseControlImpl [result=" + result + ", attributeName=" + attributeName + "]"; 130 } 131 132}