Clover coverage report - Convert - proto0
Coverage timestamp: Mo Nov 22 2004 13:19:16 CET
file stats: LOC: 59   Methods: 5
NCLOC: 33   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ArrayToArrayListConverter.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.List;
 25   
 26    /**
 27    * @author Ronald Blaschke
 28    */
 29    public class ArrayToArrayListConverter extends AbstractConverter {
 30    private final Type sourceCType, destinationCType;
 31    private final MetaConverter cConverter;
 32   
 33  44 public ArrayToArrayListConverter(final Type sourceCType, final Type destinationCType, final MetaConverter cConverter) {
 34  44 this.sourceCType = sourceCType;
 35  44 this.destinationCType = destinationCType;
 36  44 this.cConverter = cConverter;
 37    }
 38   
 39  391 public Type getSourceType() {
 40  391 return Types.findPTypeByType(Types.primitiveArrayType(), sourceCType);
 41    }
 42   
 43  391 public Type getDestinationType() {
 44  391 return Types.findPTypeByType(Types.findTypeByClass(ArrayList.class), destinationCType);
 45    }
 46   
 47  44 public int getWeight() {
 48  44 return 100;
 49    }
 50   
 51  1 public Object convert(final Object obj) throws Exception {
 52  1 final Object[] array = (Object[]) obj;
 53  1 final List l = new ArrayList(array.length);
 54  1 for (int i = 0; i < array.length; ++i) {
 55  1 l.add(cConverter.getConverter().convert(array[i]));
 56    }
 57  1 return l;
 58    }
 59    }