Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 233   Methods: 19
NCLOC: 120   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
TopEntityImpl.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.common;
 20   
 21   
 22    import java.util.Collections;
 23    import java.util.LinkedHashMap;
 24    import java.util.LinkedHashSet;
 25    import java.util.Set;
 26   
 27    import org.omwg.ontology.Ontology;
 28    import org.wsmo.common.IRI;
 29    import org.wsmo.common.Identifier;
 30    import org.wsmo.common.Namespace;
 31    import org.wsmo.common.TopEntity;
 32   
 33    /**
 34    * <p>Title: WSMO4J</p>
 35    * <p>Description: WSMO API and a Reference Implementation</p>
 36    * <p>Copyright: Copyright (c) 2004-2005</p>
 37    * <p>Company: OntoText Lab. / SIRMA </p>
 38    * @author not attributable
 39    * @version 1.0
 40    *
 41    */
 42    public class TopEntityImpl extends EntityImpl implements TopEntity {
 43   
 44    private String wsmlVariant;
 45   
 46    private Namespace defaultNS;
 47   
 48    private LinkedHashSet <IRI> mediators;
 49   
 50    private LinkedHashMap <String, Namespace> namespaces;
 51   
 52    private LinkedHashMap <Identifier, Ontology> ontologies;
 53   
 54  0 public TopEntityImpl(Identifier id) {
 55  0 super(id);
 56  0 mediators = new LinkedHashSet <IRI>();
 57  0 namespaces = new LinkedHashMap <String, Namespace> ();
 58  0 ontologies = new LinkedHashMap <Identifier, Ontology> ();
 59    }
 60   
 61   
 62  0 public String getWsmlVariant() {
 63    /*
 64    * If variant is not set, you cannot conclude that it's core,
 65    * you need the validator to determine the variant.
 66    */
 67   
 68    // if (this.wsmlVariant == null) {
 69    // return WSML.WSML_CORE;
 70    // }
 71    // else {
 72  0 return this.wsmlVariant;
 73    // }
 74    }
 75   
 76  0 public void setWsmlVariant(String variant) {
 77  0 if (variant != null
 78    && variant.trim().length() == 0) {
 79  0 variant = null;
 80    }
 81  0 this.wsmlVariant = variant;
 82    }
 83   
 84  0 public Set <Namespace> listNamespaces() {
 85  0 return new LinkedHashSet <Namespace>(namespaces.values());
 86    }
 87   
 88  0 public void addNamespace(Namespace ns) {
 89  0 if (ns == null) {
 90  0 throw new IllegalArgumentException();
 91    }
 92  0 namespaces.put(ns.getPrefix(), ns);
 93    }
 94   
 95  0 public void removeNamespace(String prefix) {
 96  0 if (prefix == null) {
 97  0 throw new IllegalArgumentException();
 98    }
 99  0 namespaces.remove(prefix);
 100    }
 101   
 102  0 public void removeNamespace(Namespace ns) {
 103  0 if (ns == null) {
 104  0 throw new IllegalArgumentException();
 105    }
 106  0 removeNamespace(ns.getPrefix());
 107    }
 108   
 109  0 public Namespace findNamespace(String prefix) {
 110  0 if (prefix == null) {
 111  0 throw new IllegalArgumentException();
 112    }
 113  0 return namespaces.get(prefix);
 114    }
 115   
 116  0 public Namespace getDefaultNamespace() {
 117  0 return this.defaultNS;
 118    }
 119   
 120  0 public void setDefaultNamespace(Namespace ns) {
 121  0 this.defaultNS = ns;
 122    }
 123   
 124    /**
 125    * sets a default namespace for the container
 126    * @param iri IRI of namespace to set as default
 127    * @see #setDefaultNamespace(Namespace ns)
 128    */
 129  0 public void setDefaultNamespace(IRI iri) {
 130  0 if (iri == null) {
 131  0 this.defaultNS = null;
 132    }
 133    else {
 134  0 this.defaultNS = new NamespaceImpl("", iri);
 135    }
 136    }
 137   
 138  0 public void addMediator(IRI mediator) {
 139  0 if (mediator == null) {
 140  0 throw new IllegalArgumentException();
 141    }
 142  0 mediators.add(mediator);
 143    }
 144   
 145  0 public void removeMediator(IRI mediator) {
 146  0 if (mediator == null) {
 147  0 throw new IllegalArgumentException();
 148    }
 149  0 mediators.remove(mediator);
 150    }
 151   
 152   
 153  0 public Set <IRI> listMediators() {
 154  0 return Collections.unmodifiableSet(mediators);
 155    }
 156   
 157  0 public void addOntology(Ontology ontology) {
 158  0 if (ontology == null) {
 159  0 throw new IllegalArgumentException();
 160    }
 161  0 ontologies.put(ontology.getIdentifier(), ontology);
 162    }
 163   
 164  0 public void removeOntology(IRI iri) {
 165  0 if (iri == null) {
 166  0 throw new IllegalArgumentException();
 167    }
 168  0 ontologies.remove(iri);
 169    }
 170   
 171  0 public void removeOntology(Ontology ontology) {
 172  0 if (ontology == null) {
 173  0 throw new IllegalArgumentException();
 174    }
 175  0 ontologies.remove(ontology.getIdentifier());
 176    }
 177   
 178  0 public Set <Ontology> listOntologies() {
 179  0 return new LinkedHashSet <Ontology> (ontologies.values());
 180    }
 181   
 182  0 public boolean equals(Object object) {
 183  0 if (object == this) {
 184  0 return true; // instance match
 185    }
 186  0 if (object == null
 187    || false == object instanceof TopEntity) {
 188  0 return false;
 189    }
 190  0 return super.equals(object);
 191    }
 192    }
 193   
 194    /*
 195    * $Log$
 196    * Revision 1.7 2007/04/02 12:13:20 morcen
 197    * Generics support added to wsmo-api, wsmo4j and wsmo-test
 198    *
 199    * Revision 1.6 2006/04/05 13:24:03 vassil_momtchev
 200    * usesMediator now refer mediators by IRI instead of handle to object
 201    *
 202    * Revision 1.5 2005/11/09 12:32:06 alex_simov
 203    * setDefaultNamespace(IRI) did not handle null IRI argument
 204    *
 205    * Revision 1.4 2005/09/14 14:10:03 alex_simov
 206    * setWsmlVariant() allows null argument values
 207    *
 208    * Revision 1.3 2005/09/09 14:57:51 nathaliest
 209    * changed method getWsmlVariant
 210    *
 211    * Revision 1.2 2005/06/22 09:16:05 alex_simov
 212    * Simplified equals() method. Identity strongly relies on identifier string
 213    *
 214    * Revision 1.1 2005/06/01 12:00:32 marin_dimitrov
 215    * v0.4.0
 216    *
 217    * Revision 1.5 2005/05/17 11:16:19 alex
 218    * 'import ... Mediator' added
 219    *
 220    * Revision 1.4 2005/05/17 10:49:52 marin
 221    * 1. added pre-condition on setWsmlVariant
 222    * 2. getWsmlVariant return WSML_CORE by default
 223    *
 224    * Revision 1.3 2005/05/16 08:50:21 alex
 225    * implementation method setDefaultNamespace(IRI) added
 226    *
 227    * Revision 1.2 2005/05/11 13:34:26 alex
 228    * equals() method added
 229    *
 230    * Revision 1.1 2005/05/11 11:50:56 alex
 231    * initial commit
 232    *
 233    */