Clover coverage report - ActiveSOAP - 1.0-SNAPSHOT
Coverage timestamp: Wed May 18 2005 17:30:15 BST
file stats: LOC: 113   Methods: 6
NCLOC: 76   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
DocumentFilterXMLStreamReader.java 63.6% 67.6% 66.7% 66.1%
coverage coverage
 1   
 /** 
 2   
  * 
 3   
  * Copyright 2004 Protique Ltd
 4   
  * 
 5   
  * Licensed under the Apache License, Version 2.0 (the "License"); 
 6   
  * you may not use this file except in compliance with the License. 
 7   
  * You may obtain a copy of the License at 
 8   
  * 
 9   
  * http://www.apache.org/licenses/LICENSE-2.0
 10   
  * 
 11   
  * Unless required by applicable law or agreed to in writing, software
 12   
  * distributed under the License is distributed on an "AS IS" BASIS, 
 13   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 14   
  * See the License for the specific language governing permissions and 
 15   
  * limitations under the License. 
 16   
  * 
 17   
  **/
 18   
 package org.codehaus.activesoap.util;
 19   
 
 20   
 import javax.xml.namespace.QName;
 21   
 import javax.xml.stream.XMLStreamConstants;
 22   
 import javax.xml.stream.XMLStreamException;
 23   
 import javax.xml.stream.XMLStreamReader;
 24   
 import javax.xml.stream.util.StreamReaderDelegate;
 25   
 
 26   
 /**
 27   
  * An {@link StreamReaderDelegate} which creates a logical sub-document
 28   
  * from a stream until a certain close element is discovered - such as for making
 29   
  * the contents of a SOAP body appear as a logical XML document.
 30   
  *
 31   
  * @version $Revision: 1.5 $
 32   
  */
 33   
 public class DocumentFilterXMLStreamReader extends StreamReaderDelegate implements XMLStreamConstants {
 34   
     boolean first = true;
 35   
     boolean finished = false;
 36   
     private final QName name;
 37   
     private boolean second;
 38   
 
 39  88
     public DocumentFilterXMLStreamReader(QName name, XMLStreamReader in) {
 40  88
         super(in);
 41  88
         this.name = name;
 42   
     }
 43   
 
 44  0
     public void disableStartDocumentEvent() {
 45  0
         first = false;
 46   
     }
 47   
 
 48  837
     public boolean hasNext() throws XMLStreamException {
 49  837
         if (first) {
 50  40
             return true;
 51   
         }
 52  797
         else if (finished) {
 53  57
             return false;
 54   
         }
 55  740
         return super.hasNext();
 56   
     }
 57   
 
 58  975
     public int next() throws XMLStreamException {
 59  975
         if (first) {
 60  86
             first = false;
 61  86
             second = true;
 62  86
             return START_DOCUMENT;
 63   
         }
 64  889
         else if (second) {
 65  86
             second = false;
 66  86
             return super.getEventType();
 67   
         }
 68  803
         else if (finished) {
 69  0
             return END_DOCUMENT;
 70   
         }
 71   
         else {
 72  803
             int answer = super.next();
 73   
             // TODO : to avoid bug in RI disable this line
 74   
             //if (answer == END_ELEMENT && name.equals(getName())) {
 75  803
             if (answer == END_ELEMENT && name.getLocalPart().equals(getLocalName()) && name.getNamespaceURI().equals(getNamespaceURI())) {
 76  85
                 finished = true;
 77   
             }
 78  803
             return answer;
 79   
         }
 80   
     }
 81   
 
 82  0
     public int nextTag() throws XMLStreamException {
 83  0
         int eventType = next();
 84  0
         if (eventType == START_DOCUMENT) {
 85  0
             eventType = next();     
 86   
         }
 87  0
         while ((eventType == CHARACTERS && isWhiteSpace()) // skip whitespace
 88   
                 || (eventType == CDATA && isWhiteSpace())
 89   
                 // skip whitespace
 90   
                 || eventType == SPACE
 91   
                 || eventType == PROCESSING_INSTRUCTION
 92   
                 || eventType == COMMENT
 93   
                 ) {
 94  0
             eventType = next();
 95   
         }
 96  0
         if (eventType != START_ELEMENT && eventType != END_ELEMENT) {
 97  0
             throw new XMLStreamException("expected start or end tag but got type: " + eventType, getLocation());
 98   
         }
 99  0
         return eventType;
 100   
     }
 101   
 
 102  107
     public int getEventType() {
 103  107
         if (first) {
 104  70
             return START_DOCUMENT;
 105   
         }
 106  37
         else if (finished) {
 107  0
             return END_DOCUMENT;
 108   
         }
 109  37
         return super.getEventType();
 110   
     }
 111   
 }
 112   
 
 113