Clover coverage report - Maven Clover report
Coverage timestamp: Sun Jun 1 2008 20:05:13 EST
file stats: LOC: 58   Methods: 4
NCLOC: 29   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
CollectionReplacer.java - 14.3% 50% 22.2%
coverage coverage
 1    /**
 2    * Copyright 2007 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    package org.codehaus.wadi.aop.tracker.basic;
 17   
 18    import java.util.Arrays;
 19    import java.util.Collection;
 20   
 21    import org.codehaus.wadi.aop.tracker.InstanceTrackerException;
 22   
 23    /**
 24    *
 25    * @version $Revision: 1538 $
 26    */
 27    public class CollectionReplacer extends AbstractReplacer {
 28   
 29  18 public CollectionReplacer(InstanceAndTrackerReplacer parentReplacer) {
 30  18 super(parentReplacer);
 31    }
 32   
 33  112 public boolean canProcess(Object instance) {
 34  112 return instance instanceof Collection;
 35    }
 36   
 37  0 protected Object replace(Object instance, Replacer replacer) {
 38  0 Collection collection = (Collection) instance;
 39  0 Collection newCollection = newCollection(collection);
 40   
 41  0 Object[] instances = collection.toArray();
 42  0 instances = (Object[]) replacer.replace(instances);
 43  0 newCollection.addAll(Arrays.asList(instances));
 44  0 return newCollection;
 45    }
 46   
 47  0 protected Collection newCollection(Collection collection) {
 48  0 Collection newCollection;
 49  0 Class collClass = collection.getClass();
 50  0 try {
 51  0 newCollection = (Collection) collClass.getConstructor().newInstance();
 52    } catch (Exception e) {
 53  0 throw new InstanceTrackerException(e);
 54    }
 55  0 return newCollection;
 56    }
 57   
 58    }