Coverage Report - org.apache.commons.betwixt.schema.LocalComplexType

Classes in this File Line Coverage Branch Coverage Complexity
LocalComplexType
33% 
30% 
2.286

 1  
 /*
 2  
  * Copyright 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  
 package org.apache.commons.betwixt.schema;
 18  
 
 19  
 import java.beans.IntrospectionException;
 20  
 import java.util.Collection;
 21  
 import java.util.Iterator;
 22  
 
 23  
 import org.apache.commons.betwixt.ElementDescriptor;
 24  
 
 25  
 /**
 26  
  * Models a local <code>complexType</code> definition.
 27  
  * @author <a href='http://jakarta.apache.org/'>Apache Commons Team</a>
 28  
  * @version $Revision: 397648 $
 29  
  */
 30  
 public class LocalComplexType extends ComplexType {
 31  
 
 32  
 
 33  0
     public LocalComplexType() {}
 34  
 
 35  
     public LocalComplexType(TranscriptionConfiguration configuration, ElementDescriptor elementDescriptor, Schema schema) throws IntrospectionException {
 36  65
         super(configuration, elementDescriptor, schema);   
 37  65
     }
 38  
 
 39  
     public boolean equals(Object obj) {
 40  676
           boolean result = false;
 41  676
           if (obj instanceof GlobalComplexType) {
 42  156
               GlobalComplexType complexType = (GlobalComplexType) obj;
 43  156
               result =  
 44  156
                         equalContents(attributes, complexType.attributes) &&
 45  0
                         equalContents(elements, complexType.elements);
 46  
                                    
 47  
           }
 48  676
           return result;
 49  
       }
 50  
 
 51  
     
 52  
     private boolean equalContents(Collection one, Collection two)
 53  
     {
 54  
         // doesn't check cardinality but should be ok
 55  156
         if (one.size() != two.size()) {
 56  156
             return false;
 57  
         }
 58  0
         for (Iterator it=one.iterator();it.hasNext();) {
 59  0
             Object object = it.next();
 60  0
             if (!two.contains(object)) {
 61  0
                 return false;
 62  
             }
 63  
         }
 64  0
         return true;
 65  
     }
 66  
 
 67  
     public int hashCode() {
 68  130
         return 0;
 69  
     }
 70  
 
 71  
       /**
 72  
        * Null safe equals method
 73  
        * @param one
 74  
        * @param two
 75  
        * @return
 76  
        */
 77  
       private boolean isEqual(String one, String two) {
 78  0
           boolean result = false;
 79  0
           if (one == null) {
 80  0
               result = (two == null); 
 81  
           }
 82  
           else
 83  
           {
 84  0
               result = one.equals(two);
 85  
           }
 86  
         
 87  0
           return result;
 88  
       }
 89  
       
 90  
       public String toString() {
 91  0
           StringBuffer buffer = new StringBuffer();
 92  0
           buffer.append("<xsd:complexType>");
 93  0
           buffer.append("<xsd:sequence>");
 94  0
           for (Iterator it=elements.iterator(); it.hasNext();) {
 95  0
                 buffer.append(it.next());    
 96  
           }
 97  0
           buffer.append("</xsd:sequence>");
 98  
           
 99  0
           for (Iterator it=attributes.iterator(); it.hasNext();) {
 100  0
                 buffer.append(it.next());    
 101  
           }
 102  0
           buffer.append("</xsd:complexType>");
 103  0
           return buffer.toString();
 104  
       }
 105  
 }