1 // SECTION-START[License Header]
2 // <editor-fold defaultstate="collapsed" desc=" Generated License ">
3 /*
4 * Copyright (c) 2010 The JOMC Project
5 * Copyright (c) 2005 Christian Schulte <schulte2005@users.sourceforge.net>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * o Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * o Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE JOMC PROJECT AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JOMC PROJECT OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $Id: SequenceDirectory.java 2244 2010-06-29 07:58:09Z schulte2005 $
33 *
34 */
35 // </editor-fold>
36 // SECTION-END
37 package org.jomc.sequences;
38
39 import java.math.BigInteger;
40 import java.util.Set;
41
42 // SECTION-START[Documentation]
43 // <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
44 /**
45 * Directory of sequences.
46 *
47 * <p>
48 * This specification declares a multiplicity of {@code One}.
49 * An application assembler may provide either no or one implementation of this specification.
50 * </p>
51 *
52 * <p>
53 * Use of class {@link org.jomc.ObjectManager ObjectManager} is supported for accessing implementations.
54 * <pre>
55 * SequenceDirectory object = ObjectManagerFactory.getObjectManager( getClass().getClassLoader() ).getObject( SequenceDirectory.class );
56 * SequenceDirectory object = ObjectManagerFactory.getObjectManager( getClass().getClassLoader() ).getObject( SequenceDirectory.class, "<i>implementation name</i>" );
57 * </pre>
58 * </p>
59 *
60 * <p>
61 * This specification applies to {@code Singleton} scope.
62 * The same singleton object is returned whenever requested.
63 * </p>
64 *
65 * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
66 * @version $Id: SequenceDirectory.java 2244 2010-06-29 07:58:09Z schulte2005 $
67 */
68 // </editor-fold>
69 // SECTION-END
70 // SECTION-START[Annotations]
71 // <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
72 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" )
73 // </editor-fold>
74 // SECTION-END
75 public interface SequenceDirectory
76 {
77 // SECTION-START[SequenceDirectory]
78
79 /**
80 * Gets the total number of sequences stored in the directory.
81 *
82 * @return The total number of sequences stored in the directory.
83 *
84 * @throws SequencesSystemException if getting the total number of sequences fails.
85 */
86 BigInteger getSequenceCount() throws SequencesSystemException;
87
88 /**
89 * Gets the capacity limit of the directory.
90 *
91 * @return The capacity limit of the directory.
92 *
93 * @throws SequencesSystemException if getting the capacity limit fails.
94 */
95 BigInteger getCapacityLimit() throws SequencesSystemException;
96
97 /**
98 * Gets a sequence for a given name.
99 *
100 * @param name The name of the sequence to return.
101 *
102 * @return The sequence with name {@code name} or {@code null} if no sequence matching {@code name} exists in the
103 * directory.
104 *
105 * @throws SequencesSystemException if getting the sequence fails.
106 */
107 Sequence getSequence( String name ) throws SequencesSystemException;
108
109 /**
110 * Adds a sequence to the directory.
111 *
112 * @param sequence The sequence to add to the directory.
113 *
114 * @return The data of the sequence from the directory.
115 *
116 * @throws SequenceVetoException if {@code sequence} holds illegal values.
117 * @throws SequenceExistsException if a sequence with the same name already exists.
118 * @throws CapacityLimitException if the directory's capacity limit has been reached.
119 * @throws SequencesSystemException if adding the sequence fails.
120 */
121 Sequence addSequence( Sequence sequence )
122 throws SequenceVetoException, SequenceExistsException, CapacityLimitException, SequencesSystemException;
123
124 /**
125 * Updates a sequence in the directory.
126 *
127 * @param name The name of the sequence to update.
128 * @param revision The revision of the sequence to update.
129 * @param sequence The data to update the directory with.
130 *
131 * @return The data of the sequence from the directory.
132 *
133 * @throws SequenceVetoException if {@code sequence} holds illegal values.
134 * @throws SequenceNotFoundException if no sequence matching {@code name} exists in the directory.
135 * @throws ConcurrentModificationException if the same sequence got concurrently modified in the directory, that is,
136 * {@code revision} denotes outdated data.
137 * @throws SequencesSystemException if editing the sequence fails.
138 */
139 Sequence editSequence( String name, long revision, Sequence sequence )
140 throws SequenceVetoException, SequenceNotFoundException, ConcurrentModificationException,
141 SequencesSystemException;
142
143 /**
144 * Removes a sequence from the directory.
145 *
146 * @param name The name of the sequence to remove.
147 * @param revision The revision of the sequence to remove.
148 *
149 * @return The data of the removed sequence from the directory.
150 *
151 * @throws SequenceNotFoundException if no sequence matching {@code name} exists in the directory.
152 * @throws ConcurrentModificationException if the same sequence got concurrently modified in the directory, that is,
153 * {@code revision} denotes outdated data.
154 * @throws SequencesSystemException if deleting the sequence fails.
155 */
156 Sequence deleteSequence( String name, long revision )
157 throws SequenceNotFoundException, ConcurrentModificationException, SequencesSystemException;
158
159 /**
160 * Searches the directory for sequences matching the given arguments.
161 *
162 * @param name Text to select sequences whose {@code name} property matches the given text; {@code null} to ignore
163 * property {@code name} in the search.
164 *
165 * @return All sequences matching the given criteria.
166 *
167 * @throws SequencesSystemException if searching the directory fails.
168 */
169 Set<Sequence> searchSequences( String name ) throws SequencesSystemException;
170
171 // SECTION-END
172 }