| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| PassageEvent |
|
| 1.0;1 | ||||
| PassageEvent$EventType |
|
| 1.0;1 |
| 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.passage; | |
| 21 | ||
| 22 | import java.util.EventObject; | |
| 23 | ||
| 24 | /** | |
| 25 | * Defines an event that encapsulates changes to a Passage. For many operations | |
| 26 | * on a Passage, calculating the extent of the changes is hard. In these cases | |
| 27 | * we default the range to the whole Bible. | |
| 28 | * | |
| 29 | * @see gnu.lgpl.License The GNU Lesser General Public License for details. | |
| 30 | * @author Joe Walker | |
| 31 | */ | |
| 32 | public class PassageEvent extends EventObject { | |
| 33 | ||
| 34 | /** | |
| 35 | * Indicates what kind of change happened to a Passage. | |
| 36 | */ | |
| 37 | 0 | public enum EventType { |
| 38 | /** | |
| 39 | * Identifies one or more changes in the lists contents. | |
| 40 | */ | |
| 41 | 0 | CHANGED, |
| 42 | ||
| 43 | /** | |
| 44 | * Identifies the addition of one or more contiguous items to the list | |
| 45 | */ | |
| 46 | 0 | ADDED, |
| 47 | ||
| 48 | /** | |
| 49 | * Identifies the removal of one or more contiguous items from the list | |
| 50 | */ | |
| 51 | 0 | REMOVED, |
| 52 | } | |
| 53 | ||
| 54 | /** | |
| 55 | * Constructs a PassageEvent object. | |
| 56 | * | |
| 57 | * @param source | |
| 58 | * the source Object (typically <code>this</code>) | |
| 59 | * @param versesChanged | |
| 60 | * an int specifying VERSES_CHANGED, VERSES_ADDED, VERSES_REMOVED | |
| 61 | * @param lower | |
| 62 | * an int specifying the bottom of a range | |
| 63 | * @param upper | |
| 64 | * an int specifying the top of a range | |
| 65 | */ | |
| 66 | public PassageEvent(Object source, EventType versesChanged, Verse lower, Verse upper) { | |
| 67 | 0 | super(source); |
| 68 | ||
| 69 | 0 | this.type = versesChanged; |
| 70 | 0 | this.lower = lower; |
| 71 | 0 | this.upper = upper; |
| 72 | 0 | } |
| 73 | ||
| 74 | /** | |
| 75 | * Returns the event type. The possible values are: | |
| 76 | * <ul> | |
| 77 | * <li>VERSES_CHANGED | |
| 78 | * <li>VERSES_ADDED | |
| 79 | * <li>VERSES_REMOVED | |
| 80 | * </ul> | |
| 81 | * | |
| 82 | * @return an int representing the type value | |
| 83 | */ | |
| 84 | public EventType getType() { | |
| 85 | 0 | return type; |
| 86 | } | |
| 87 | ||
| 88 | /** | |
| 89 | * Returns the lower index of the range. For a single element, this value is | |
| 90 | * the same as that returned by {@link #getUpperIndex()}. | |
| 91 | * | |
| 92 | * @return an int representing the lower index value | |
| 93 | */ | |
| 94 | public Verse getLowerIndex() { | |
| 95 | 0 | return lower; |
| 96 | } | |
| 97 | ||
| 98 | /** | |
| 99 | * Returns the upper index of the range. For a single element, this value is | |
| 100 | * the same as that returned by {@link #getLowerIndex()}. | |
| 101 | * | |
| 102 | * @return an int representing the upper index value | |
| 103 | */ | |
| 104 | public Verse getUpperIndex() { | |
| 105 | 0 | return upper; |
| 106 | } | |
| 107 | ||
| 108 | /** | |
| 109 | * The type of change | |
| 110 | */ | |
| 111 | private EventType type; | |
| 112 | ||
| 113 | /** | |
| 114 | * The lowest numbered element to have changed | |
| 115 | */ | |
| 116 | private Verse lower; | |
| 117 | ||
| 118 | /** | |
| 119 | * The highest numbered element to have changed | |
| 120 | */ | |
| 121 | private Verse upper; | |
| 122 | ||
| 123 | /** | |
| 124 | * Serialization ID | |
| 125 | */ | |
| 126 | private static final long serialVersionUID = 3906647492467898675L; | |
| 127 | } |