Clover coverage report - Convert - proto0
Coverage timestamp: Mo Nov 22 2004 13:19:16 CET
file stats: LOC: 62   Methods: 5
NCLOC: 34   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ListConverter.java 100% 100% 100% 100%
coverage
 1    /*
 2    * Copyright 2004 Ronald Blaschke.
 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.rblasch.convert.converters.collections;
 17   
 18    import org.rblasch.convert.MetaConverter;
 19    import org.rblasch.convert.converters.AbstractConverter;
 20    import org.rblasch.convert.type.Type;
 21    import org.rblasch.convert.type.Types;
 22   
 23    import java.util.ArrayList;
 24    import java.util.Iterator;
 25    import java.util.List;
 26   
 27    /**
 28    * @author Ronald Blaschke
 29    */
 30    public class ListConverter extends AbstractConverter {
 31    private final Type sourceCType, destinationCType;
 32    private final MetaConverter cConverter;
 33   
 34  188 public ListConverter(final Type sourceCType, final Type destinationCType, final MetaConverter cConverter) {
 35  188 this.sourceCType = sourceCType;
 36  188 this.destinationCType = destinationCType;
 37  188 this.cConverter = cConverter;
 38    }
 39   
 40  1619 public Type getSourceType() {
 41  1619 return Types.findPTypeByType(Types.findTypeByClass(List.class), sourceCType);
 42    }
 43   
 44  1619 public Type getDestinationType() {
 45  1619 return Types.findPTypeByType(Types.findTypeByClass(ArrayList.class), destinationCType);
 46    }
 47   
 48  188 public int getWeight() {
 49  188 return 100;
 50    }
 51   
 52  3 public Object convert(final Object obj) throws Exception {
 53  3 final List in = (List) obj;
 54   
 55  3 final List out = new ArrayList(in.size());
 56  3 for (final Iterator i = in.iterator(); i.hasNext();) {
 57  5 out.add(cConverter.getConverter().convert(i.next()));
 58    }
 59   
 60  3 return out;
 61    }
 62    }