Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 94   Methods: 12
NCLOC: 66   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
Schema.java 50% 85,7% 83,3% 82,1%
 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.schema.cmp;
 11   
 
 12   
 import java.util.ArrayList;
 13   
 import java.util.Collection;
 14   
 import java.util.HashMap;
 15   
 import java.util.Iterator;
 16   
 import java.util.Map;
 17   
 
 18   
 import org.jbind.util.collection.FilterIterator;
 19   
 import org.jbind.xml.base.IHasLocation;
 20   
 import org.jbind.xml.base.ILocation;
 21   
 import org.jbind.xml.base.IRef;
 22   
 import org.jbind.xml.base.ISymbolspace;
 23   
 import org.jbind.xml.core.cmp.IComponent;
 24   
 import org.jbind.xml.core.cmp.ISchema;
 25   
 import org.jbind.xml.core.data.IAnyTypeData;
 26   
 import org.jbind.xml.msg.IConstraintViolations;
 27   
 import org.jbind.xml.msg.XmlMessages;
 28   
 
 29   
 public class Schema implements ISchema {
 30   
 
 31   
   private Map myComponents = new HashMap();
 32   
   private String myNamespace = null;
 33   
   private IAnyTypeData myFactory = null;
 34   
   private IHasLocation myHasLocation = null;
 35   
 
 36   
   private Collection myDirectlyImportedSchemas = new ArrayList();
 37   
 
 38  188
   public Schema(String aNamespace, IHasLocation aHasLocation) {
 39  188
     myNamespace = aNamespace;
 40  188
     myHasLocation = aHasLocation;
 41   
   }
 42   
 
 43   
 
 44  14261
   public IComponent getComponent(IRef aGlobalRef) {
 45   
     assert aGlobalRef.getNamespace().equals(getNamespace()) :
 46   
            "component belongs to different namespace";
 47  14261
     return (IComponent)myComponents.get(aGlobalRef);
 48   
   }
 49   
 
 50   
 
 51  1133
   public void setComponent(IComponent aComponent, IConstraintViolations aViolations) {
 52  1133
     IRef r = aComponent.getGlobalRef();
 53   
     assert r.getNamespace().equals(getNamespace()) :
 54   
            "component belongs to different namespace";
 55  1133
     if (null != myComponents.put(r, aComponent)) {
 56  0
       aViolations.add(XmlMessages.componentNotUnique(r, aComponent));
 57   
     }
 58   
   }
 59   
 
 60  582
   public Iterator iterComponents(final ISymbolspace aSymbolSpace) {
 61  582
     return new FilterIterator(myComponents.values().iterator(), new FilterIterator.ICondition() {
 62  3326
       public boolean evaluate(Object anObject) {
 63  3326
         return (null == aSymbolSpace) || aSymbolSpace.equals(((IComponent)anObject).getGlobalRef().getSymbolSpace());
 64   
       }
 65   
     });
 66   
   }
 67   
 
 68  37924
   public String getNamespace() {
 69  37924
     return myNamespace;
 70   
   }
 71   
 
 72  0
   public void validate(IConstraintViolations aViolations) {}
 73   
 
 74  0
   public ILocation getLocation() {
 75  0
     return (null != myHasLocation) ? myHasLocation.getLocation() : null;
 76   
   }
 77   
 
 78  1
   public IAnyTypeData getFactory() {
 79  1
     return myFactory;
 80   
   }
 81  2
   public void setFactory(IAnyTypeData aFactory) {
 82  2
     myFactory = aFactory;
 83   
   }
 84   
 
 85  26
   public synchronized void addImportedSchema(ISchema aSchema) {
 86  26
     myDirectlyImportedSchemas.add(aSchema);
 87   
   }
 88   
 
 89  2
   public Iterator iterImportedSchema() {
 90  2
     return myDirectlyImportedSchemas.iterator();
 91   
   }
 92   
 
 93   
 }
 94