Clover coverage report - Apache Addressing - 1.0
Coverage timestamp: Tue Mar 22 2005 07:59:24 EST
file stats: LOC: 73   Methods: 3
NCLOC: 39   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
TextExtractor.java 58.3% 83.3% 100% 75.8%
coverage coverage
 1   
 /*
 2   
  * Copyright  1999-2004 The Apache Software Foundation.
 3   
  *
 4   
  *  Licensed under the Apache License, Version 2.0 (the "License");
 5   
  *  you may not use this file except in compliance with the License.
 6   
  *  You may obtain a copy of the License at
 7   
  *
 8   
  *      http://www.apache.org/licenses/LICENSE-2.0
 9   
  *
 10   
  *  Unless required by applicable law or agreed to in writing, software
 11   
  *  distributed under the License is distributed on an "AS IS" BASIS,
 12   
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13   
  *  See the License for the specific language governing permissions and
 14   
  *  limitations under the License.
 15   
  *
 16   
  */
 17   
 
 18   
 package org.apache.axis.message.addressing.util;
 19   
 
 20   
 import javax.xml.soap.SOAPElement;
 21   
 
 22   
 import javax.xml.namespace.QName;
 23   
 
 24   
 import org.w3c.dom.Document;
 25   
 import org.w3c.dom.Element;
 26   
 import org.w3c.dom.Node;
 27   
 import org.w3c.dom.NodeList;
 28   
 import org.w3c.dom.Text;
 29   
 
 30   
 /**
 31   
  * Class TextExtractor
 32   
  * 
 33   
  * @author Davanum Srinivas (dims@yahoo.com)
 34   
  */
 35   
 public class TextExtractor {
 36   
 
 37  8
     public static QName getQName(String value, SOAPElement elem) {
 38  8
         int p = value.indexOf(':');
 39  8
         String prefix = (p == -1) ? "" : value.substring(0, p);
 40  8
         String ns = elem.getNamespaceURI(prefix);
 41  8
         return new QName(ns, value.substring(p+1));
 42   
     }
 43   
 
 44  3
     public static String getText(Node node) {
 45  3
         if (node == null) {
 46  0
             return "";
 47   
         }
 48   
 
 49  3
         if (node instanceof Text) {
 50  0
             return node.getNodeValue().trim();
 51   
         }
 52   
 
 53  3
         StringBuffer result = new StringBuffer();
 54  3
         NodeList list = node.getChildNodes();
 55  3
         for (int i=0;i<list.getLength();i++) {
 56  3
             Node child = list.item(i);
 57  3
             if (child instanceof Text) {
 58  3
                 result.append(child.getNodeValue());
 59   
             } else {
 60   
                 // until first non text node
 61  0
                 break;
 62   
             }
 63   
         }
 64  3
         return result.toString().trim();
 65   
     }
 66   
 
 67  108
     public static String getText(SOAPElement element) {
 68  108
         String value = element.getValue();
 69  108
         return (value == null) ? "" : value.trim();
 70   
     }
 71   
     
 72   
 }
 73