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.mavibot.btree;
21  
22  
23  import java.util.Arrays;
24  
25  
26  /**
27   * A class to hold name, revision, and copied page offsets of a B-Tree.
28   *
29   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
30   */
31  public class RevisionOffset
32  {
33      /** the revision number */
34      private long revision;
35  
36      /** offsets of copied pages */
37      private long[] offsets;
38  
39  
40      /**
41       * Creates a new instance of RevisionOffset.
42       *
43       * @param revision the revision number
44       * @param offsets array of copied page offsets
45       */
46      public RevisionOffset( long revision, long[] offsets )
47      {
48          this.revision = revision;
49          this.offsets = offsets;
50      }
51  
52  
53      public long getRevision()
54      {
55          return revision;
56      }
57  
58  
59      /* no qualifier */void setRevision( long revision )
60      {
61          this.revision = revision;
62      }
63  
64  
65      public long[] getOffsets()
66      {
67          return offsets;
68      }
69  
70  
71      /* no qualifier */void setOffsets( long[] offsets )
72      {
73          this.offsets = offsets;
74      }
75  
76  
77      @Override
78      public int hashCode()
79      {
80          final int prime = 31;
81          int result = 1;
82          result = prime * result + ( int ) ( revision ^ ( revision >>> 32 ) );
83          return result;
84      }
85  
86  
87      @Override
88      public boolean equals( Object obj )
89      {
90          if ( this == obj )
91          {
92              return true;
93          }
94          
95          if ( obj == null )
96          {
97              return false;
98          }
99  
100         RevisionOffset other = ( RevisionOffset ) obj;
101 
102         if ( revision != other.revision )
103         {
104             return false;
105         }
106 
107         return true;
108     }
109 
110 
111     @Override
112     public String toString()
113     {
114         return "RevisionOffset [revision=" + revision + ", offsets=" + Arrays.toString( offsets ) + "]";
115     }
116 
117 }