Coverage Report - org.simpleframework.xml.stream.NodeMap
 
Classes in this File Line Coverage Branch Coverage Complexity
NodeMap
N/A
N/A
1
 
 1  
 /*
 2  
  * NodeMap.java July 2006
 3  
  *
 4  
  * Copyright (C) 2006, 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>NodeMap</code> object represents a map of nodes that
 25  
  * can be set as name value pairs. This typically represents the
 26  
  * attributes that belong to an element and is used as an neutral
 27  
  * way to access an element for either an input or output event.
 28  
  *
 29  
  * @author Niall Gallagher
 30  
  *
 31  
  * @see org.simpleframework.xml.stream.Node
 32  
  */ 
 33  
 public interface NodeMap<T extends Node> extends Iterable<String> {
 34  
     
 35  
     /**
 36  
      * This is used to acquire the actual node this map represents.
 37  
      * The source node provides further details on the context of
 38  
      * the node, such as the parent name, the namespace, and even
 39  
      * the value in the node. Care should be taken when using this. 
 40  
      * 
 41  
      * @return this returns the node that this map represents
 42  
      */
 43  
     T getNode();
 44  
 
 45  
    /**
 46  
     * This is used to get the name of the element that owns the
 47  
     * nodes for the specified map. This can be used to determine
 48  
     * which element the node map belongs to.
 49  
     * 
 50  
     * @return this returns the name of the owning element
 51  
     */         
 52  
    String getName();        
 53  
 
 54  
    /**
 55  
     * This is used to acquire the <code>Node</code> mapped to the
 56  
     * given name. This returns a name value pair that represents
 57  
     * either an attribute or element. If no node is mapped to the
 58  
     * specified name then this method will return null.
 59  
     *
 60  
     * @param name this is the name of the node to retrieve
 61  
     * 
 62  
     * @return this will return the node mapped to the given name
 63  
     */         
 64  
    T get(String name);        
 65  
 
 66  
    /**
 67  
     * This is used to remove the <code>Node</code> mapped to the
 68  
     * given name.  This returns a name value pair that represents
 69  
     * either an attribute or element. If no node is mapped to the
 70  
     * specified name then this method will return null.
 71  
     *
 72  
     * @param name this is the name of the node to remove
 73  
     * 
 74  
     * @return this will return the node mapped to the given name
 75  
     */ 
 76  
    T remove(String name);
 77  
    
 78  
    /**
 79  
     * This returns an iterator for the names of all the nodes in
 80  
     * this <code>NodeMap</code>. This allows the names to be 
 81  
     * iterated within a for each loop in order to extract nodes.
 82  
     *
 83  
     * @return this returns the names of the nodes in the map
 84  
     */ 
 85  
    Iterator<String> iterator();
 86  
 
 87  
    /**
 88  
     * This is used to add a new <code>Node</code> to the map. The
 89  
     * type of node that is created an added is left up to the map
 90  
     * implementation. Once a node is created with the name value
 91  
     * pair it can be retrieved and used.
 92  
     *
 93  
     * @param name this is the name of the node to be created
 94  
     * @param value this is the value to be given to the node
 95  
     * 
 96  
     * @return this is the node that has been added to the map
 97  
     */ 
 98  
    T put(String name, String value);
 99  
 }