Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 68   Methods: 8
NCLOC: 46   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
BooleanData.java 66,7% 38,9% 25% 40,6%
 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.instance.data;
 11   
 
 12   
 import org.jbind.xml.core.data.IAnyTypeData;
 13   
 import org.jbind.xml.core.data.IBooleanData;
 14   
 import org.jbind.xml.msg.IConstraintViolations;
 15   
 import org.jbind.xml.msg.XmlException;
 16   
 import org.jbind.xml.msg.XmlMessages;
 17   
 
 18   
 public class BooleanData extends AbstractSimpleData implements IBooleanData {
 19   
 
 20   
   private boolean myValue;
 21   
 
 22  22
   public void doAccept(String aString) throws XmlException {
 23  22
     super.doAccept(aString);
 24  22
     if ("0".equals(aString) || "false".equals(aString)) {
 25  7
       myValue = false;
 26  15
     } else if ("1".equals(aString) || "true".equals(aString)) {
 27  11
       myValue = true;
 28   
     } else {
 29  4
       throw new XmlException(XmlMessages.invalidBoolean(aString, getImpl_()));
 30   
     }
 31   
   }
 32   
 
 33  1
   public boolean getBoolean() {
 34  1
     return myValue;
 35   
   }
 36   
 
 37  0
   public void setBoolean(boolean aNewValue) throws XmlException {
 38  0
     boolean oldValue = myValue;
 39  0
     myValue = aNewValue;
 40  0
     IConstraintViolations violations = completeSimpleStorageAssignment_();
 41  0
     if (!violations.isEmpty()) {
 42  0
       myValue = oldValue;
 43  0
       throw new XmlException(violations);
 44   
     }
 45   
   }
 46   
 
 47  0
   public String getCanonicalForm_() {
 48  0
     return "" + myValue;
 49   
   }
 50   
 
 51  0
   public boolean simpleStorageValueEquals(IAnyTypeData aData) {
 52  0
     return (aData instanceof IBooleanData) && (myValue == ((IBooleanData)aData).getBoolean());
 53   
   }
 54   
 
 55  0
   public int simpleStorageValueHashCode() {
 56  0
     return myValue ? 1231 : 1237;
 57   
   }
 58   
 
 59  0
   public Object getSimpleStorageObject() {
 60  0
     return new Boolean(myValue);
 61   
   }
 62   
 
 63  0
   public void setSimpleStorageObject(Object aValue) {
 64  0
     myValue = ((Boolean)aValue).booleanValue();
 65   
   }
 66   
 
 67   
 }
 68