| BooksEvent.java |
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 it's 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 for license details.<br>
31 * The copyright to this program is held by it's authors.
32 * @author Joe Walker [joe at eireneh dot com]
33 */
34 public class BooksEvent extends EventObject {
35 /**
36 * Basic constructor
37 *
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 public boolean isAddition() {
64 return added;
65 }
66
67 /**
68 * Serialization support.
69 *
70 * @param is
71 * @throws IOException
72 * @throws ClassNotFoundException
73 */
74 private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException {
75 // Broken but we don't serialize events
76 book = null;
77 is.defaultReadObject();
78 }
79
80 /**
81 * Is this an addition event?
82 */
83 private boolean added;
84
85 /**
86 * The name of the changed Bible
87 */
88 private transient Book book;
89
90 /**
91 * Serialization ID
92 */
93 private static final long serialVersionUID = 3834876879554819894L;
94 }
95