KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > store > SequenceStore


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/store/SequenceStore.java,v 1.3 2004/07/28 09:34:40 ib Exp $
3  * $Revision: 1.3 $
4  * $Date: 2004/07/28 09:34:40 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2004 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.slide.store;
25
26 import org.apache.slide.common.Service;
27 import org.apache.slide.common.ServiceAccessException;
28
29 /**
30  * Store for sequence support. A sequence is an entity that provides unique numbers.
31  * A store supports sequences when it implements this interface and the method
32  * {@link isSupported} returns <code>true</code>.
33  *
34  * @version $Revision: 1.3 $
35  */

36 public interface SequenceStore extends Service {
37     
38     /**
39      * Checks if this store instance actually supports sequences. It may seem clear
40      * this store supports sequences as it implements this interface, but a request to the
41      * underlying persistence store might be needed to dynamically find out.
42      *
43      * @return <code>true</code> if the store supports sequences, <code>false</code> otherwise
44      */

45     public boolean isSequenceSupported();
46     
47     /**
48      * Checks if the sequence already exists.
49      *
50      * @param sequenceName the name of the sequence you want to check
51      * @return <code>true</code> if the sequence already exists, <code>false</code> otherwise
52      * @throws ServiceAccessException if anything goes wrong while accessing the sequence
53      */

54     public boolean sequenceExists(String JavaDoc sequenceName) throws ServiceAccessException;
55     
56     /**
57      * Creates a sequence if it does not already exist.
58      *
59      * @param sequenceName the name of the sequence you want to create
60      * @return <code>true</code> if the sequence has been created, <code>false</code> if it already existed
61      * @throws ServiceAccessException if anything goes wrong while accessing the sequence
62      */

63     public boolean createSequence(String JavaDoc sequenceName) throws ServiceAccessException;
64     
65     /**
66      * Gets the next value of the sequence. Note that the sequence may not deliver consecutive
67      * or continuous values. The only thing that is assured is the value will be unique
68      * in the scope of the sequence, i.e. this method will never return the
69      * same value for the same sequence. A sequence of valid values <em>might</em> be
70      * <pre>1,2,3,4,5,...</pre>, but it might just as well be
71      * <pre>10,787875845,1,2,434,...</pre>.
72      * However, it may not be
73      * <pre>1,2,1,3,...</pre>.
74      * as a sequence must never return the same value twice or more times.
75      *
76      * @param sequenceNamethe name of the sequence you want the next value for
77      * @return the next value of the sequence
78      * @throws ServiceAccessException if anything goes wrong while accessing the sequence
79      */

80     public long nextSequenceValue(String JavaDoc sequenceName) throws ServiceAccessException;
81 }
82
Popular Tags