Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 77   Methods: 9
NCLOC: 54   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
ByteData.java 0% 40,9% 66,7% 40,5%
 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.IByteData;
 13   
 import org.jbind.xml.core.data.IDecimalData;
 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 ByteData extends AbstractShortData implements IByteData {
 19   
 
 20   
   private byte myValue;
 21   
 
 22  4
   public short getShort() {
 23  4
     return myValue;
 24   
   }
 25   
 
 26  0
   public void setShort(short aValue) throws XmlException {
 27  0
     if (aValue > Byte.MAX_VALUE) {
 28  0
       throw new XmlException(XmlMessages.numberTooLarge(String.valueOf(aValue), null));
 29   
     }
 30  0
     if (aValue < Byte.MIN_VALUE) {
 31  0
       throw new XmlException(XmlMessages.numberTooSmall(String.valueOf(aValue), null));
 32   
     }
 33  0
     setByte((byte)aValue);
 34   
   }
 35   
 
 36  3
   public byte getByte() {
 37  3
     return myValue;
 38   
   }
 39   
 
 40  0
   public void setByte(byte aNewValue) throws XmlException {
 41  0
     byte oldValue = myValue;
 42  0
     myValue = aNewValue;
 43  0
     IConstraintViolations violations = completeSimpleStorageAssignment_();
 44  0
     if (!violations.isEmpty()) {
 45  0
       myValue = oldValue;
 46  0
       throw new XmlException(violations);
 47   
     }
 48   
   }
 49   
 
 50  2
   public int compareSubTypeData_(IDecimalData aData) {
 51  2
     byte v = ((IByteData)aData).getByte();
 52  2
     return (myValue < v) ? -1 : ((myValue > v) ? 1 : 0);
 53   
   }
 54   
 
 55  10
   public void doAccept(String aString) throws XmlException {
 56  10
     super.doAccept(aString);
 57  10
     try {
 58  10
       myValue = Byte.parseByte(aString);
 59   
     } catch (NumberFormatException e) {
 60  0
       throw new XmlException(XmlMessages.simpleDataConversionException(aString, e, getImpl_()));
 61   
     }
 62   
   }
 63   
 
 64  4
   public String getCanonicalForm_() {
 65  4
     return Byte.toString(myValue);
 66   
   }
 67   
 
 68  2
   public Object getSimpleStorageObject() {
 69  2
     return new Byte(myValue);
 70   
   }
 71   
 
 72  0
   public void setSimpleStorageObject(Object aValue) {
 73  0
     myValue = ((Byte)aValue).byteValue();
 74   
   }
 75   
 
 76   
 }
 77