[jsword-svn] jsword/java/jsword/org/crosswire/jsword/passage s
jswordcvs at crosswire.org
jswordcvs at crosswire.org
Sun May 8 18:29:09 MST 2005
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage
In directory www.crosswire.org:/tmp/cvs-serv6194/java/jsword/org/crosswire/jsword/passage
Modified Files:
DistinctPassage.java PassageTally.java RestrictionType.java
VerseRange.java DefaultLeafKeyList.java AbstractKeyList.java
AbstractPassage.java Verse.java RangedPassage.java
Log Message:
Moved unused code to limbo.
Upgraded support-tools: checkstyle, pmd and findbugs to most recent.
Addressed over 100 issues reported by findbugs and checkstyle.
Resulted in major refactoring of GBFFilter.
Net result is that code size is significantly smaller.
Index: DistinctPassage.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/DistinctPassage.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** DistinctPassage.java 16 Aug 2004 22:08:43 -0000 1.10
--- DistinctPassage.java 9 May 2005 01:29:06 -0000 1.11
***************
*** 90,94 ****
// However SortedSet is not Clonable so I can't
// Watch out for this, I'm not sure if it breaks anything.
! copy.store = Collections.synchronizedSortedSet(new TreeSet());
copy.store.addAll(store);
--- 90,94 ----
// However SortedSet is not Clonable so I can't
// Watch out for this, I'm not sure if it breaks anything.
! copy.store = new TreeSet();
copy.store.addAll(store);
***************
*** 217,221 ****
optimizeWrites();
! store = Collections.synchronizedSortedSet(new TreeSet());
readObjectSupport(in);
}
--- 217,221 ----
optimizeWrites();
! store = new TreeSet();
readObjectSupport(in);
}
***************
*** 229,232 ****
* The place the real data is stored
*/
! private transient SortedSet store = Collections.synchronizedSortedSet(new TreeSet());
}
--- 229,232 ----
* The place the real data is stored
*/
! private transient SortedSet store = new TreeSet();
}
Index: RestrictionType.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/RestrictionType.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** RestrictionType.java 24 Jan 2005 23:29:45 -0000 1.4
--- RestrictionType.java 9 May 2005 01:29:06 -0000 1.5
***************
*** 347,351 ****
public static int getBlurRestriction()
{
! return defaultBlurRestriction.toInteger();
}
--- 347,351 ----
public static int getBlurRestriction()
{
! return getDefaultBlurRestriction().toInteger();
}
***************
*** 356,359 ****
--- 356,363 ----
public static RestrictionType getDefaultBlurRestriction()
{
+ if (defaultBlurRestriction == null)
+ {
+ defaultBlurRestriction = RestrictionType.CHAPTER;
+ }
return defaultBlurRestriction;
}
***************
*** 362,366 ****
* A default restriction type for blurring.
*/
! private static RestrictionType defaultBlurRestriction = RestrictionType.CHAPTER;
/**
--- 366,370 ----
* A default restriction type for blurring.
*/
! private static RestrictionType defaultBlurRestriction;
/**
Index: RangedPassage.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/RangedPassage.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** RangedPassage.java 1 Apr 2005 17:09:46 -0000 1.20
--- RangedPassage.java 9 May 2005 01:29:06 -0000 1.21
***************
*** 4,8 ****
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
- import java.util.Collections;
import java.util.Iterator;
import java.util.NoSuchElementException;
--- 4,7 ----
***************
*** 58,62 ****
protected RangedPassage()
{
! store = Collections.synchronizedSortedSet(new TreeSet());
}
--- 57,61 ----
protected RangedPassage()
{
! store = new TreeSet();
}
***************
*** 78,82 ****
super(refs);
! store = Collections.synchronizedSortedSet(new TreeSet());
addVerses(refs);
normalize();
--- 77,81 ----
super(refs);
! store = new TreeSet();
addVerses(refs);
normalize();
***************
*** 95,99 ****
// However SortedSet is not Clonable so I can't
// Watch out for this, I'm not sure if it breaks anything.
! copy.store = Collections.synchronizedSortedSet(new TreeSet());
copy.store.addAll(store);
--- 94,98 ----
// However SortedSet is not Clonable so I can't
// Watch out for this, I'm not sure if it breaks anything.
! copy.store = new TreeSet();
copy.store.addAll(store);
***************
*** 228,232 ****
// This allows us to modify store which iterating through a copy
! SortedSet new_store = Collections.synchronizedSortedSet(new TreeSet());
new_store.addAll(store);
Iterator it = new_store.iterator();
--- 227,231 ----
// This allows us to modify store which iterating through a copy
! SortedSet new_store = new TreeSet();
new_store.addAll(store);
Iterator it = new_store.iterator();
***************
*** 274,278 ****
optimizeWrites();
! SortedSet new_store = Collections.synchronizedSortedSet(new TreeSet());
Iterator that_it = null;
--- 273,277 ----
optimizeWrites();
! SortedSet new_store = new TreeSet();
Iterator that_it = null;
***************
*** 330,334 ****
VerseRange last = null;
VerseRange next = null;
! SortedSet new_store = Collections.synchronizedSortedSet(new TreeSet());
Iterator it = rangeIterator(RestrictionType.NONE);
--- 329,333 ----
VerseRange last = null;
VerseRange next = null;
! SortedSet new_store = new TreeSet();
Iterator it = rangeIterator(RestrictionType.NONE);
***************
*** 375,379 ****
try
{
! SortedSet temp = Collections.synchronizedSortedSet(new TreeSet());
while (it.hasNext())
--- 374,378 ----
try
{
! SortedSet temp = new TreeSet();
while (it.hasNext())
***************
*** 544,548 ****
optimizeWrites();
! store = Collections.synchronizedSortedSet(new TreeSet());
readObjectSupport(in);
}
--- 543,547 ----
optimizeWrites();
! store = new TreeSet();
readObjectSupport(in);
}
Index: Verse.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/Verse.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** Verse.java 5 Apr 2005 00:33:40 -0000 1.35
--- Verse.java 9 May 2005 01:29:06 -0000 1.36
***************
*** 7,10 ****
--- 7,11 ----
import java.util.NoSuchElementException;
+ import org.crosswire.common.util.EmptyIterator;
import org.crosswire.common.util.Logger;
***************
*** 912,932 ****
public Iterator iterator()
{
! return new Iterator()
! {
! public void remove()
! {
! throw new UnsupportedOperationException();
! }
!
! public boolean hasNext()
! {
! return false;
! }
!
! public Object next()
! {
! return null;
! }
! };
}
--- 913,917 ----
public Iterator iterator()
{
! return new EmptyIterator();
}
Index: DefaultLeafKeyList.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/DefaultLeafKeyList.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DefaultLeafKeyList.java 1 Apr 2005 17:09:46 -0000 1.4
--- DefaultLeafKeyList.java 9 May 2005 01:29:06 -0000 1.5
***************
*** 3,6 ****
--- 3,8 ----
import java.util.Iterator;
+ import org.crosswire.common.util.EmptyIterator;
+
/**
* A simple default implementation of the Key interface.
***************
*** 109,129 ****
public Iterator iterator()
{
! return new Iterator()
! {
! public void remove()
! {
! throw new UnsupportedOperationException();
! }
!
! public boolean hasNext()
! {
! return false;
! }
!
! public Object next()
! {
! return null;
! }
! };
}
--- 111,115 ----
public Iterator iterator()
{
! return new EmptyIterator();
}
Index: AbstractKeyList.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/AbstractKeyList.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** AbstractKeyList.java 5 Apr 2005 00:33:40 -0000 1.8
--- AbstractKeyList.java 9 May 2005 01:29:06 -0000 1.9
***************
*** 120,141 ****
}
! final StringBuffer buffer = new StringBuffer();
! KeyUtil.visit(this, new DefaultKeyVisitor()
! {
! public void visitLeaf(Key key)
! {
! buffer.append(key.getName());
! buffer.append(AbstractPassage.REF_PREF_DELIM);
! }
! });
!
! String reply = buffer.toString();
! if (reply.length() > 0)
! {
! // strip off the final ", "
! reply = reply.substring(0, reply.length() - AbstractPassage.REF_PREF_DELIM.length());
! }
!
! return reply;
}
--- 120,126 ----
}
! DefaultKeyVisitor visitor = new NameVisitor();
! KeyUtil.visit(this, visitor);
! return visitor.toString();
}
***************
*** 145,171 ****
public String getOSISName()
{
! if (osisName != null)
! {
! return osisName;
! }
!
! final StringBuffer buffer = new StringBuffer();
! KeyUtil.visit(this, new DefaultKeyVisitor()
! {
! public void visitLeaf(Key key)
! {
! buffer.append(key.getOSISName());
! buffer.append(AbstractPassage.REF_OSIS_DELIM);
! }
! });
!
! String reply = buffer.toString();
! if (reply.length() > 0)
! {
! // strip off the final ", "
! reply = reply.substring(0, reply.length() - AbstractPassage.REF_OSIS_DELIM.length());
! }
!
! return reply;
}
--- 130,136 ----
public String getOSISName()
{
! DefaultKeyVisitor visitor = new OSISNameVisitor();
! KeyUtil.visit(this, visitor);
! return visitor.toString();
}
***************
*** 218,228 ****
/**
! * The common user visible name for this work
*/
! private String name;
/**
! * The OSIS ID attribute
*/
! private String osisName;
}
--- 183,245 ----
/**
! * The <code>NameVisitor</code> constructs a readable representation
! * of the Passage.
*/
! private static class NameVisitor extends DefaultKeyVisitor
! {
! /**
! * Create a <code>NameVisitor</code>.
! */
! public NameVisitor()
! {
! buffer = new StringBuffer();
! }
!
! /* (non-Javadoc)
! * @see org.crosswire.jsword.passage.KeyVisitor#visitLeaf(org.crosswire.jsword.passage.Key)
! */
! public void visitLeaf(Key key)
! {
! buffer.append(key.getName());
! buffer.append(AbstractPassage.REF_PREF_DELIM);
! }
!
! /* (non-Javadoc)
! * @see java.lang.Object#toString()
! */
! public String toString()
! {
! String reply = buffer.toString();
! if (reply.length() > 0)
! {
! // strip off the final ", "
! reply = reply.substring(0, reply.length() - AbstractPassage.REF_OSIS_DELIM.length());
! }
!
! return reply;
! }
!
! protected StringBuffer buffer;
! }
!
! /**
! * The <code>OSISNameVisitor</code> constructs a readable representation
! * of the Passage, using OSIS names.
! */
! private static class OSISNameVisitor extends NameVisitor
! {
! /* (non-Javadoc)
! * @see org.crosswire.jsword.passage.KeyVisitor#visitLeaf(org.crosswire.jsword.passage.Key)
! */
! public void visitLeaf(Key key)
! {
! buffer.append(key.getOSISName());
! buffer.append(AbstractPassage.REF_PREF_DELIM);
! }
! }
/**
! * The common user visible name for this work
*/
! private String name;
}
Index: PassageTally.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/PassageTally.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** PassageTally.java 5 Apr 2005 00:33:40 -0000 1.34
--- PassageTally.java 9 May 2005 01:29:06 -0000 1.35
***************
*** 100,103 ****
--- 100,119 ----
}
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.AbstractPassage#isEmpty()
+ */
+ public boolean isEmpty()
+ {
+ return size == 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.AbstractPassage#countVerses()
+ */
+ public int countVerses()
+ {
+ return size;
+ }
+
/**
* Set how we sort the verses we output. The options are:<ul>
***************
*** 343,360 ****
public int getIndexOf(Verse verse)
{
! int reply = 0;
!
! Iterator it = iterator();
! while (it.hasNext())
! {
! if (verse.equals(it.next()))
! {
! return reply;
! }
!
! reply++;
! }
!
! return -1;
}
--- 359,365 ----
public int getIndexOf(Verse verse)
{
! int pos = verse.getOrdinal() - 1;
! int tally = board[pos];
! return tally > 0 ? pos : -1;
}
***************
*** 544,547 ****
--- 549,554 ----
}
+ size = 0;
+
fireIntervalRemoved(this, null, null);
}
***************
*** 652,656 ****
int[] new_board = new int[BibleInfo.versesInBible()];
! int vib = BibleInfo.versesInBible();
for (int i = 0; i < vib; i++)
{
--- 659,663 ----
int[] new_board = new int[BibleInfo.versesInBible()];
! int vib = new_board.length;
for (int i = 0; i < vib; i++)
{
***************
*** 700,704 ****
/**
* Sometimes we end up not knowing what the max is - this makes sure
! * we know accurately
*/
private void resetMax()
--- 707,712 ----
/**
* Sometimes we end up not knowing what the max is - this makes sure
! * we know accurately.
! * Same with size.
*/
private void resetMax()
***************
*** 708,713 ****
--- 716,726 ----
int vib = BibleInfo.versesInBible();
max = 0;
+ size = 0;
for (int i = 0; i < vib; i++)
{
+ if (board[i] > 0)
+ {
+ size++;
+ }
if (board[i] > max)
{
***************
*** 744,747 ****
--- 757,761 ----
private final void increment(int ord, int tally)
{
+ boolean exists = board[ord - 1] > 0;
board[ord - 1] += tally;
if (board[ord - 1] > MAX_TALLY)
***************
*** 753,756 ****
--- 767,780 ----
board[ord - 1] = 0;
}
+
+ // Recompute the size
+ if (exists && board[ord - 1] == 0)
+ {
+ size--;
+ }
+ else if (!exists && board[ord - 1] > 0)
+ {
+ size++;
+ }
}
***************
*** 778,781 ****
--- 802,810 ----
private final void kill(int ord)
{
+ if (board[ord - 1] > 0)
+ {
+ size--;
+ }
+
board[ord - 1] = 0;
}
***************
*** 796,799 ****
--- 825,832 ----
public static final int MAX_TALLY = 20000;
+ /*
+ * The number of verses in the tally.
+ */
+ private int size;
/**
* The tallyboard itself
Index: AbstractPassage.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/AbstractPassage.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** AbstractPassage.java 5 May 2005 11:20:29 -0000 1.41
--- AbstractPassage.java 9 May 2005 01:29:06 -0000 1.42
***************
*** 980,984 ****
* you are done.
*/
! protected void raiseNormalizeProtection()
{
skipNormalization++;
--- 980,984 ----
* you are done.
*/
! public void raiseNormalizeProtection()
{
skipNormalization++;
***************
*** 1000,1004 ****
* calls normalize() if the count reaches zero.
*/
! protected void lowerNormalizeProtection()
{
skipNormalization--;
--- 1000,1004 ----
* calls normalize() if the count reaches zero.
*/
! public void lowerNormalizeProtection()
{
skipNormalization--;
***************
*** 1018,1022 ****
* you are done.
*/
! protected void raiseEventSuppresion()
{
suppressEvents++;
--- 1018,1022 ----
* you are done.
*/
! public void raiseEventSuppresion()
{
suppressEvents++;
***************
*** 1038,1042 ****
* @return true if it is then safe to fire an event.
*/
! protected boolean lowerEventSuppresionAndTest()
{
suppressEvents--;
--- 1038,1042 ----
* @return true if it is then safe to fire an event.
*/
! public boolean lowerEventSuppresionAndTest()
{
suppressEvents--;
Index: VerseRange.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/VerseRange.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** VerseRange.java 1 Apr 2005 17:09:46 -0000 1.38
--- VerseRange.java 9 May 2005 01:29:06 -0000 1.39
***************
*** 7,10 ****
--- 7,11 ----
import java.util.NoSuchElementException;
+ import org.crosswire.common.util.EmptyIterator;
import org.crosswire.common.util.Logger;
***************
*** 1043,1063 ****
public Iterator iterator()
{
! return new Iterator()
! {
! public void remove()
! {
! throw new UnsupportedOperationException();
! }
!
! public boolean hasNext()
! {
! return false;
! }
!
! public Object next()
! {
! return null;
! }
! };
}
--- 1044,1048 ----
public Iterator iterator()
{
! return new EmptyIterator();
}
More information about the jsword-svn
mailing list