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 * © CrossWire Bible Society, 2005 - 2016 18 * 19 */ 20 package org.crosswire.jsword.book; 21 22 import java.io.IOException; 23 import java.io.ObjectInputStream; 24 import java.util.EventObject; 25 26 /** 27 * A BooksEvent is fired whenever a Bible is added or removed from the system. 28 * 29 * @see gnu.lgpl.License The GNU Lesser General Public License for details. 30 * @author Joe Walker 31 */ 32 public class BooksEvent extends EventObject { 33 /** 34 * Basic constructor 35 * 36 * @param source the source of this BookEvent 37 * @param book 38 * The book of the changed Bible, or null if there is more than 39 * one change. 40 * @param added 41 * True if the changed Bible is an addition. 42 */ 43 public BooksEvent(Object source, Book book, boolean added) { 44 super(source); 45 46 this.book = book; 47 this.added = added; 48 } 49 50 /** 51 * Get the name of the changed Book 52 * 53 * @return The Book 54 */ 55 public Book getBook() { 56 return book; 57 } 58 59 /** 60 * Is this an addition event? 61 * 62 * @return true if the book is being added 63 */ 64 public boolean isAddition() { 65 return added; 66 } 67 68 /** 69 * Serialization support. 70 * 71 * @param is the input stream 72 * @throws IOException if an I/O error occurred 73 * @throws ClassNotFoundException this class cannot be recreated. 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