Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 238   Methods: 21
NCLOC: 116   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AttributeImpl.java 0% 0% 0% 0%
coverage
 1    /*
 2    wsmo4j - a WSMO API and Reference Implementation
 3   
 4    Copyright (c) 2004-2005, OntoText Lab. / SIRMA
 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   
 19    package com.ontotext.wsmo4j.ontology;
 20   
 21    /**
 22    * <p>Title: WSMO4J</p>
 23    * <p>Description: WSMO API and a Reference Implementation</p>
 24    * <p>Copyright: Copyright (c) 2004-2005</p>
 25    * <p>Company: OntoText Lab. / SIRMA </p>
 26    * @author not attributable
 27    * @version 1.0
 28    *
 29    */
 30    import java.util.Collections;
 31    import java.util.LinkedHashSet;
 32    import java.util.Set;
 33   
 34    import org.omwg.ontology.Attribute;
 35    import org.omwg.ontology.Concept;
 36    import org.omwg.ontology.Type;
 37    import org.wsmo.common.Identifier;
 38    import org.wsmo.common.exception.InvalidModelException;
 39    import org.wsmo.common.exception.SynchronisationException;
 40   
 41    import com.ontotext.wsmo4j.common.EntityImpl;
 42   
 43   
 44    public class AttributeImpl extends EntityImpl
 45    implements Attribute {
 46   
 47    private Concept domain;
 48   
 49    private LinkedHashSet <Type> ranges;
 50   
 51    private int minCardinality = 0;
 52   
 53    private int maxCardinality = Integer.MAX_VALUE;
 54   
 55    private boolean constraining = false,
 56    reflexive = false,
 57    symmetric = false,
 58    transitive = false;
 59   
 60    private Identifier inverseAttribute = null;
 61   
 62  0 public AttributeImpl(Identifier thisID, Concept domain) {
 63  0 super(thisID);
 64  0 this.domain = domain;
 65   
 66  0 ranges = new LinkedHashSet <Type> ();
 67    }
 68   
 69  0 public Concept getConcept() throws SynchronisationException {
 70  0 return this.domain;
 71    }
 72   
 73  0 public void removeFromConcept() throws InvalidModelException {
 74  0 if (domain == null)
 75  0 return;
 76  0 Concept old = domain;
 77  0 domain = null;
 78  0 old.removeAttribute(this);
 79    }
 80   
 81  0 public boolean isConstraining() {
 82  0 return constraining;
 83    }
 84   
 85  0 public void setConstraining(boolean constraining) {
 86  0 this.constraining = constraining;
 87    }
 88   
 89  0 public int getMinCardinality() {
 90  0 return this.minCardinality;
 91    }
 92   
 93  0 public void setMinCardinality(int min) {
 94  0 this.minCardinality = min;
 95    }
 96   
 97  0 public int getMaxCardinality() {
 98  0 return this.maxCardinality;
 99    }
 100   
 101  0 public void setMaxCardinality(int max) {
 102  0 this.maxCardinality = max;
 103    }
 104   
 105  0 public Set <Type> listTypes() {
 106  0 return Collections.unmodifiableSet(ranges);
 107    }
 108   
 109  0 public void addType(Type type) throws InvalidModelException {
 110  0 if (type == null) {
 111  0 throw new IllegalArgumentException();
 112    }
 113  0 ranges.add(type);
 114    }
 115   
 116  0 public void removeType(Type type) throws InvalidModelException {
 117  0 if (type == null) {
 118  0 throw new IllegalArgumentException();
 119    }
 120  0 ranges.remove(type);
 121    }
 122   
 123  0 public boolean isReflexive() {
 124  0 return this.reflexive;
 125    }
 126   
 127  0 public void setReflexive(boolean reflexive) {
 128  0 this.reflexive = reflexive;
 129    }
 130   
 131  0 public boolean isSymmetric() {
 132  0 return symmetric;
 133    }
 134   
 135  0 public void setSymmetric(boolean symmetric) {
 136  0 this.symmetric = symmetric;
 137    }
 138   
 139  0 public boolean isTransitive() {
 140  0 return this.transitive;
 141    }
 142   
 143  0 public void setTransitive(boolean trans) {
 144  0 this.transitive = trans;
 145    }
 146   
 147  0 public Identifier getInverseOf() {
 148  0 return this.inverseAttribute;
 149    }
 150   
 151  0 public void setInverseOf(Identifier id) {
 152  0 this.inverseAttribute = id;
 153    }
 154   
 155  0 public boolean equals(Object object) {
 156  0 if (object == this) {
 157  0 return true; // instance match
 158    }
 159  0 if (object == null
 160    || false == object instanceof Attribute) {
 161  0 return false;
 162    }
 163  0 Attribute anotherAttr = (Attribute)object;
 164  0 if (getConcept() == null) {
 165  0 if (anotherAttr.getConcept() != null) {
 166  0 return false;
 167    }
 168    }
 169    else {
 170  0 if (!getConcept().equals(anotherAttr.getConcept())) {
 171  0 return false;
 172    }
 173    }
 174  0 return super.equals(object);
 175    }
 176   
 177    }
 178   
 179    /*
 180    * $Log$
 181    * Revision 1.32 2007/04/02 12:13:21 morcen
 182    * Generics support added to wsmo-api, wsmo4j and wsmo-test
 183    *
 184    * Revision 1.31 2006/11/17 10:52:41 vassil_momtchev
 185    * conceptImpl now uses attributeImpl, when attribute is removed to reset the domain of the attribute
 186    *
 187    * Revision 1.30 2006/08/07 10:53:00 vassil_momtchev
 188    * getConcept() method checks if this attribute instance was already removed from the Concept
 189    *
 190    * Revision 1.29 2006/03/23 16:12:13 nathaliest
 191    * moving the anon Id check to the validator
 192    *
 193    * Revision 1.28 2006/02/16 09:56:50 vassil_momtchev
 194    * setInverseOf(Attribute) changed to setInverseOf(Identifier)
 195    *
 196    * Revision 1.27 2006/02/13 11:49:58 nathaliest
 197    * changed anonId-check error String
 198    *
 199    * Revision 1.26 2006/02/13 09:21:21 nathaliest
 200    * added AnonIds Check
 201    *
 202    * Revision 1.25 2005/09/26 13:04:39 vassil_momtchev
 203    * setInverseOf is symmetric now
 204    *
 205    * Revision 1.24 2005/09/15 09:51:51 vassil_momtchev
 206    * changes from today are discarded
 207    *
 208    * Revision 1.22 2005/09/13 11:15:54 vassil_momtchev
 209    * removed method self call (stack overflow)
 210    *
 211    * Revision 1.21 2005/09/13 11:12:21 vassil_momtchev
 212    * switch back setInverseOf to not be symmetric (proxy problem)
 213    *
 214    * Revision 1.20 2005/09/13 09:53:44 alex_simov
 215    * bugfix in setInverseOf() - null argument is now supported
 216    *
 217    * Revision 1.19 2005/09/12 12:23:11 vassil_momtchev
 218    * setInverseOf changed to be symetric for both attributes
 219    *
 220    * Revision 1.18 2005/07/05 12:46:17 alex_simov
 221    * attributes refactored
 222    *
 223    * Revision 1.17 2005/06/22 09:16:05 alex_simov
 224    * Simplified equals() method. Identity strongly relies on identifier string
 225    *
 226    * Revision 1.16 2005/06/01 12:09:33 marin_dimitrov
 227    * v0.4.0
 228    *
 229    * Revision 1.3 2005/05/17 12:04:57 alex
 230    * Collections.unmodifiableSet() used instead of new set construction
 231    *
 232    * Revision 1.2 2005/05/12 12:06:36 alex
 233    * addType()/removeType() now throw InvalidModelException
 234    *
 235    * Revision 1.1 2005/05/12 09:45:49 alex
 236    * initial commit
 237    *
 238    */