Clover coverage report - Apache Addressing - 1.0
Coverage timestamp: Tue Mar 22 2005 07:59:24 EST
file stats: LOC: 197   Methods: 12
NCLOC: 91   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
ServiceNameType.java 66.7% 93.9% 83.3% 88.2%
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;
 19   
 
 20   
 import javax.xml.soap.SOAPElement;
 21   
 
 22   
 import org.apache.axis.utils.XMLUtils;
 23   
 import org.apache.axis.encoding.SimpleType;
 24   
 
 25   
 import org.apache.axis.message.addressing.util.TextExtractor;
 26   
 
 27   
 import org.w3c.dom.Attr;
 28   
 import org.w3c.dom.Element;
 29   
 
 30   
 import javax.xml.namespace.QName;
 31   
 
 32   
 /**
 33   
  * Java content class for ServiceNameType complex type.
 34   
  * <p>The following schema fragment specifies the expected content contained within this java content object. (defined at http://schemas.xmlsoap.org/ws/2004/08/addressing line 67)
 35   
  * <p>
 36   
  * <pre>
 37   
  * &lt;complexType name="ServiceNameType">
 38   
  *   &lt;simpleContent>
 39   
  *     &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>QName">
 40   
  *       &lt;attribute name="PortName" type="{http://www.w3.org/2001/XMLSchema}NCName" />
 41   
  *     &lt;/extension>
 42   
  *   &lt;/simpleContent>
 43   
  * &lt;/complexType>
 44   
  * </pre>
 45   
  * 
 46   
  * @author Davanum Srinivas (dims@yahoo.com)
 47   
  */
 48   
 public class ServiceNameType extends AttributedQName 
 49   
     implements SimpleType { // needed to serialize attributes
 50   
     
 51   
     /**
 52   
      * Field port
 53   
      */
 54   
     private String port;
 55   
     
 56  0
     public ServiceNameType(QName qname) {
 57  0
         super(qname);
 58   
     }
 59   
 
 60   
     /**
 61   
      * Constructor ServiceName
 62   
      * 
 63   
      * @param qname 
 64   
      * @param port  
 65   
      */
 66  9
     public ServiceNameType(QName qname, String port) {
 67  9
         super(qname);
 68  9
         this.port = port;
 69   
     }
 70   
 
 71   
     /**
 72   
      * Constructor ServiceName
 73   
      * 
 74   
      * @param namespace
 75   
      * @param localName
 76   
      */
 77  3
     public ServiceNameType(String namespace, 
 78   
                            String localName) {
 79  3
         super(namespace, localName);
 80   
     }
 81   
     
 82   
     /**
 83   
      * Constructor ServiceName
 84   
      * 
 85   
      * @param serviceName
 86   
      */
 87  1
     public ServiceNameType(ServiceNameType serviceName) {
 88  1
         super(serviceName);
 89  1
         this.port = serviceName.getPort();
 90   
     }
 91   
 
 92   
     /**
 93   
      * Method getPort
 94   
      * 
 95   
      * @return 
 96   
      */
 97  13
     public String getPort() {
 98  13
         return port;
 99   
     }
 100   
 
 101   
     /**
 102   
      * Method setPort
 103   
      * 
 104   
      * @param port 
 105   
      */
 106  1
     public void setPort(String port) {
 107  1
         this.port = port;
 108   
     }
 109   
 
 110   
     /**
 111   
      * append DOM node to parent
 112   
      * 
 113   
      * @param parent 
 114   
      */
 115  2
     public void append(Element parent, String elementName) {
 116  2
         Element sn = parent.getOwnerDocument().createElementNS(
 117   
                            Constants.NS_URI_ADDRESSING_DEFAULT,
 118   
                            elementName);
 119  2
         String value = XMLUtils.getStringForQName(this, sn);
 120  2
         sn.appendChild(parent.getOwnerDocument().createTextNode(value));
 121  2
         if (getPort() != null) {
 122  2
             sn.setAttribute(Constants.PORT_NAME, getPort());
 123   
         }
 124  2
         parent.appendChild(sn);
 125   
     }
 126   
 
 127  4
     public static ServiceNameType fromSOAPElement(SOAPElement element) 
 128   
         throws Exception {
 129  4
         String value = TextExtractor.getText(element);
 130  4
         QName qname = TextExtractor.getQName(value, element);
 131  4
         String portName = element.getAttribute(Constants.PORT_NAME);
 132  4
         portName = (portName == null || portName.length() == 0) ? 
 133   
             null : portName;
 134  4
         return new ServiceNameType(qname, portName);
 135   
     }
 136   
 
 137  1
     public static ServiceNameType fromElement(Element element) 
 138   
         throws Exception {
 139  1
         String value = TextExtractor.getText(element);
 140  1
         QName qname = XMLUtils.getQNameFromString(value, element);
 141  1
         String portName = element.getAttribute(Constants.PORT_NAME);
 142  1
         portName = (portName == null || portName.length() == 0) ? 
 143   
             null : portName;
 144  1
         return new ServiceNameType(qname, portName);
 145   
     }
 146   
 
 147   
     // Axis bits to serialize/deserialize the fields correctly
 148   
     
 149   
     // Type metadata
 150   
     private static org.apache.axis.description.TypeDesc typeDesc =
 151   
         new org.apache.axis.description.TypeDesc(ServiceNameType.class, true);
 152   
 
 153   
     static {
 154  4
         typeDesc.setXmlType(new javax.xml.namespace.QName(Constants.NS_URI_ADDRESSING_DEFAULT, "ServiceNameType"));
 155  4
         org.apache.axis.description.AttributeDesc attrField = new org.apache.axis.description.AttributeDesc();
 156  4
         attrField.setFieldName("port");
 157  4
         attrField.setXmlName(new javax.xml.namespace.QName("", "PortName"));
 158  4
         attrField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
 159  4
         typeDesc.addFieldDesc(attrField);
 160   
     }
 161   
 
 162   
     /**
 163   
      * Return type metadata object
 164   
      */
 165  0
     public static org.apache.axis.description.TypeDesc getTypeDesc() {
 166  0
         return typeDesc;
 167   
     }
 168   
 
 169   
 
 170   
     /**
 171   
      * Get Custom Serializer
 172   
      */
 173  1
     public static org.apache.axis.encoding.Serializer getSerializer(
 174   
            java.lang.String mechType, 
 175   
            java.lang.Class _javaType,  
 176   
            javax.xml.namespace.QName _xmlType) {
 177  1
         return 
 178   
           new  org.apache.axis.encoding.ser.SimpleSerializer(
 179   
             _javaType, _xmlType, typeDesc);
 180   
     }
 181   
 
 182   
     /**
 183   
      * Get Custom Deserializer
 184   
      */
 185  2
     public static org.apache.axis.encoding.Deserializer getDeserializer(
 186   
            java.lang.String mechType, 
 187   
            java.lang.Class _javaType,  
 188   
            javax.xml.namespace.QName _xmlType) {
 189  2
         return 
 190   
           new  org.apache.axis.encoding.ser.SimpleDeserializer(
 191   
             _javaType, _xmlType, typeDesc);
 192   
     }
 193   
 
 194   
 }
 195   
 
 196   
 
 197