Clover coverage report - Convert - proto0
Coverage timestamp: Mo Nov 22 2004 13:19:16 CET
file stats: LOC: 72   Methods: 2
NCLOC: 38   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
JlGraphFactory.java 0% 0% 0% 0%
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;
 17   
 18    import org.rblasch.convert.converters.lang.CastConverter;
 19    import org.rblasch.convert.converters.lang.IdentityConverter;
 20    import org.rblasch.convert.converters.lang.ObjectToStringConverter;
 21    import org.rblasch.convert.graph.Graph;
 22    import org.rblasch.convert.graph.SparseWeightedDirectedGraph;
 23    import org.rblasch.convert.graph.WeightedDirectedGraph;
 24    import org.rblasch.convert.type.ClassType;
 25    import org.rblasch.convert.type.ParameterizableType;
 26    import org.rblasch.convert.type.Type;
 27   
 28    import java.util.Arrays;
 29    import java.util.Iterator;
 30   
 31    /**
 32    * @author Ronald Blaschke
 33    * @deprecated no longer used
 34    */
 35    public class JlGraphFactory {
 36  0 private static void addConnection(final Graph g, final MetaConverter mc) {
 37  0 g.addConnection(new TypeVertex(mc.getSourceType()),
 38    new ConverterEdge(mc, mc.getWeight()),
 39    new TypeVertex(mc.getDestinationType()));
 40    }
 41   
 42  0 public static WeightedDirectedGraph createGraphFor(final Type t) {
 43  0 final WeightedDirectedGraph g = new SparseWeightedDirectedGraph();
 44   
 45    // identity
 46  0 addConnection(g, new IdentityConverter(t));
 47   
 48    // class lookup
 49  0 if (t instanceof ClassType) {
 50  0 final ClassType ct = (ClassType) t;
 51   
 52  0 Class tmp = ct.getTheClass();
 53  0 while (tmp.getSuperclass() != null) {
 54  0 addConnection(g, new CastConverter(tmp, tmp.getSuperclass()));
 55   
 56  0 for (final Iterator i = Arrays.asList(tmp.getInterfaces()).iterator(); i.hasNext();) {
 57  0 final Class iface = (Class) i.next();
 58  0 addConnection(g, new CastConverter(tmp, iface));
 59    }
 60   
 61  0 tmp = tmp.getSuperclass();
 62    }
 63  0 } else if (t instanceof ParameterizableType) {
 64    //TODO: add parameter lookup
 65    }
 66   
 67    // "default" .toString() conversion
 68  0 addConnection(g, new ObjectToStringConverter());
 69   
 70  0 return g;
 71    }
 72    }