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
UnsignedByteData.java 0% 27,3% 44,4% 27%
 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.IDecimalData;
 13   
 import org.jbind.xml.core.data.IUnsignedByteData;
 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 UnsignedByteData extends AbstractUnsignedShortData implements IUnsignedByteData {
 19   
 
 20   
   private short myValue;
 21   
 
 22  1
   protected void doAccept(String aString) throws XmlException {
 23  1
     super.doAccept(aString);
 24  1
     try {
 25  1
       myValue = Short.parseShort(aString);
 26   
     } catch (NumberFormatException e) {
 27  0
       throw new XmlException(XmlMessages.simpleDataConversionException(aString, e, getImpl_()));
 28   
     }
 29   
   }
 30   
 
 31  1
   public String getCanonicalForm_() {
 32  1
     return String.valueOf(myValue);
 33   
   }
 34   
 
 35  1
   public short getShort() {
 36  1
     return myValue;
 37   
   }
 38  0
   public void setShort(short aNewValue) throws XmlException {
 39  0
     short oldValue = myValue;
 40  0
     myValue = aNewValue;
 41  0
     IConstraintViolations violations = completeSimpleStorageAssignment_();
 42  0
     if (!violations.isEmpty()) {
 43  0
       myValue = oldValue;
 44  0
       throw new XmlException(violations);
 45   
     }
 46   
   }
 47   
 
 48  0
   public int compareSubTypeData_(IDecimalData aData) {
 49  0
     short v = ((IUnsignedByteData)aData).getShort();
 50  0
     return (myValue < v) ? -1 : ((myValue > v) ? 1 : 0);
 51   
   }
 52   
 
 53  0
   public Object getSimpleStorageObject() {
 54  0
     return new Short(myValue);
 55   
   }
 56   
 
 57  0
   public void setSimpleStorageObject(Object aValue) {
 58  0
     myValue = ((Short)aValue).shortValue();
 59   
   }
 60   
 
 61  1
   public int getInt() {
 62  1
     return getShort();
 63   
   }
 64   
 
 65  0
   public void setInt(int aValue) throws XmlException {
 66  0
     if (aValue > 255) {
 67  0
       throw new XmlException(XmlMessages.numberTooLarge(String.valueOf(aValue), null));
 68   
     }
 69  0
     if (aValue < 0) {
 70  0
       throw new XmlException(XmlMessages.numberTooSmall(String.valueOf(aValue), null));
 71   
     }
 72  0
     setShort((short)aValue);
 73   
   }
 74   
 
 75   
 
 76   
 }
 77