Clover Coverage Report - KS Common Impl 1.2-M4-SNAPSHOT
Coverage timestamp: Wed Jul 20 2011 12:37:18 EDT
../../../../../../../img/srcFileCovDistChart0.png 55% of files have more coverage
23   95   23   11.5
6   86   1   2
2     11.5  
1    
 
  ComplexSubstructuresHelper       Line # 16 23 0% 23 31 0% 0.0
 
No Tests
 
1    package org.kuali.student.common.dictionary.service.impl;
2   
3   
4    import java.beans.BeanInfo;
5    import java.beans.IntrospectionException;
6    import java.beans.Introspector;
7    import java.beans.PropertyDescriptor;
8    import java.lang.reflect.ParameterizedType;
9    import java.util.Date;
10    import java.util.LinkedHashSet;
11    import java.util.List;
12    import java.util.Set;
13   
14    import org.kuali.student.common.dto.MetaInfo;
15   
 
16    public class ComplexSubstructuresHelper
17    {
18   
19   
 
20  0 toggle public Set<String> getComplexStructures (String className)
21    {
22  0 Set<String> complexStructures = new LinkedHashSet<String> ();
23  0 loadComplexStructures (className, complexStructures);
24  0 return complexStructures;
25    }
26   
 
27  0 toggle private void loadComplexStructures (String className,
28    Set<String> complexStructures)
29    {
30  0 if ( ! complexStructures.add (className))
31    {
32  0 return;
33    }
34  0 BeanInfo beanInfo;
35  0 Class<?> clazz;
36  0 try
37    {
38  0 clazz = Class.forName (className);
39    }
40    catch (ClassNotFoundException ex)
41    {
42  0 System.out.println ("ComplexSubstructuresHelper: Could not process because the class must be a freestanding object: " + className);
43  0 return;
44    }
45  0 try
46    {
47  0 beanInfo = Introspector.getBeanInfo (clazz);
48    }
49    catch (IntrospectionException ex)
50    {
51  0 throw new RuntimeException (ex);
52    }
53  0 for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors ())
54    {
55  0 Class<?> subClass = pd.getPropertyType ();
56  0 if (List.class.equals (subClass))
57    {
58  0 try
59    {
60  0 subClass =
61    (Class<?>) ((ParameterizedType) clazz.getDeclaredField (
62    pd.getName ()).getGenericType ()).getActualTypeArguments ()[0];
63    }
64    catch (NoSuchFieldException ex)
65    {
66  0 throw new RuntimeException (ex);
67    }
68    catch (SecurityException ex)
69    {
70  0 throw new RuntimeException (ex);
71    }
72    }
73  0 if ( ! MetaInfo.class.equals (subClass)
74    && ! Class.class.equals (subClass)
75    && ! String.class.equals (subClass)
76    && ! Integer.class.equals (subClass)
77    && ! Long.class.equals (subClass)
78    && ! Boolean.class.equals (subClass)
79    && ! boolean.class.equals (subClass)
80    && ! int.class.equals (subClass)
81    && ! long.class.equals (subClass)
82    && ! Double.class.equals (subClass)
83    && ! Float.class.equals (subClass)
84    && ! Date.class.equals (subClass)
85    && ! DictionaryConstants.ATTRIBUTES.equals (pd.getName ())
86    && ! Enum.class.isAssignableFrom (subClass)
87    && ! Object.class.equals (subClass))
88    {
89  0 loadComplexStructures (subClass.getName (), complexStructures);
90    }
91    }
92    }
93   
94   
95    }