View Javadoc

1   // START LICENSE
2   // JSet - a Java JSet card board game implementation
3   // Copyright (C) 2004 Jerome Lacoste
4   //
5   // This program is free software; you can redistribute it and/or modify
6   // it under the terms of the GNU General Public License as published by
7   // the Free Software Foundation; either version 2 of the License, or (at
8   // your option) any later version.
9   //
10  // This program is distributed in the hope that it will be useful, but
11  // WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  // General Public License for more details.
14  //
15  // You should have received a copy of the GNU General Public License
16  // along with this program; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  // END LICENSE
19  
20  package org.cb.cardboard;
21  
22  import java.util.List;
23  
24  /***
25   * This interface defines the methods components like JCardBoard use
26   * to get the value of each card in a board and the length of the list.
27   * Logically the model is a vector, indices vary from 0 to
28   * CardBoardModel.getSize() - 1.  Any change to the contents or
29   * length of the data model must be reported to all of the
30   * CardBoardModelListener.
31   *
32   * @author jerome@coffeebreaks.org - last modified by $LastChangedBy: jerome $
33   * @version $Id: CardBoardModel.java 123 2004-04-14 23:45:53Z jerome $
34   */
35  public interface CardBoardModel
36  {
37    /***
38     * Returns the number of cards on the board.
39     * @return the length of the list
40     */
41    int getSize();
42  
43    /***
44     * Returns the value at the specified index.
45     * @param index the requested index
46     * @return the value at <code>index</code>
47     */
48    Card getElementAt(int index);
49  
50  
51    /***
52     * @return all the values.
53     */
54    List getElements();
55  
56    /***
57     * Adds a listener to the list that's notified each time a change
58     * to the data model occurs.
59     * @param listener the <code>CardBoardModelListener</code> to be added
60     */
61    void addBoardDataListener(CardBoardModelListener listener);
62  
63    /***
64     * Removes a listener from the list that's notified each time a
65     * change to the data model occurs.
66     * @param listener the <code>CardBoardModelListener</code> to be removed
67     */
68    void removeBoardDataListener(CardBoardModelListener listener);
69  }