Coverage Report - org.apache.myfaces.view.facelets.compiler.NamespaceManager
 
Classes in this File Line Coverage Branch Coverage Complexity
NamespaceManager
0%
0/28
0%
0/12
2
NamespaceManager$NS
0%
0/4
N/A
2
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.myfaces.view.facelets.compiler;
 20  
 
 21  
 import java.util.ArrayList;
 22  
 import java.util.List;
 23  
 
 24  
 import org.apache.myfaces.view.facelets.tag.TagLibrary;
 25  
 
 26  
 /**
 27  
  * @author Jacob Hookom
 28  
  * @version $Id$
 29  
  */
 30  
 final class NamespaceManager
 31  
 {
 32  
 
 33  
     private final static class NS
 34  
     {
 35  
         public final String prefix;
 36  
 
 37  
         public final String namespace;
 38  
 
 39  
         public NS(String prefix, String ns)
 40  0
         {
 41  0
             this.prefix = prefix;
 42  0
             this.namespace = ns;
 43  0
         }
 44  
     }
 45  
 
 46  
     private final List<NS> namespaces;
 47  
 
 48  
     /**
 49  
      * 
 50  
      */
 51  
     public NamespaceManager()
 52  0
     {
 53  0
         this.namespaces = new ArrayList<NS>();
 54  0
     }
 55  
 
 56  
     public void reset()
 57  
     {
 58  0
         this.namespaces.clear();
 59  0
     }
 60  
 
 61  
     public void pushNamespace(String prefix, String namespace)
 62  
     {
 63  0
         NS ns = new NS(prefix, namespace);
 64  0
         this.namespaces.add(0, ns);
 65  0
     }
 66  
 
 67  
     public String getNamespace(String prefix)
 68  
     {
 69  0
         NS ns = null;
 70  0
         for (int i = 0; i < this.namespaces.size(); i++)
 71  
         {
 72  0
             ns = (NS) this.namespaces.get(i);
 73  0
             if (ns.prefix.equals(prefix))
 74  
             {
 75  0
                 return ns.namespace;
 76  
             }
 77  
         }
 78  0
         return null;
 79  
     }
 80  
 
 81  
     public void popNamespace(String prefix)
 82  
     {
 83  0
         NS ns = null;
 84  0
         for (int i = 0; i < this.namespaces.size(); i++)
 85  
         {
 86  0
             ns = (NS) this.namespaces.get(i);
 87  0
             if (ns.prefix.equals(prefix))
 88  
             {
 89  0
                 this.namespaces.remove(i);
 90  0
                 return;
 91  
             }
 92  
         }
 93  0
     }
 94  
 
 95  
     public NamespaceUnit toNamespaceUnit(TagLibrary library)
 96  
     {
 97  0
         NamespaceUnit unit = new NamespaceUnit(library);
 98  0
         if (this.namespaces.size() > 0)
 99  
         {
 100  0
             NS ns = null;
 101  0
             for (int i = this.namespaces.size() - 1; i >= 0; i--)
 102  
             {
 103  0
                 ns = this.namespaces.get(i);
 104  0
                 unit.setNamespace(ns.prefix, ns.namespace);
 105  
             }
 106  
         }
 107  0
         return unit;
 108  
     }
 109  
 
 110  
 }