Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 64   Methods: 9
NCLOC: 43   Classes: 1
This license of Clover is provided to support the development of JBind only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover.
 
 Source file Conditionals Statements Methods TOTAL
Range.java - 100% 100% 100%
 1   
 /*
 2   
  * JBind
 3   
  *
 4   
  * Copyright (c) by Stefan Wachter. All rights reserved.
 5   
  *
 6   
  * Usage, modification, and redistribution is subject to license terms that are
 7   
  * available at 'http://www.jbind.org'. The JBind license is like the
 8   
  * 'Apache Software License V 1.1'.
 9   
  */
 10   
 package org.jbind.xml.base;
 11   
 
 12   
 public class Range implements IRange {
 13   
 
 14   
   public static final IRange ZERO = new Range(0, 0);
 15   
   public static final IRange ONE = new Range(1, 1);
 16   
   public static final IRange ZERO_TO_UNBOUNDED = new Range(0);
 17   
 
 18  919
   public static IRange createRange(int aMin, int aMax, boolean anIsUnbounded) {
 19  919
     return anIsUnbounded ? new Range(aMin) : new Range(aMin, aMax);
 20   
   }
 21   
 
 22   
   private int myMinOccurs;
 23   
   private int myMaxOccurs;
 24   
 
 25  13897
   public Range(int aMinOccurs, int aMaxOccurs) {
 26   
     assert 0 <= aMinOccurs : "minOccurs must be >= 0";
 27   
     assert 0 <= aMaxOccurs : "maxOccurs must be >= 0";
 28   
     assert aMinOccurs <= aMaxOccurs : "minOccurs must be <= maxOccurs";
 29  13897
     myMinOccurs = aMinOccurs;
 30  13897
     myMaxOccurs = aMaxOccurs;
 31   
   }
 32   
 
 33  5678
   public Range(int aMinOccurs) {
 34   
     assert 0 <= aMinOccurs : "minOccurs must be >= 0";
 35  5678
     myMinOccurs = aMinOccurs;
 36  5678
     myMaxOccurs = -1;
 37   
   }
 38   
 
 39  70103
   public boolean isUnbounded() {
 40  70103
     return myMaxOccurs == -1;
 41   
   }
 42   
 
 43  1653
   public boolean compareMaxOccurs(int anInt) {
 44  1653
     return myMaxOccurs == anInt;
 45   
   }
 46   
 
 47  54056
   public int getMinOccurs() {
 48  54056
     return myMinOccurs;
 49   
   }
 50   
 
 51  46037
   public int getMaxOccurs() {
 52   
     assert 0 <= myMaxOccurs :
 53   
            "the range is unbounded; use the isUnbounded() method to check this in advance";
 54  46037
     return myMaxOccurs;
 55   
   }
 56   
 
 57  9857
   public boolean isZero() {
 58  9857
     return (0 == myMinOccurs) && (0 == myMaxOccurs);
 59   
   }
 60  978
   public boolean isOne() {
 61  978
     return (1 == myMinOccurs) && (1 == myMaxOccurs);
 62   
   }
 63   
 }
 64