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.server.core.partition.impl.btree.jdbm;
21
22
23 import org.apache.directory.server.core.avltree.AvlTree;
24
25
26 /**
27 * A wrapper around duplicate key values. This class wraps either an AvlTree
28 * or a BTreeRedirect. The AvlTree and BTreeRedirect forms are used for the
29 * two value persistence mechanisms used to implement duplicate keys over JDBM
30 * btrees.
31 *
32 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
33 * @version $Rev$
34 */
35 public class DupsContainer<V>
36 {
37 private final AvlTree<V> avlTree;
38 private final BTreeRedirect btreeRedirect;
39
40
41 DupsContainer( AvlTree<V> avlTree )
42 {
43 this.avlTree = avlTree;
44 btreeRedirect = null;
45 }
46
47
48 DupsContainer( BTreeRedirect btreeRedirect )
49 {
50 avlTree = null;
51 this.btreeRedirect = btreeRedirect;
52 }
53
54
55 final boolean isBTreeRedirect()
56 {
57 return btreeRedirect != null;
58 }
59
60
61 final boolean isAvlTree()
62 {
63 return avlTree != null;
64 }
65
66
67 final AvlTree<V> getAvlTree()
68 {
69 if ( avlTree == null )
70 {
71 throw new IllegalStateException( "this is not a avlTree container" );
72 }
73
74 return avlTree;
75 }
76
77
78 final BTreeRedirect getBTreeRedirect()
79 {
80 if ( btreeRedirect == null )
81 {
82 throw new IllegalStateException( "this is not a btreeRedirect container" );
83 }
84
85 return btreeRedirect;
86 }
87 }