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.mitosis.service.protocol.message;
21  
22  
23  import org.apache.directory.shared.ldap.util.EqualsBuilder;
24  import org.apache.directory.shared.ldap.util.HashCodeBuilder;
25  import org.apache.directory.mitosis.common.CSNVector;
26  import org.apache.directory.mitosis.service.protocol.Constants;
27  
28  
29  public class BeginLogEntriesAckMessage extends ResponseMessage
30  {
31      private final CSNVector purgeVector;
32      private final CSNVector updateVector;
33  
34  
35      public BeginLogEntriesAckMessage( int sequence, int responseCode, CSNVector purgeVector, CSNVector updateVector )
36      {
37          super( sequence, responseCode );
38  
39          if ( responseCode == Constants.OK )
40          {
41              assert purgeVector != null;
42              assert updateVector != null;
43  
44              this.purgeVector = purgeVector;
45              this.updateVector = updateVector;
46          }
47          else
48          {
49              this.purgeVector = null;
50              this.updateVector = null;
51          }
52      }
53  
54  
55      public int getType()
56      {
57          return Constants.GET_UPDATE_VECTOR_ACK;
58      }
59  
60  
61      public CSNVector getPurgeVector()
62      {
63          return purgeVector;
64      }
65  
66  
67      public CSNVector getUpdateVector()
68      {
69          return updateVector;
70      }
71  
72  
73      /**
74       * @see java.lang.Object#equals(Object)
75       */
76      public boolean equals( Object object )
77      {
78          if ( object == this )
79          {
80              return true;
81          }
82  
83          if ( !( object instanceof BeginLogEntriesAckMessage ) )
84          {
85              return false;
86          }
87  
88          BeginLogEntriesAckMessage rhs = ( BeginLogEntriesAckMessage ) object;
89  
90          return new EqualsBuilder().appendSuper( super.equals( object ) ).append( this.purgeVector, rhs.purgeVector )
91              .append( this.updateVector, rhs.updateVector ).isEquals();
92      }
93  
94  
95      /**
96       * @see java.lang.Object#hashCode()
97       * @return the instance's hashcode 
98       */
99      public int hashCode()
100     {
101         return new HashCodeBuilder( 537917217, 1652875233 ).appendSuper( super.hashCode() ).append( this.purgeVector )
102             .append( this.updateVector ).toHashCode();
103     }
104 
105 
106     public String toString()
107     {
108         return "[BeginLogEntriesAck] " + super.toString() + ", PV: " + purgeVector + ", UV: " + updateVector;
109     }
110 }