Coverage Report - org.simpleframework.xml.stream.EventNode
 
Classes in this File Line Coverage Branch Coverage Complexity
EventNode
N/A
N/A
1
 
 1  
 /*
 2  
  * EventNode.java January 2010
 3  
  *
 4  
  * Copyright (C) 2010, 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  
 /**
 22  
  * The <code>EventNode</code> object is used to represent an event
 23  
  * that has been extracted from the XML document. Events provide a
 24  
  * framework neutral way to represent a token from the source XML.
 25  
  * It provides the name and value of the event, if applicable, and
 26  
  * also provides namespace information. Some nodes will have 
 27  
  * associated <code>Attribute</code> objects, typically these will 
 28  
  * be the XML element events. Also, if available, the event will 
 29  
  * provide the line number the event was encountered in the XML.
 30  
  * 
 31  
  * @author Niall Gallagher
 32  
  *
 33  
  * @see org.simpleframework.xml.stream.EventReader
 34  
  */
 35  
 interface EventNode extends Iterable<Attribute> {
 36  
    
 37  
    /**
 38  
     * This is used to provide the line number the XML event was
 39  
     * encountered at within the XML document. If there is no line
 40  
     * number available for the node then this will return a -1.
 41  
     * 
 42  
     * @return this returns the line number if it is available
 43  
     */
 44  
    int getLine();
 45  
    
 46  
    /**
 47  
     * This provides the name of the event. Typically this will be
 48  
     * the name of an XML element if the event represents an element.
 49  
     * If however the event represents a text token or an element
 50  
     * close token then this method may return null for the name.
 51  
     * 
 52  
     * @return this returns the name of this event or null
 53  
     */
 54  
    String getName();
 55  
    
 56  
    /**
 57  
     * This returns the value of the event. Typically this will be
 58  
     * the text value that the token contains. If the event does 
 59  
     * not contain a value then this returns null. Only text events
 60  
     * are required to produce a value via this methods. 
 61  
     * 
 62  
     * @return this returns the value represented by this event
 63  
     */
 64  
    String getValue();
 65  
    
 66  
    /**
 67  
     * This is used to acquire the namespace reference that this 
 68  
     * node is in. A namespace is normally associated with an XML
 69  
     * element or attribute, so text events and element close events
 70  
     * are not required to contain any namespace references. 
 71  
     * 
 72  
     * @return this will provide the associated namespace reference
 73  
     */
 74  
    String getReference();
 75  
    
 76  
    /**
 77  
     * This is used to acquire the namespace prefix associated with
 78  
     * this node. A prefix is used to qualify an XML element or
 79  
     * attribute within a namespace. So, if this represents a text
 80  
     * event then a namespace prefix is not required.
 81  
     * 
 82  
     * @return this returns the namespace prefix for this event
 83  
     */
 84  
    String getPrefix();
 85  
    
 86  
    /**
 87  
     * This is used to return the source of the event. Depending on
 88  
     * which provider was selected to parse the XML document an
 89  
     * object for the internal parsers representation of the event
 90  
     * will be returned. This is useful for debugging purposes.
 91  
     * 
 92  
     * @return this will return the source object for this event
 93  
     */
 94  
    Object getSource();
 95  
    
 96  
    /**
 97  
     * This is true when the node represents an element close. Such
 98  
     * events are required by the core reader to determine if a 
 99  
     * node is still in context. This helps to determine if there
 100  
     * are any more children to be read from a specific node.
 101  
     * 
 102  
     * @return this returns true if the event is an element close
 103  
     */
 104  
    boolean isEnd();
 105  
    
 106  
    /**
 107  
     * This is true when the node represents a new element. This is
 108  
     * the core event type as it contains the element name and any
 109  
     * associated attributes. The core reader uses this to compose
 110  
     * the input nodes that are produced.
 111  
     * 
 112  
     * @return this returns true if the event represents an element
 113  
     */
 114  
    boolean isStart();
 115  
  
 116  
    /**
 117  
     * This is true when the node represents a text token. Text 
 118  
     * tokens are required to provide a value only. So namespace
 119  
     * details and the node name will typically return null.
 120  
     *  
 121  
     * @return this returns true if this represents text  
 122  
     */
 123  
    boolean isText();
 124  
 }