1   /**
2    * Distribution License:
3    * JSword is free software; you can redistribute it and/or modify it under
4    * the terms of the GNU Lesser General Public License, version 2.1 or later
5    * as published by the Free Software Foundation. This program is distributed
6    * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
7    * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8    * See the GNU Lesser General Public License for more details.
9    *
10   * The License is available on the internet at:
11   *       http://www.gnu.org/copyleft/lgpl.html
12   * or by writing to:
13   *      Free Software Foundation, Inc.
14   *      59 Temple Place - Suite 330
15   *      Boston, MA 02111-1307, USA
16   *
17   * Copyright: 2005
18   *     The copyright to this program is held by its authors.
19   *
20   */
21  package org.crosswire.jsword.book;
22  
23  import java.io.IOException;
24  import java.io.ObjectInputStream;
25  import java.util.EventObject;
26  
27  /**
28   * A BooksEvent is fired whenever a Bible is added or removed from the system.
29   * 
30   * @see gnu.lgpl.License The GNU Lesser General Public License for details.
31   * @author Joe Walker
32   */
33  public class BooksEvent extends EventObject {
34      /**
35       * Basic constructor
36       * 
37       * @param source the source of this BookEvent
38       * @param book
39       *            The book of the changed Bible, or null if there is more than
40       *            one change.
41       * @param added
42       *            True if the changed Bible is an addition.
43       */
44      public BooksEvent(Object source, Book book, boolean added) {
45          super(source);
46  
47          this.book = book;
48          this.added = added;
49      }
50  
51      /**
52       * Get the name of the changed Book
53       * 
54       * @return The Book
55       */
56      public Book getBook() {
57          return book;
58      }
59  
60      /**
61       * Is this an addition event?
62       * 
63       * @return true if the book is being added
64       */
65      public boolean isAddition() {
66          return added;
67      }
68  
69      /**
70       * Serialization support.
71       * 
72       * @param is the input stream
73       * @throws IOException if an I/O error occurred
74       * @throws ClassNotFoundException this class cannot be recreated.
75       */
76      private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException {
77          // Broken but we don't serialize events
78          book = null;
79          is.defaultReadObject();
80      }
81  
82      /**
83       * Is this an addition event?
84       */
85      private boolean added;
86  
87      /**
88       * The name of the changed Bible
89       */
90      private transient Book book;
91  
92      /**
93       * Serialization ID
94       */
95      private static final long serialVersionUID = 3834876879554819894L;
96  }
97