Coverage report

| %line | %branch
--- | --- | ---
org.apache.commons.configuration.StrictConfigurationComparator |
100% |
100% |

1 |  |
     /*
2 |  |
      * Copyright 2001-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.configuration;
18 |  |
19 |  |
     import java.util.Iterator;
20 |  |
21 |  |
     /**
22 |  |
      * Strict comparator for configurations.
23 |  |
      *
24 |  |
      * @since 1.0
25 |  |
      *
26 |  |
      * @author <a href="mailto:herve.quiroz@esil.univ-mrs.fr">Herve Quiroz</a>
27 |  |
      * @author <a href="mailto:shapira@mpi.com">Yoav Shapira</a>
28 |  |
      * @version $Revision: 1.3 $, $Date: 2004/06/22 09:56:38 $
29 |  |
      */
30 |  |
     public class StrictConfigurationComparator implements ConfigurationComparator
31 |  |
     {
32 |  |
         /**
33 |  |
          * Create a new strict comparator.
34 |  |
          */
35 |  |
         public StrictConfigurationComparator()
36 | 2 |
         {
37 | 2 |
         }
38 |  |
39 |  |
         /**
40 |  |
          * Compare two configuration objects.
41 |  |
          *
42 |  |
          * @param a the first configuration
43 |  |
          * @param b the second configuration
44 |  |
          * @return true if keys from a are found in b and keys from b are
45 |  |
          *         found in a and for each key in a, the corresponding value
46 |  |
          *         is the sale in for the same key in b
47 |  |
          */
48 |  |
         public boolean compare(Configuration a, Configuration b)
49 |  |
         {
50 | 9 |
             if (a == null && b == class="keyword">null)
51 |  |
             {
52 | 1 |
                 return true;
53 |  |
             }
54 | 8 |
             else if (a == null || b == class="keyword">null)
55 |  |
             {
56 | 2 |
                 return false;
57 |  |
             }
58 |  |
59 | 6 |
             for (Iterator keys = a.getKeys(); keys.hasNext();)
60 |  |
             {
61 | 14 |
                 String key = (String) keys.next();
62 | 14 |
                 Object value = a.getProperty(key);
63 | 14 |
                 if (!value.equals(b.getProperty(key)))
64 |  |
                 {
65 | 1 |
                     return false;
66 |  |
                 }
67 |  |
             }
68 |  |
69 | 5 |
             for (Iterator keys = b.getKeys(); keys.hasNext();)
70 |  |
             {
71 | 14 |
                 String key = (String) keys.next();
72 | 14 |
                 Object value = b.getProperty(key);
73 | 14 |
                 if (!value.equals(a.getProperty(key)))
74 |  |
                 {
75 | 1 |
                     return false;
76 |  |
                 }
77 |  |
             }
78 |  |
79 | 4 |
             return true;
80 |  |
         }
81 |  |
     }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.