Clover coverage report - PMD - 3.9
Coverage timestamp: Tue Dec 19 2006 09:38:44 EST
file stats: LOC: 83   Methods: 4
NCLOC: 44   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ClassUtil.java 100% 90% 50% 85%
coverage coverage
 1    package net.sourceforge.pmd.util;
 2   
 3    import java.math.BigDecimal;
 4   
 5   
 6    /**
 7    * Various class-related utility methods
 8    *
 9    * @author Brian Remedios
 10    */
 11    public class ClassUtil {
 12   
 13  0 private ClassUtil() {};
 14   
 15    private static final TypeMap primitiveTypesByName = new TypeMap( new Class[] {
 16    int.class,
 17    byte.class,
 18    long.class,
 19    short.class,
 20    float.class,
 21    double.class,
 22    char.class,
 23    boolean.class,
 24    });
 25   
 26    private static final TypeMap typesByNames = new TypeMap( new Class[] {
 27    Integer.class,
 28    Byte.class,
 29    Long.class,
 30    Short.class,
 31    Float.class,
 32    Double.class,
 33    Character.class,
 34    Boolean.class,
 35    BigDecimal.class,
 36    String.class,
 37    Object.class,
 38    });
 39   
 40    /**
 41    * Returns the type(class) for the name specified
 42    * or null if not found.
 43    *
 44    * @param name String
 45    * @return Class
 46    */
 47  0 public static Class getPrimitiveTypeFor(String name) {
 48  0 return primitiveTypesByName.typeFor(name);
 49    }
 50   
 51    /**
 52    * Attempt to determine the actual class given the short name.
 53    *
 54    * @param shortName String
 55    * @return Class
 56    */
 57  11 public static Class getTypeFor(String shortName) {
 58   
 59  11 Class type = typesByNames.typeFor(shortName);
 60  5 if (type != null) return type;
 61   
 62  6 type = primitiveTypesByName.typeFor(shortName);
 63  2 if (type != null) return type;
 64   
 65  4 return CollectionUtil.getCollectionTypeFor(shortName);
 66    }
 67    /**
 68    * Returns the abbreviated name of the type,
 69    * without the package name
 70    *
 71    * @param fullTypeName
 72    * @return String
 73    */
 74   
 75  7456 public static String withoutPackageName(String fullTypeName) {
 76   
 77  7456 int dotPos = fullTypeName.lastIndexOf('.');
 78   
 79  7456 return dotPos > 0 ?
 80    fullTypeName.substring(dotPos+1) :
 81    fullTypeName;
 82    }
 83    }