Coverage Report - org.crosswire.jsword.passage.SynchronizedPassage
 
Classes in this File Line Coverage Branch Coverage Complexity
SynchronizedPassage
0%
0/69
0%
0/2
1.022
 
 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.io.IOException;
 23  
 import java.io.Reader;
 24  
 import java.io.Writer;
 25  
 import java.util.Iterator;
 26  
 
 27  
 import org.crosswire.jsword.versification.Versification;
 28  
 
 29  
 /**
 30  
  * This is a simple proxy to a real Passage object that makes all accesses
 31  
  * synchronized. It is final to give the VM as much hope as possible at being
 32  
  * able to inline stuff.
 33  
  * 
 34  
  * @see gnu.lgpl.License The GNU Lesser General Public License for details.
 35  
  * @author Joe Walker
 36  
  */
 37  0
 final class SynchronizedPassage implements Passage {
 38  
     /**
 39  
      * Construct a SynchronizedPassage from a real Passage to which we proxy.
 40  
      * 
 41  
      * @param ref
 42  
      *            The real Passage
 43  
      */
 44  0
     SynchronizedPassage(Passage ref) {
 45  0
         this.ref = ref;
 46  0
     }
 47  
 
 48  
     /* (non-Javadoc)
 49  
      * @see org.crosswire.jsword.passage.Passage#getVersification()
 50  
      */
 51  
     public Versification getVersification() {
 52  0
         return ref.getVersification();
 53  
     }
 54  
 
 55  
     /* (non-Javadoc)
 56  
      * @see org.crosswire.jsword.passage.Passage#reversify(org.crosswire.jsword.versification.Versification)
 57  
      */
 58  
     public Passage reversify(Versification newVersification) {
 59  0
         return ref.reversify(newVersification);
 60  
     }
 61  
 
 62  
     /* (non-Javadoc)
 63  
      * @see org.crosswire.jsword.passage.VerseKey#isWhole()
 64  
      */
 65  
     public boolean isWhole() {
 66  0
         return ref.isWhole();
 67  
     }
 68  
 
 69  
     /* (non-Javadoc)
 70  
      * @see org.crosswire.jsword.passage.VerseKey#getWhole()
 71  
      */
 72  
     public Passage getWhole() {
 73  0
         return ref.getWhole();
 74  
     }
 75  
 
 76  
     /* (non-Javadoc)
 77  
      * @see org.crosswire.jsword.passage.Key#addAll(org.crosswire.jsword.passage.Key)
 78  
      */
 79  
     public synchronized void addAll(Key key) {
 80  0
         ref.addAll(key);
 81  0
     }
 82  
 
 83  
     /* (non-Javadoc)
 84  
      * @see org.crosswire.jsword.passage.Key#removeAll(org.crosswire.jsword.passage.Key)
 85  
      */
 86  
     public synchronized void removeAll(Key key) {
 87  0
         ref.removeAll(key);
 88  0
     }
 89  
 
 90  
     /* (non-Javadoc)
 91  
      * @see org.crosswire.jsword.passage.Key#retainAll(org.crosswire.jsword.passage.Key)
 92  
      */
 93  
     public synchronized void retainAll(Key key) {
 94  0
         ref.retainAll(key);
 95  0
     }
 96  
 
 97  
     /* (non-Javadoc)
 98  
      * @see org.crosswire.jsword.passage.Passage#contains(org.crosswire.jsword.passage.Key)
 99  
      */
 100  
     public synchronized boolean contains(Key key) {
 101  0
         return ref.contains(key);
 102  
     }
 103  
 
 104  
     /* (non-Javadoc)
 105  
      * @see org.crosswire.jsword.passage.Key#getChildCount()
 106  
      */
 107  
     public synchronized int getChildCount() {
 108  0
         return ref.getChildCount();
 109  
     }
 110  
 
 111  
     /* (non-Javadoc)
 112  
      * @see org.crosswire.jsword.passage.Key#getCardinality()
 113  
      */
 114  
     public synchronized int getCardinality() {
 115  0
         return ref.getCardinality();
 116  
     }
 117  
 
 118  
     /* (non-Javadoc)
 119  
      * @see org.crosswire.jsword.passage.Key#canHaveChildren()
 120  
      */
 121  
     public synchronized boolean canHaveChildren() {
 122  0
         return ref.canHaveChildren();
 123  
     }
 124  
 
 125  
     /* (non-Javadoc)
 126  
      * @see java.lang.Iterable#iterator()
 127  
      */
 128  
     public synchronized Iterator<Key> iterator() {
 129  0
         return ref.iterator();
 130  
     }
 131  
 
 132  
     /* (non-Javadoc)
 133  
      * @see org.crosswire.jsword.passage.Key#get(int)
 134  
      */
 135  
     public synchronized Key get(int index) {
 136  0
         return ref.get(index);
 137  
     }
 138  
 
 139  
     /* (non-Javadoc)
 140  
      * @see org.crosswire.jsword.passage.Key#indexOf(org.crosswire.jsword.passage.Key)
 141  
      */
 142  
     public synchronized int indexOf(Key that) {
 143  0
         return ref.indexOf(that);
 144  
     }
 145  
 
 146  
     /* (non-Javadoc)
 147  
      * @see org.crosswire.jsword.passage.Key#getParent()
 148  
      */
 149  
     public synchronized Key getParent() {
 150  0
         return ref.getParent();
 151  
     }
 152  
 
 153  
     /* (non-Javadoc)
 154  
      * @see org.crosswire.jsword.passage.Key#getName()
 155  
      */
 156  
     public synchronized String getName() {
 157  0
         return ref.getName();
 158  
     }
 159  
 
 160  
     /* (non-Javadoc)
 161  
      * @see org.crosswire.jsword.passage.Key#getName(org.crosswire.jsword.passage.Key)
 162  
      */
 163  
     public synchronized String getName(Key base) {
 164  0
         return ref.getName(base);
 165  
     }
 166  
 
 167  
     /* (non-Javadoc)
 168  
      * @see org.crosswire.jsword.passage.Key#getRootName()
 169  
      */
 170  
     public synchronized String getRootName() {
 171  0
         return ref.getRootName();
 172  
     }
 173  
 
 174  
     /* (non-Javadoc)
 175  
      * @see org.crosswire.jsword.passage.Key#getOsisRef()
 176  
      */
 177  
     public synchronized String getOsisRef() {
 178  0
         return ref.getOsisRef();
 179  
     }
 180  
 
 181  
     /* (non-Javadoc)
 182  
      * @see org.crosswire.jsword.passage.Key#getOsisID()
 183  
      */
 184  
     public synchronized String getOsisID() {
 185  0
         return ref.getOsisID();
 186  
     }
 187  
 
 188  
     /* (non-Javadoc)
 189  
      * @see org.crosswire.jsword.passage.Passage#getOverview()
 190  
      */
 191  
     public synchronized String getOverview() {
 192  0
         return ref.getOverview();
 193  
     }
 194  
 
 195  
     /* (non-Javadoc)
 196  
      * @see org.crosswire.jsword.passage.Key#isEmpty()
 197  
      */
 198  
     public synchronized boolean isEmpty() {
 199  0
         return ref.isEmpty();
 200  
     }
 201  
 
 202  
     /* (non-Javadoc)
 203  
      * @see org.crosswire.jsword.passage.Passage#countVerses()
 204  
      */
 205  
     public synchronized int countVerses() {
 206  0
         return ref.countVerses();
 207  
     }
 208  
 
 209  
     /* (non-Javadoc)
 210  
      * @see org.crosswire.jsword.passage.Passage#hasRanges(org.crosswire.jsword.passage.RestrictionType)
 211  
      */
 212  
     public synchronized boolean hasRanges(RestrictionType restrict) {
 213  0
         return ref.hasRanges(restrict);
 214  
     }
 215  
 
 216  
     /* (non-Javadoc)
 217  
      * @see org.crosswire.jsword.passage.Passage#countRanges(org.crosswire.jsword.passage.RestrictionType)
 218  
      */
 219  
     public synchronized int countRanges(RestrictionType restrict) {
 220  0
         return ref.countRanges(restrict);
 221  
     }
 222  
 
 223  
     /* (non-Javadoc)
 224  
      * @see org.crosswire.jsword.passage.Passage#trimVerses(int)
 225  
      */
 226  
     public synchronized Passage trimVerses(int count) {
 227  0
         return ref.trimVerses(count);
 228  
     }
 229  
 
 230  
     /* (non-Javadoc)
 231  
      * @see org.crosswire.jsword.passage.Passage#trimRanges(int, org.crosswire.jsword.passage.RestrictionType)
 232  
      */
 233  
     public synchronized Passage trimRanges(int count, RestrictionType restrict) {
 234  0
         return ref.trimRanges(count, restrict);
 235  
     }
 236  
 
 237  
     /* (non-Javadoc)
 238  
      * @see org.crosswire.jsword.passage.Passage#booksInPassage()
 239  
      */
 240  
     public synchronized int booksInPassage() {
 241  0
         return ref.booksInPassage();
 242  
     }
 243  
 
 244  
     /* (non-Javadoc)
 245  
      * @see org.crosswire.jsword.passage.Passage#getVerseAt(int)
 246  
      */
 247  
     public synchronized Verse getVerseAt(int offset) throws ArrayIndexOutOfBoundsException {
 248  0
         return ref.getVerseAt(offset);
 249  
     }
 250  
 
 251  
     /* (non-Javadoc)
 252  
      * @see org.crosswire.jsword.passage.Passage#getRangeAt(int, org.crosswire.jsword.passage.RestrictionType)
 253  
      */
 254  
     public synchronized VerseRange getRangeAt(int offset, RestrictionType restrict) throws ArrayIndexOutOfBoundsException {
 255  0
         return ref.getRangeAt(offset, restrict);
 256  
     }
 257  
 
 258  
     /* (non-Javadoc)
 259  
      * @see org.crosswire.jsword.passage.Passage#rangeIterator(org.crosswire.jsword.passage.RestrictionType)
 260  
      */
 261  
     public synchronized Iterator<VerseRange> rangeIterator(RestrictionType restrict) {
 262  0
         return ref.rangeIterator(restrict);
 263  
     }
 264  
 
 265  
     /* (non-Javadoc)
 266  
      * @see org.crosswire.jsword.passage.Passage#add(org.crosswire.jsword.passage.Key)
 267  
      */
 268  
     public synchronized void add(Key that) {
 269  0
         ref.add(that);
 270  0
     }
 271  
 
 272  
     /* (non-Javadoc)
 273  
      * @see org.crosswire.jsword.passage.Passage#remove(org.crosswire.jsword.passage.Key)
 274  
      */
 275  
     public synchronized void remove(Key that) {
 276  0
         ref.remove(that);
 277  0
     }
 278  
 
 279  
     /* (non-Javadoc)
 280  
      * @see org.crosswire.jsword.passage.Passage#containsAll(org.crosswire.jsword.passage.Passage)
 281  
      */
 282  
     public synchronized boolean containsAll(Passage that) {
 283  0
         return ref.containsAll(that);
 284  
     }
 285  
 
 286  
     /* (non-Javadoc)
 287  
      * @see org.crosswire.jsword.passage.Key#clear()
 288  
      */
 289  
     public synchronized void clear() {
 290  0
         ref.clear();
 291  0
     }
 292  
 
 293  
     /* (non-Javadoc)
 294  
      * @see org.crosswire.jsword.passage.Key#blur(int, org.crosswire.jsword.passage.RestrictionType)
 295  
      */
 296  
     public synchronized void blur(int by, RestrictionType restrict) {
 297  0
         ref.blur(by, restrict);
 298  0
     }
 299  
 
 300  
     /* (non-Javadoc)
 301  
      * @see org.crosswire.jsword.passage.Passage#readDescription(java.io.Reader)
 302  
      */
 303  
     public synchronized void readDescription(Reader in) throws IOException, NoSuchVerseException {
 304  0
         ref.readDescription(in);
 305  0
     }
 306  
 
 307  
     /* (non-Javadoc)
 308  
      * @see org.crosswire.jsword.passage.Passage#writeDescription(java.io.Writer)
 309  
      */
 310  
     public synchronized void writeDescription(Writer out) throws IOException {
 311  0
         ref.writeDescription(out);
 312  0
     }
 313  
 
 314  
     /* (non-Javadoc)
 315  
      * @see org.crosswire.jsword.passage.Passage#optimizeReads()
 316  
      */
 317  
     public synchronized void optimizeReads() {
 318  0
         ref.optimizeReads();
 319  0
     }
 320  
 
 321  
     /* (non-Javadoc)
 322  
      * @see org.crosswire.jsword.passage.Passage#addPassageListener(org.crosswire.jsword.passage.PassageListener)
 323  
      */
 324  
     public synchronized void addPassageListener(PassageListener li) {
 325  0
         ref.addPassageListener(li);
 326  0
     }
 327  
 
 328  
     /* (non-Javadoc)
 329  
      * @see org.crosswire.jsword.passage.Passage#removePassageListener(org.crosswire.jsword.passage.PassageListener)
 330  
      */
 331  
     public synchronized void removePassageListener(PassageListener li) {
 332  0
         ref.removePassageListener(li);
 333  0
     }
 334  
 
 335  
     @Override
 336  
     public synchronized SynchronizedPassage clone() {
 337  0
         SynchronizedPassage clone = null;
 338  
         try {
 339  0
             clone = (SynchronizedPassage) super.clone();
 340  0
             synchronized (clone) {
 341  0
                 clone.ref = (Passage) ref.clone();
 342  0
             }
 343  0
         } catch (CloneNotSupportedException e) {
 344  0
             assert false : e;
 345  0
         }
 346  0
         return clone;
 347  
     }
 348  
 
 349  
     @Override
 350  
     public synchronized int hashCode() {
 351  0
         return ref.hashCode();
 352  
     }
 353  
 
 354  
     @Override
 355  
     public synchronized boolean equals(Object obj) {
 356  0
         return ref.equals(obj);
 357  
     }
 358  
 
 359  
     /* (non-Javadoc)
 360  
      * @see java.lang.Comparable#compareTo(java.lang.Object)
 361  
      */
 362  
     public synchronized int compareTo(Key o) {
 363  0
         return ref.compareTo(o);
 364  
     }
 365  
 
 366  
     /**
 367  
      * The object we are proxying to
 368  
      */
 369  
     private Passage ref;
 370  
 
 371  
     /**
 372  
      * Serialization ID
 373  
      */
 374  
     private static final long serialVersionUID = 3833181441264531251L;
 375  
 }