Clover coverage report - Apache Addressing - 1.0
Coverage timestamp: Tue Mar 22 2005 07:59:24 EST
file stats: LOC: 301   Methods: 17
NCLOC: 181   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
ReferencePropertiesType.java 47.5% 57.5% 70.6% 56.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 org.apache.axis.encoding.AnyContentType;
 21   
 import org.apache.axis.message.MessageElement;
 22   
 import org.apache.axis.utils.XMLUtils;
 23   
 
 24   
 import org.apache.commons.logging.Log;
 25   
 import org.apache.commons.logging.LogFactory;
 26   
 
 27   
 import org.w3c.dom.Document;
 28   
 import org.w3c.dom.Element;
 29   
 import org.w3c.dom.Node;
 30   
 import org.w3c.dom.NodeList;
 31   
 
 32   
 import javax.xml.namespace.QName;
 33   
 import javax.xml.soap.SOAPElement;
 34   
 
 35   
 import java.io.Serializable;
 36   
 import java.util.Iterator;
 37   
 
 38   
 /**
 39   
  * Java content class for ReferencePropertiesType complex type.
 40   
  * <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 62)
 41   
  * <p>
 42   
  * <pre>
 43   
  * &lt;complexType name="ReferencePropertiesType">
 44   
  *   &lt;complexContent>
 45   
  *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 46   
  *       &lt;sequence>
 47   
  *         &lt;any/>
 48   
  *       &lt;/sequence>
 49   
  *     &lt;/restriction>
 50   
  *   &lt;/complexContent>
 51   
  * &lt;/complexType>
 52   
  * </pre>
 53   
  * 
 54   
  * @author Davanum Srinivas (dims@yahoo.com)
 55   
  */
 56   
 public class ReferencePropertiesType implements Serializable, AnyContentType { 
 57   
 
 58   
     private static Log log = 
 59   
         LogFactory.getLog(ReferencePropertiesType.class.getName());
 60   
 
 61   
     private MessageElement [] _any;
 62   
 
 63   
     /**
 64   
      * Constructor ReferenceProperties
 65   
      */
 66  117
     public ReferencePropertiesType() {
 67   
     }
 68   
     
 69   
     /**
 70   
      * Constructor ReferenceProperties
 71   
      */
 72  0
     public ReferencePropertiesType(Object element) {
 73  0
         add(element);
 74   
     }
 75   
 
 76   
     /**
 77   
      * Constructor ReferenceProperties (performs shallow copy)
 78   
      * 
 79   
      * @param properties
 80   
      */
 81  0
     public ReferencePropertiesType(ReferencePropertiesType properties) {
 82  0
         this(properties, false);
 83   
     }
 84   
     
 85   
     /**
 86   
      * Constructor ReferenceProperties
 87   
      * 
 88   
      * @param properties
 89   
      * @param deepCopy
 90   
      */
 91  13
     public ReferencePropertiesType(ReferencePropertiesType properties, 
 92   
                                    boolean deepCopy) {
 93  13
         if (properties == null) {
 94  0
             throw new IllegalArgumentException();
 95   
         }
 96  13
         MessageElement elem = null;
 97  13
         for (int i = 0; i < properties.size(); i++) {
 98  4
             elem = properties._any[i];
 99  4
             if (deepCopy) {
 100   
                 // deep copy
 101  1
                 try {
 102  1
                     add(new MessageElement(elem.getAsDOM()));
 103   
                 } catch (Exception e) {
 104   
                     // if failed just copy reference
 105  0
                     add(elem);
 106   
                 }
 107   
             } else {
 108   
                 // shallow copy
 109  3
                 add(elem);
 110   
             }
 111   
         }
 112   
     }
 113   
 
 114  79
     public int size() {
 115  79
         return (this._any == null) ? 0 : this._any.length;
 116   
     }
 117   
 
 118  16
     public Object get(int index) {
 119  16
         return this._any[index];
 120   
     }
 121   
 
 122   
     /**
 123   
      * Get a (single) MessageElement matching the passed QName
 124   
      * @param qname
 125   
      * @return
 126   
      */
 127  0
     public MessageElement get(QName qname) {
 128  0
         for (int i = 0; i < _any.length; i++) {
 129  0
             MessageElement messageElement = _any[i];
 130  0
             if (messageElement.getQName().equals(qname))
 131  0
                 return messageElement;
 132   
         }
 133  0
         return null;
 134   
     }
 135   
 
 136  27
     public void add(Object element) {
 137  27
         MessageElement value = null;
 138  27
         if (element instanceof MessageElement) {
 139  13
             value = (MessageElement)element;
 140  14
         } else if (element instanceof Element) {
 141  14
             value = new MessageElement((Element)element);
 142   
         } else {
 143  0
             throw new IllegalArgumentException();
 144   
         }
 145  27
         MessageElement [] newAny = null;
 146   
 
 147  27
         if (this._any == null) {
 148  20
             this._any = new MessageElement[] {value};
 149   
         } else {
 150  7
             MessageElement [] any = null;
 151  7
             any = new MessageElement[this._any.length + 1];
 152  7
             System.arraycopy(this._any, 0,
 153   
                              any, 0, 
 154   
                              this._any.length);
 155  7
             any[this._any.length] = value;
 156  7
             this._any = any;
 157   
         }
 158   
     }
 159   
 
 160   
     /**
 161   
      * append DOM node to parent
 162   
      * 
 163   
      * @param parent 
 164   
      */
 165  2
     public void append(Element parent, String elementName) {
 166  2
         Document doc = parent.getOwnerDocument();
 167  2
         Element refProp = doc.createElementNS(Constants.NS_URI_ADDRESSING_DEFAULT,
 168   
                                               elementName);
 169  2
         MessageElement [] any = get_any();
 170  2
         if (any != null) {
 171  2
             try {
 172  2
                 for (int i=0;i<any.length;i++) {
 173  2
                     refProp.appendChild(doc.importNode(any[i].getAsDOM(), 
 174   
                                                        true));
 175   
                 }
 176   
             } catch (Exception e) {
 177  0
                 log.debug("", e);
 178   
             }
 179   
         }
 180  2
         parent.appendChild(refProp);
 181   
     }
 182   
 
 183  0
     public static ReferencePropertiesType fromSOAPElement(SOAPElement element)
 184   
         throws Exception {
 185  0
         ReferencePropertiesType props = null;
 186  0
         Iterator iter = element.getChildElements();
 187  0
         while(iter.hasNext()) {
 188  0
             javax.xml.soap.Node child = (javax.xml.soap.Node)iter.next();
 189  0
             if (!(child instanceof SOAPElement)) {
 190  0
                 continue;
 191   
             }
 192  0
             if (props == null) {
 193  0
                 props = new ReferencePropertiesType();
 194   
             }
 195   
 
 196  0
             if (child instanceof MessageElement) {
 197  0
                 props.add( ((MessageElement)child).getAsDOM() );
 198   
             } else {
 199  0
                 props.add(child);
 200   
             }
 201   
         }
 202  0
         return props;
 203   
     }
 204   
 
 205  1
     public static ReferencePropertiesType fromElement(Element element)
 206   
         throws Exception {
 207  1
         ReferencePropertiesType props = null;
 208  1
         NodeList children = element.getChildNodes();
 209  1
         for (int i=0;i<children.getLength();i++) {
 210  1
             Node child = (Node)children.item(i);
 211  1
             if (!(child instanceof Element)) {
 212  0
                 continue;
 213   
             }
 214  1
             if (props == null) {
 215  1
                 props = new ReferencePropertiesType();
 216   
             }
 217   
 
 218  1
             props.add(child);
 219   
         }
 220  1
         return props;
 221   
     }
 222   
 
 223   
     /**
 224   
      * Gets the _any value for this ReferencePropertiesType.
 225   
      * 
 226   
      * @return _any
 227   
      */
 228  17
     public MessageElement [] get_any() {
 229  17
         return _any;
 230   
     }
 231   
     
 232   
     /**
 233   
      * Sets the _any value for this ReferencePropertiesType.
 234   
      * 
 235   
      * @param _any
 236   
      */
 237  5
     public void set_any(MessageElement [] _any) {
 238  5
         this._any = _any;
 239   
     }
 240   
     
 241  0
     public String toString() {
 242  0
         if (this._any == null) {
 243  0
             return "";
 244   
         }
 245  0
         StringBuffer buf = new StringBuffer();
 246  0
         for (int i=0;i<this._any.length;i++) {
 247  0
             buf.append("Reference property[" + i + "]:\n");
 248  0
             try {
 249  0
                 buf.append(XMLUtils.ElementToString(this._any[i].getAsDOM()));
 250   
             } catch (Exception e) {
 251  0
                 buf.append("<error converting: " + e.getMessage() + ">");
 252   
             }
 253  0
             buf.append("\n");
 254   
         }
 255  0
         return buf.toString();
 256   
     }
 257   
 
 258   
     // Type metadata
 259   
     private static org.apache.axis.description.TypeDesc typeDesc =
 260   
         new org.apache.axis.description.TypeDesc(ReferencePropertiesType.class, true);
 261   
     
 262   
     static {
 263  5
         typeDesc.setXmlType(new javax.xml.namespace.QName(Constants.NS_URI_ADDRESSING_DEFAULT, "ReferencePropertiesType"));
 264   
     }
 265   
 
 266   
     /**
 267   
      * Return type metadata object
 268   
      */
 269  1
     public static org.apache.axis.description.TypeDesc getTypeDesc() {
 270  1
         return typeDesc;
 271   
     }
 272   
 
 273   
 
 274   
     /**
 275   
      * Get Custom Serializer
 276   
      */
 277  3
     public static org.apache.axis.encoding.Serializer getSerializer(
 278   
            java.lang.String mechType, 
 279   
            java.lang.Class _javaType,  
 280   
            javax.xml.namespace.QName _xmlType) {
 281  3
         return 
 282   
           new  org.apache.axis.encoding.ser.BeanSerializer(
 283   
             _javaType, _xmlType, typeDesc);
 284   
     }
 285   
 
 286   
     /**
 287   
      * Get Custom Deserializer
 288   
      */
 289  3
     public static org.apache.axis.encoding.Deserializer getDeserializer(
 290   
            java.lang.String mechType, 
 291   
            java.lang.Class _javaType,  
 292   
            javax.xml.namespace.QName _xmlType) {
 293  3
         return 
 294   
           new  org.apache.axis.encoding.ser.BeanDeserializer(
 295   
             _javaType, _xmlType, typeDesc);
 296   
     }
 297   
 
 298   
 }
 299   
 
 300   
 
 301