Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 77   Methods: 5
NCLOC: 57   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
NamespaceContext.java 90% 92,3% 80% 90,2%
 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.parser;
 11   
 
 12   
 import java.util.Collection;
 13   
 import java.util.Collections;
 14   
 import java.util.HashMap;
 15   
 import java.util.Iterator;
 16   
 import java.util.Map;
 17   
 import java.util.Stack;
 18   
 
 19   
 import org.jbind.xml.base.INamespaces;
 20   
 import org.jbind.xml.base.PrefixDeclaration;
 21   
 
 22   
 public class NamespaceContext implements INamespaceContext {
 23   
 
 24   
   private Stack myMaps = null;
 25   
   private Stack myAddedDeclarations = null;
 26   
 
 27  467
   public NamespaceContext() {
 28  467
     myMaps = new Stack();
 29  467
     HashMap m = new HashMap(13);
 30  467
     m.put("xml", INamespaces.XML);
 31  467
     m.put("", INamespaces.NO);
 32  467
     myMaps.push(m);
 33  467
     myAddedDeclarations = new Stack();
 34  467
     myAddedDeclarations.push(Collections.EMPTY_LIST);
 35   
   }
 36   
 
 37  21344
   public Map getCurrentMapping() {
 38  21344
     return (Map)myMaps.peek();
 39   
   }
 40   
 
 41  0
   public Collection getAddedPrefixDeclarations() {
 42  0
     return (Collection)myAddedDeclarations.peek();
 43   
   }
 44   
 
 45  8676
   public void popContext() {
 46  8676
     myMaps.pop();
 47  8676
     myAddedDeclarations.pop();
 48   
   }
 49   
 
 50  8676
   public void pushContext(Collection aPrefixDeclarations) {
 51  8676
     if (null == aPrefixDeclarations) {
 52  8193
       aPrefixDeclarations = Collections.EMPTY_LIST;
 53   
     }
 54  8676
     Map m = null;
 55  8676
     if (aPrefixDeclarations.size() > 0) {
 56  483
       m = new HashMap((Map)myMaps.peek());
 57  483
       for (Iterator i = aPrefixDeclarations.iterator(); i.hasNext(); ) {
 58  908
         PrefixDeclaration pd = (PrefixDeclaration)i.next();
 59  908
         if ("".equals(pd.namespace)) {
 60  2
           if ("".equals(pd.prefix)) {
 61  2
             m.put("", INamespaces.NO);
 62   
           } else {
 63  0
             m.remove(pd.prefix);
 64   
           }
 65   
         } else {
 66  906
           m.put(pd.prefix, pd.namespace);
 67   
         }
 68   
       }
 69   
     } else {
 70  8193
       m = (Map)myMaps.peek();
 71   
     }
 72  8676
     myMaps.push(m);
 73  8676
     myAddedDeclarations.push(aPrefixDeclarations);
 74   
   }
 75   
 
 76   
 }
 77