| 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 as published by
5 * the Free Software Foundation. This program is distributed in the hope
6 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
7 * 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 * ID: $Id: BooksEvent.java 1966 2009-10-30 01:15:14Z dmsmith $
21 */
22 package org.crosswire.jsword.book;
23
24 import java.io.IOException;
25 import java.io.ObjectInputStream;
26 import java.util.EventObject;
27
28 /**
29 * A BooksEvent is fired whenever a Bible is added or removed from the system.
30 *
31 * @see gnu.lgpl.License for license details.<br>
32 * The copyright to this program is held by it's authors.
33 * @author Joe Walker [joe at eireneh dot com]
34 */
35 public class BooksEvent extends EventObject {
36 /**
37 * Basic constructor
38 *
39 * @param book
40 * The book of the changed Bible, or null if there is more than
41 * one change.
42 * @param added
43 * True if the changed Bible is an addition.
44 */
45 public BooksEvent(Object source, Book book, boolean added) {
46 super(source);
47
48 this.book = book;
49 this.added = added;
50 }
51
52 /**
53 * Get the name of the changed Book
54 *
55 * @return The Book
56 */
57 public Book getBook() {
58 return book;
59 }
60
61 /**
62 * Is this an addition event?
63 */
64 public boolean isAddition() {
65 return added;
66 }
67
68 /**
69 * Serialization support.
70 *
71 * @param is
72 * @throws IOException
73 * @throws ClassNotFoundException
74 */
75 private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException {
76 // Broken but we don't serialize events
77 book = null;
78 is.defaultReadObject();
79 }
80
81 /**
82 * Is this an addition event?
83 */
84 private boolean added;
85
86 /**
87 * The name of the changed Bible
88 */
89 private transient Book book;
90
91 /**
92 * Serialization ID
93 */
94 private static final long serialVersionUID = 3834876879554819894L;
95 }
96