View Javadoc

1   /*
2    *   Copyright 2004 The Apache Software Foundation
3    *
4    *   Licensed under the Apache License, Version 2.0 (the "License");
5    *   you may not use this file except in compliance with the License.
6    *   You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *   Unless required by applicable law or agreed to in writing, software
11   *   distributed under the License is distributed on an "AS IS" BASIS,
12   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *   See the License for the specific language governing permissions and
14   *   limitations under the License.
15   *
16   */
17  package org.apache.ldap.server.partition.impl.btree;
18  
19  
20  import java.math.BigInteger;
21  
22  import javax.naming.NamingException;
23  import javax.naming.directory.Attributes;
24  
25  
26  /***
27   * The master table used to store the Attributes of entries.
28   *
29   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
30   * @version $Rev: 264732 $
31   */
32  public interface MasterTable extends Table
33  {
34      /*** the name of the dbf file for this table */
35      String DBF = "master";
36  
37      /*** the sequence key - stores last sequence value in the admin table */
38      String SEQPROP_KEY = "__sequence__";
39  
40      /***
41       * Gets the Attributes of an entry from this MasterTable.
42       *
43       * @param id the BigInteger id of the entry to retrieve.
44       * @return the Attributes of the entry with operational attributes and all.
45       * @throws NamingException if there is a read error on the underlying Db.
46       */
47      Attributes get( BigInteger id ) throws NamingException;
48      
49      /***
50       * Puts the Attributes of an entry into this master table at an index 
51       * specified by id.  Used both to create new entries and update existing 
52       * ones.
53       *
54       * @param entry the Attributes of entry w/ operational attributes
55       * @param id the BigInteger id of the entry to put
56       * @return the newly created entry's Attributes
57       * @throws NamingException if there is a write error on the underlying Db.
58       */
59      Attributes put( Attributes entry, BigInteger id ) throws NamingException;
60          
61      /***
62       * Deletes a entry from the master table at an index specified by id.
63       *
64       * @param id the BigInteger id of the entry to delete
65       * @return the Attributes of the deleted entry
66       * @throws NamingException if there is a write error on the underlying Db
67       */
68      Attributes delete( BigInteger id ) throws NamingException;
69  
70      /***
71       * Get's the current id value from this master database's sequence without
72       * affecting the seq.
73       *
74       * @return the current value.
75       * @throws NamingException if the admin table storing sequences cannot be
76       * read.
77       */
78      BigInteger getCurrentId() throws NamingException;
79      
80      /***
81       * Get's the next value from this SequenceBDb.  This has the side-effect of
82       * changing the current sequence values perminantly in memory and on disk.
83       *
84       * @return the current value incremented by one.
85       * @throws NamingException if the admin table storing sequences cannot be
86       * read and writen to.
87       */
88      BigInteger getNextId() throws NamingException;
89      
90      /***
91       * Gets a persistant property stored in the admin table of this MasterTable.
92       *
93       * @param property the key of the property to get the value of
94       * @return the value of the property
95       * @throws NamingException when the underlying admin table cannot be read
96       */
97      String getProperty( String property ) throws NamingException;
98          
99      /***
100      * Sets a persistant property stored in the admin table of this MasterTable.
101      *
102      * @param property the key of the property to set the value of
103      * @param value the value of the property
104      * @throws NamingException when the underlying admin table cannot be writen
105      */
106     void setProperty( String property, String value ) throws NamingException;
107 }