Source code: com/virtuosotechnologies/asaph/model/StringList.java
1 /*
2 ================================================================================
3
4 FILE: StringList.java
5
6 PROJECT:
7
8 Asaph
9
10 CONTENTS:
11
12 String list interface in an Asaph model
13
14 PROGRAMMERS:
15
16 Daniel Azuma (DA) <dazuma@kagi.com>
17
18 COPYRIGHT:
19
20 Copyright (C) 2003 Daniel Azuma (dazuma@kagi.com)
21
22 This program is free software; you can redistribute it and/or
23 modify it under the terms of the GNU General Public License as
24 published by the Free Software Foundation; either version 2
25 of the License, or (at your option) any later version.
26
27 This program is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 GNU General Public License for more details.
31
32 You should have received a copy of the GNU General Public
33 License along with this program; if not, write to
34 Free Software Foundation, Inc.
35 59 Temple Place, Suite 330
36 Boston, MA 02111-1307 USA
37
38 ================================================================================
39 */
40
41
42 package com.virtuosotechnologies.asaph.model;
43
44 import javax.swing.event.UndoableEditListener;
45
46
47 /**
48 * This is the string list interface in an Asaph model. It is used in various
49 * places to represent an ordered list of strings, each represented by a
50 * SimpleString.
51 */
52 public interface StringList
53 extends SongMember
54 {
55 //-------------------------------------------------------------------------
56 // Accessor methods
57 //-------------------------------------------------------------------------
58
59 /**
60 * Get the number of strings in the list
61 *
62 * @return number of strings
63 */
64 public int getStringCount();
65
66
67 /**
68 * Get the nth string
69 *
70 * @param n index
71 * @return SimpleString
72 */
73 public SimpleString getNthString(
74 int n);
75
76
77 /**
78 * Get the next string following reference.
79 * If reference is null, returns the first string.
80 * If reference is the last string, returns null;
81 *
82 * @param reference reference SimpleString
83 * @return next string
84 * @exception IllegalArgumentException reference is not a member
85 */
86 public SimpleString getNextString(
87 SimpleString reference);
88
89
90 /**
91 * Get the previous string preceding reference.
92 * If reference is null, returns the last string.
93 * If reference is the first string, returns null;
94 *
95 * @param reference reference SimpleString
96 * @return previous string
97 * @exception IllegalArgumentException reference is not a member
98 */
99 public SimpleString getPreviousString(
100 SimpleString reference);
101
102
103 //-------------------------------------------------------------------------
104 // Mutation methods
105 //-------------------------------------------------------------------------
106
107 /**
108 * Add a string to the list at the given position
109 *
110 * @param before insert before this string, or at the end if null
111 * @param str string value
112 * @param undoListener listener to notify if an undoable edit is generated,
113 * or null to suppress generation of undoable edits
114 * @return SimpleString for new string
115 * @exception IllegalArgumentException before is not a member
116 * @exception NullPointerException str was null
117 */
118 public SimpleString insertStringBefore(
119 SimpleString before,
120 String str,
121 UndoableEditListener undoListener);
122
123
124 /**
125 * Add a string to the list at the given position
126 *
127 * @param after insert after this string, or at the beginning if null
128 * @param str string value
129 * @param undoListener listener to notify if an undoable edit is generated,
130 * or null to suppress generation of undoable edits
131 * @return SimpleString for new string
132 * @exception IllegalArgumentException after is not a member
133 * @exception NullPointerException str was null
134 */
135 public SimpleString insertStringAfter(
136 SimpleString after,
137 String str,
138 UndoableEditListener undoListener);
139
140
141 /**
142 * Remove a SimpleString from the list.
143 *
144 * @param str string to remove
145 * @param undoListener listener to notify if an undoable edit is generated,
146 * or null to suppress generation of undoable edits
147 * @exception IllegalArgumentException str is not a member
148 * @exception NullPointerException str was null
149 */
150 public void removeString(
151 SimpleString str,
152 UndoableEditListener undoListener);
153
154
155 /**
156 * Clear the string list
157 *
158 * @param undoListener listener to notify if an undoable edit is generated,
159 * or null to suppress generation of undoable edits
160 */
161 public void clear(
162 UndoableEditListener undoListener);
163 }