|
|||||||||
| Home >> All >> com >> eireneh >> bible >> [ passage overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.eireneh.bible.passage
Class BitwisePassage

java.lang.Objectcom.eireneh.bible.passage.AbstractPassage
com.eireneh.bible.passage.BitwisePassage
- All Implemented Interfaces:
- java.lang.Cloneable, Passage, PassageConstants, java.io.Serializable
- Direct Known Subclasses:
- RocketPassage
- public class BitwisePassage
- extends AbstractPassage
A Passage that is implemented using a BitSet - one for each verse. The attributes of the style are:
- Fairly fast manipulation
- Fairly getName()
- Static size, poor for small Passages, good for large Passages
There is some optimization we could do here: The benchmark I have
been using spends a lot of time in VerseEnumeration. There is some
inefficiency here due to having to examine the bits of the BitSet
one by one, rather than being able to compare the underlying longs
with zero (clearing 64 bits in one shot). This would speed up the
(usual) case where there are relatively few matches in the BitSet,
but be a slowdown for fuller Passages.
The bad news is that this would mean re-writing BitSet which I am
not all that keen to do right now.
The BitSet has one more bit than the number of verses in the Bible. This would waste 1 bit per BitSet but since this doesn't cause BitSet to need an extra long it doesn't, and it saves us some maths.
|
Distribution Licence: Project B is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. The License is available on the internet here, by writing to Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, Or locally at the Licence link below. The copyright to this program is held by it's authors. |
- Version:
- $Id:$
| Nested Class Summary | |
private class |
BitwisePassage.VerseEnumeration
Iterate over the Verses |
| Nested classes inherited from class com.eireneh.bible.passage.AbstractPassage |
AbstractPassage.VerseRangeEnumeration |
| Field Summary | |
(package private) static long |
serialVersionUID
To make serialization work across new versions |
private java.util.BitSet |
store
The place the real data is stored |
| Fields inherited from class com.eireneh.bible.passage.AbstractPassage |
BITWISE, DISTINCT, listeners, log, METHOD_COUNT, original_name, RANGED, skip_normalization, suppress_events |
| Fields inherited from interface com.eireneh.bible.passage.PassageConstants |
ACCURACY_BOOK_CHAPTER, ACCURACY_BOOK_ONLY, ACCURACY_BOOK_VERSE, ACCURACY_CHAPTER_VERSE, ACCURACY_NONE, ACCURACY_VERSE_ONLY, CASE_LOWER, CASE_MIXED, CASE_SENTANCE, CASE_UPPER, CASES, RANGE_ALLOWED_DELIMS, RANGE_PREF_DELIM, REF_ALLOWED_DELIMS, REF_PREF_DELIM, RESTRICT_BOOK, RESTRICT_CHAPTER, RESTRICT_NONE, RESTRICTIONS, VERSE_ALLOWED_DELIMS, VERSE_END_MARK1, VERSE_END_MARK2, VERSE_NUMERIC_BOOK, VERSE_PREF_DELIM1, VERSE_PREF_DELIM2 |
| Constructor Summary | |
protected |
BitwisePassage()
Create an empty BitwisePassage. |
protected |
BitwisePassage(java.lang.String refs)
Create a Verse from a human readable string. |
| Method Summary | |
void |
add(VerseBase obj)
Ensures that this Passage contains the specified Verse |
void |
addAll(Passage that)
Adds the Verses in that Passage to this Passage |
void |
blur(int verses,
int restrict)
Widen the range of the verses in this list. |
void |
clear()
Removes all of the Verses from this Passage |
java.lang.Object |
clone()
Get a copy of ourselves. |
boolean |
contains(VerseBase obj)
Returns true if this Passage contains the specified Verse |
int |
countVerses()
Returns the number of verses in this collection. |
boolean |
isEmpty()
Does this Passage have 0 members |
java.util.Enumeration |
rangeElements()
Enumerate over the VerseRanges |
private void |
readObject(java.io.ObjectInputStream in)
Call the support mechanism in AbstractPassage |
void |
remove(VerseBase obj)
Removes a single instance of the specified Verse from this Passage |
void |
removeAll(Passage that)
Removes the Verses in this Passage that are contained in the specified Passage. |
void |
retainAll(Passage that)
Retains only the Verses in this Passage that are contained in the specified Passage. |
java.util.Enumeration |
verseElements()
Iterate over the Verses |
private void |
writeObject(java.io.ObjectOutputStream out)
Call the support mechanism in AbstractPassage |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
serialVersionUID
static final long serialVersionUID
- To make serialization work across new versions
- See Also:
- Constant Field Values
store
private transient java.util.BitSet store
- The place the real data is stored
| Constructor Detail |
BitwisePassage
protected BitwisePassage()
- Create an empty BitwisePassage. There are no ctors from either Verse
or VerseRange so you need to do new
DistinctPassage().add(...);
BitwisePassage
protected BitwisePassage(java.lang.String refs) throws NoSuchVerseException
- Create a Verse from a human readable string. The opposite
of toString(), Given any BitwisePassage v1, and the following
DistinctPassage v2 = new BitwisePassage(v1.toString());Thenv1.equals(v2);Theoretically, since there are many ways of representing a BitwisePassage as text string comparision along the lines of:v1.toString().equals(v2.toString())could be false. Practically since toString() is standardized this will be true however. We don't need to worry about thread safety in a ctor since we don't exist yet.
| Method Detail |
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
- Get a copy of ourselves. Points to note:
Call clone() not new() on member Objects, and on us.
Do not use Copy Constructors! - they do not inherit well.
Think about this needing to be synchronized
If this is not cloneable then writing cloneable children is harder
- Specified by:
clonein interfacePassage- Overrides:
clonein classAbstractPassage
countVerses
public int countVerses()
- Description copied from class:
AbstractPassage - Returns the number of verses in this collection. Like Collection.size()
This does not mean the Passage needs to use Verses, just that it understands the concept.
- Specified by:
countVersesin interfacePassage- Overrides:
countVersesin classAbstractPassage
isEmpty
public boolean isEmpty()
- Description copied from class:
AbstractPassage - Does this Passage have 0 members
- Specified by:
isEmptyin interfacePassage- Overrides:
isEmptyin classAbstractPassage
verseElements
public java.util.Enumeration verseElements()
- Iterate over the Verses
rangeElements
public java.util.Enumeration rangeElements()
- Enumerate over the VerseRanges
- Specified by:
rangeElementsin interfacePassage- Overrides:
rangeElementsin classAbstractPassage
contains
public boolean contains(VerseBase obj)
- Returns true if this Passage contains the specified Verse
add
public void add(VerseBase obj)
- Ensures that this Passage contains the specified Verse
remove
public void remove(VerseBase obj)
- Removes a single instance of the specified Verse from this Passage
addAll
public void addAll(Passage that)
- Adds the Verses in that Passage to this Passage
- Specified by:
addAllin interfacePassage- Overrides:
addAllin classAbstractPassage
removeAll
public void removeAll(Passage that)
- Removes the Verses in this Passage that are contained in the
specified Passage. In other words, removes from this Passage
all of its Verses that are not contained in the specified Passage
- Specified by:
removeAllin interfacePassage- Overrides:
removeAllin classAbstractPassage
retainAll
public void retainAll(Passage that)
- Retains only the Verses in this Passage that are contained in the
specified Passage. In other words, removes from this Passage
all of its Verses that are not contained in the specified Passage
- Specified by:
retainAllin interfacePassage- Overrides:
retainAllin classAbstractPassage
clear
public void clear()
- Removes all of the Verses from this Passage
- Specified by:
clearin interfacePassage- Overrides:
clearin classAbstractPassage
blur
public void blur(int verses,
int restrict)
- Widen the range of the verses in this list. This is primarily for
"find x within n verses of y" type applications.
- Specified by:
blurin interfacePassage- Overrides:
blurin classAbstractPassage
writeObject
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
- Call the support mechanism in AbstractPassage
readObject
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
- Call the support mechanism in AbstractPassage
|
|||||||||
| Home >> All >> com >> eireneh >> bible >> [ passage overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC