Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 118   Methods: 10
NCLOC: 61   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SimpleDataValueImpl.java 0% 0% 0% 0%
coverage
 1    /*
 2    wsmo4j - a WSMO API and Reference Implementation
 3   
 4    Copyright (c) 2005, University of Innsbruck, Austria
 5   
 6    This library is free software; you can redistribute it and/or modify it under
 7    the terms of the GNU Lesser General Public License as published by the Free
 8    Software Foundation; either version 2.1 of the License, or (at your option)
 9    any later version.
 10    This library is distributed in the hope that it will be useful, but WITHOUT
 11    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 12    FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 13    details.
 14    You should have received a copy of the GNU Lesser General Public License along
 15    with this library; if not, write to the Free Software Foundation, Inc.,
 16    59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 17    */
 18    package com.ontotext.wsmo4j.ontology;
 19   
 20    import java.math.BigDecimal;
 21    import java.math.BigInteger;
 22   
 23    import org.omwg.logicalexpression.terms.Visitor;
 24    import org.omwg.ontology.*;
 25   
 26    /**
 27    * Interface or class description
 28    *
 29    * <pre>
 30    * Created on Sep 5, 2005
 31    * Committed by $Author$
 32    * </pre>
 33    *
 34    * @author Holger Lausen (holger.lausen@deri.org)
 35    *
 36    * @version $Revision$ $Date$
 37    */
 38    public class SimpleDataValueImpl implements SimpleDataValue{
 39   
 40    Object value = null;
 41    SimpleDataType type = null;
 42   
 43  0 public SimpleDataValueImpl(SimpleDataType type, String value){
 44  0 if (!WsmlDataType.WSML_STRING.equals(
 45    type.getIRI().toString())){
 46  0 throw new IllegalArgumentException("Simple type string must have type wsml#string!");
 47    }
 48  0 this.type = type;
 49  0 this.value = value;
 50    }
 51   
 52  0 public SimpleDataValueImpl(SimpleDataType type, BigInteger value){
 53  0 if (!WsmlDataType.WSML_INTEGER.equals(
 54    type.getIRI().toString())){
 55  0 throw new IllegalArgumentException("Simple type integer must have type wsml#integer!");
 56    }
 57  0 this.type = type;
 58  0 this.value = value;
 59    }
 60   
 61  0 public SimpleDataValueImpl(SimpleDataType type, BigDecimal value){
 62  0 if (!WsmlDataType.WSML_DECIMAL.equals(
 63    type.getIRI().toString())){
 64  0 throw new IllegalArgumentException("Simple type decimal must have type wsml#decimal!");
 65    }
 66  0 this.type = type;
 67  0 this.value = value;
 68    }
 69   
 70  0 public String asString() {
 71  0 return value.toString();
 72    }
 73   
 74  0 public String toString() {
 75  0 return asString();
 76    }
 77   
 78  0 public WsmlDataType getType() {
 79  0 return type;
 80    }
 81   
 82  0 public Object getValue() {
 83  0 return value;
 84    }
 85   
 86  0 public void accept(Visitor v) {
 87  0 v.visitSimpleDataValue(this);
 88    }
 89   
 90  0 public boolean equals(Object o){
 91  0 if (o == null || !(o instanceof SimpleDataValue)){
 92  0 return false;
 93    }
 94  0 SimpleDataValue v = (SimpleDataValue)o;
 95  0 if (!v.getType().getIRI().toString().equals(type.getIRI().toString())){
 96  0 return false;
 97    }
 98  0 return v.getValue().equals(value);
 99    }
 100   
 101  0 public int hashCode(){
 102  0 return value.hashCode();
 103    }
 104    }
 105   
 106    /*
 107    * $Log$
 108    * Revision 1.2 2005/09/16 14:02:44 alex_simov
 109    * Identifier.asString() removed, use Object.toString() instead
 110    * (Implementations MUST override toString())
 111    *
 112    * Revision 1.1 2005/09/06 18:33:42 holgerlausen
 113    * support for datatypes: updated implementation according to interfaces
 114    * renamed WsmlDataTypeImpl to SimpleDataTypeImpl
 115    * moved DataValueImpl to ComplexDataValueImpl
 116    * added SimpleDataValueImpl for basic strings, decimal, ints
 117    *
 118    */