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.xdbm;
21
22
23 /**
24 * A master table used to store indexible entries.
25 *
26 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
27 * @version $Rev: 661851 $
28 */
29 public interface MasterTable<E> extends Table<Long, E>
30 {
31 /** the base name for the db file for this table */
32 String DBF = "master";
33
34 /** the sequence key - stores last sequence value in the admin table */
35 String SEQPROP_KEY = "__sequence__";
36
37
38 /**
39 * Gets an entry from this MasterTable.
40 *
41 * @param id the BigInteger id of the entry to retrieve.
42 * @return the entry with operational attributes and all.
43 * @throws Exception if there is a read error on the underlying Db.
44 */
45 E get( Long id ) throws Exception;
46
47
48 /**
49 * Puts an entry into this MasterTable with a specified unique id. Used
50 * both to create new entries and update existing ones.
51 *
52 * @param entry the entry to add
53 * @param id unique identifier of the entry to put
54 * @throws Exception if there is a write error on the underlying Db.
55 */
56 void put( Long id, E entry ) throws Exception;
57
58
59 /**
60 * Deletes a entry from this MasterTable at an index specified by id.
61 *
62 * @param id unique identifier of the entry to delete
63 * @return the deleted entry
64 * @throws Exception if there is a write error on the underlying Db
65 */
66 void delete( Long id ) throws Exception;
67
68
69 /**
70 * Gets the value of the id sequence from this MasterTable's sequence
71 * without affecting the value.
72 *
73 * @throws Exception if the admin table storing sequences cannot be read
74 */
75 Long getCurrentId() throws Exception;
76
77
78 /**
79 * Gets the next value from the sequence of this MasterTable. This has
80 * the side-effect of incrementing the sequence values perminantly.
81 *
82 * @return the current value of this MasterTable's sequence incremented
83 * by one
84 * @throws Exception on failure to update the id sequence
85 */
86 Long getNextId() throws Exception;
87
88
89 /**
90 * Gets a persistant property associated with this MasterTable.
91 *
92 * @param property the key of the property to get the value of
93 * @return the value of the property
94 * @throws Exception on failure to read the property
95 */
96 String getProperty( String property ) throws Exception;
97
98
99 /**
100 * Sets a persistant property associated with 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 Exception on failure to write the property
105 */
106 void setProperty( String property, String value ) throws Exception;
107 }