Coverage Report - org.simpleframework.xml.stream.NamespaceMap
 
Classes in this File Line Coverage Branch Coverage Complexity
NamespaceMap
N/A
N/A
1
 
 1  
 /*
 2  
  * NamespaceMap.java July 2008
 3  
  *
 4  
  * Copyright (C) 2008, Niall Gallagher <niallg@users.sf.net>
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License");
 7  
  * you may not use this file except in compliance with the License.
 8  
  * 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, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 15  
  * implied. See the License for the specific language governing 
 16  
  * permissions and limitations under the License.
 17  
  */
 18  
 
 19  
 package org.simpleframework.xml.stream;
 20  
 
 21  
 import java.util.Iterator;
 22  
 
 23  
 /**
 24  
  * The <code>NamespaceMap</code> object is used store the namespaces
 25  
  * for an element. Each namespace added to this map can be added
 26  
  * with a prefix. A prefix is added only if the associated reference
 27  
  * has not been added to a parent element. If a parent element has
 28  
  * the associated reference, then the parents prefix is the one that
 29  
  * will be returned when requested from this map. 
 30  
  * 
 31  
  * @author Niall Gallagher
 32  
  */
 33  
 public interface NamespaceMap extends Iterable<String> {
 34  
    
 35  
    /**
 36  
     * This is the prefix that is associated with the source element.
 37  
     * If the source element does not contain a namespace reference
 38  
     * then this will return its parents namespace. This ensures 
 39  
     * that if a namespace has been declared its child elements will
 40  
     * inherit its prefix.
 41  
     * 
 42  
     * @return this returns the prefix that is currently in scope
 43  
     */
 44  
    String getPrefix();
 45  
 
 46  
    /**
 47  
     * This acquires the prefix for the specified namespace reference.
 48  
     * If the namespace reference has been set on this node with a
 49  
     * given prefix then that prefix is returned, however if it has
 50  
     * not been set this will search the parent elements to find the
 51  
     * prefix that is in scope for the specified reference.
 52  
     * 
 53  
     * @param reference the reference to find a matching prefix for
 54  
     * 
 55  
     * @return this will return the prefix that is is scope
 56  
     */
 57  
    String getPrefix(String reference);
 58  
    
 59  
    /**
 60  
     * This acquires the namespace reference for the specified prefix.
 61  
     * If the provided prefix has been set on this node with a given
 62  
     * reference then that reference is returned, however if it has
 63  
     * not been set this will search the parent elements to find the
 64  
     * reference that is in scope for the specified reference.
 65  
     * 
 66  
     * @param prefix the prefix to find a matching reference for
 67  
     * 
 68  
     * @return this will return the reference that is is scope
 69  
     */
 70  
    String getReference(String prefix);
 71  
 
 72  
    /**
 73  
     * This returns an iterator for the namespace of all the nodes 
 74  
     * in this <code>NamespaceMap</code>. This allows the namespaces 
 75  
     * to be iterated within a for each loop in order to extract the
 76  
     * prefix values associated with the map.
 77  
     *
 78  
     * @return this returns the namespaces contained in this map
 79  
     */ 
 80  
    Iterator<String> iterator();
 81  
    
 82  
    /**
 83  
     * This is used to add the namespace reference to the namespace
 84  
     * map. If the namespace has been added to a parent node then
 85  
     * this will not add the reference. The prefix added to the map
 86  
     * will be the default namespace, which is an empty prefix.
 87  
     * 
 88  
     * @param reference this is the reference to be added 
 89  
     * 
 90  
     * @return this returns the prefix that has been replaced
 91  
     */
 92  
    String setReference(String reference);
 93  
    
 94  
    /**
 95  
     * This is used to add the namespace reference to the namespace
 96  
     * map. If the namespace has been added to a parent node then
 97  
     * this will not add the reference. 
 98  
     * 
 99  
     * @param reference this is the reference to be added 
 100  
     * @param prefix this is the prefix to be added to the reference
 101  
     * 
 102  
     * @return this returns the prefix that has been replaced
 103  
     */
 104  
    String setReference(String reference, String prefix);
 105  
 }