EMMA Coverage Report (generated Mon Mar 20 21:34:30 PST 2006)
[all classes][com.moesol.generator.core]

COVERAGE SUMMARY FOR SOURCE FILE [VisitClass.java]

nameclass, %method, %block, %line, %
VisitClass.java100% (3/3)57%  (12/21)57%  (235/412)61%  (55.3/90)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VisitClass$2100% (1/1)33%  (1/3)6%   (3/49)12%  (1/8)
compare (Constructor, Constructor): int 0%   (0/1)0%   (0/39)0%   (0/6)
compare (Object, Object): int 0%   (0/1)0%   (0/7)0%   (0/1)
VisitClass$2 (): void 100% (1/1)100% (3/3)100% (1/1)
     
class VisitClass$1100% (1/1)100% (3/3)34%  (20/59)40%  (4/10)
compare (Method, Method): int 100% (1/1)20%  (10/49)25%  (2/8)
VisitClass$1 (): void 100% (1/1)100% (3/3)100% (1/1)
compare (Object, Object): int 100% (1/1)100% (7/7)100% (1/1)
     
class VisitClass100% (1/1)53%  (8/15)70%  (212/304)70%  (50.3/72)
VisitClass (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getMethodComparator (): Comparator 0%   (0/1)0%   (0/2)0%   (0/1)
visitBases (Class, BaseVisitor): void 0%   (0/1)0%   (0/28)0%   (0/7)
visitParamTypes (Class, Constructor, ParamTypeVisitor): void 0%   (0/1)0%   (0/6)0%   (0/2)
visitParamTypes (Class, Method, ParamTypeVisitor): void 0%   (0/1)0%   (0/6)0%   (0/2)
visitParamTypes (Constructor, ParamTypeVisitor): void 0%   (0/1)0%   (0/7)0%   (0/2)
visitParamTypes (Method, ParamTypeVisitor): void 0%   (0/1)0%   (0/7)0%   (0/2)
_visitParamTypes (Class, Class [], ParamTypeVisitor): void 100% (1/1)44%  (15/34)49%  (3.4/7)
_visitPrimitive (Class, TypeVisitor): void 100% (1/1)83%  (64/77)95%  (19/20)
checkMods (int, int, int): boolean 100% (1/1)93%  (13/14)92%  (0.9/1)
<static initializer> 100% (1/1)100% (9/9)100% (2/2)
visitParamTypes (Class [], ParamTypeVisitor): void 100% (1/1)100% (5/5)100% (2/2)
visitReflect (Class, ReflectVisitor): void 100% (1/1)100% (6/6)100% (2/2)
visitReflect (Class, ReflectVisitor, int, int): void 100% (1/1)100% (82/82)100% (15/15)
visitType (Class, TypeVisitor): void 100% (1/1)100% (18/18)100% (6/6)

1//
2// (c) Copyright, Moebius Solutions, 2002
3//
4//                       All Rights Reserved
5//
6// This material may be reproduced by or for the U. S. Government
7// pursuant to the copyright license under the clause at
8// DFARS 252.227-7013 (OCT 1988).
9//
10package com.moesol.generator.core;
11 
12import java.lang.reflect.*;
13 
14import com.moesol.generator.visitor.*;
15 
16public class VisitClass {
17    public static void visitBases(Class c, BaseVisitor v) {
18        Class superClass = c.getSuperclass();
19        Class interfaces[] = c.getInterfaces();
20        if (superClass != null) {
21            v.visitSuperClass(c, superClass);
22        }
23        for (int i = 0; i < interfaces.length; i++) {
24            v.visitInterface(c, interfaces[i], i);
25        }
26    }
27    public static void visitReflect(Class c, ReflectVisitor v)
28        throws ApplyException
29    {
30        visitReflect(c, v, 0, 0);
31    }
32    public static void visitReflect(Class c, ReflectVisitor v, int onMods, int offMods)
33        throws ApplyException
34    {
35        Constructor ctors[] = c.getDeclaredConstructors();
36        java.util.Arrays.sort(ctors, m_ctor_cmp);
37        for (int i = 0; i < ctors.length; i++) {
38            if (checkMods(ctors[i].getModifiers(), onMods, offMods)) {
39                v.visitConstructor(c, ctors[i]);
40            }
41        }
42        Method methods[] = c.getDeclaredMethods();
43        java.util.Arrays.sort(methods, m_method_cmp);
44        for (int i = 0; i < methods.length; i++) {
45            if (checkMods(methods[i].getModifiers(), onMods, offMods)) {
46                v.visitMethod(c, methods[i]);
47            }
48        }
49        Field fields[] = c.getDeclaredFields();
50        for (int i = 0; i < fields.length; i++) {
51            if (checkMods(fields[i].getModifiers(), onMods, offMods)) {
52                v.visitField(c, fields[i]);
53            }
54        }
55    }
56    // TODO does anyone need the declaring class?
57    public static void visitParamTypes(Class[] paramTypes, ParamTypeVisitor v)
58        throws ApplyException
59    {
60        _visitParamTypes(null, paramTypes, v);
61    }
62    private static void _visitParamTypes(Class c, Class[] paramTypes, ParamTypeVisitor v)
63        throws ApplyException
64    {
65        int j = 0;
66        if (j < paramTypes.length) {
67            v.visitParamType(c, j, paramTypes[j]);
68        }
69        for (j = j + 1; j < paramTypes.length; j++) {
70            v.visitParamSeparator(c);
71            v.visitParamType(c, j, paramTypes[j]);
72        }
73    }
74    public static void visitParamTypes(Method m, ParamTypeVisitor v)
75        throws ApplyException
76    {
77        _visitParamTypes(m.getDeclaringClass(), m.getParameterTypes(), v);
78    }
79    // TODO deprecate
80    public static void visitParamTypes(Class c, Method m, ParamTypeVisitor v)
81        throws ApplyException
82    {
83        _visitParamTypes(c, m.getParameterTypes(), v);
84    }
85    public static void visitParamTypes(Constructor ctor, ParamTypeVisitor v)
86        throws ApplyException
87    {
88        _visitParamTypes(ctor.getDeclaringClass(), ctor.getParameterTypes(), v);
89    }
90    // TODO deprecate
91    public static void visitParamTypes(Class c, Constructor ctor, ParamTypeVisitor v)
92        throws ApplyException
93    {
94        _visitParamTypes(c, ctor.getParameterTypes(), v);
95    }
96 
97    private static void _visitPrimitive(Class type, TypeVisitor v) {
98        if (type == Boolean.TYPE) {
99            v.visitBoolean(type);
100        } else if (type == Byte.TYPE) {
101            v.visitByte(type);
102        } else if (type == Character.TYPE) {
103            v.visitCharacter(type);
104        } else if (type == Short.TYPE) {
105            v.visitShort(type);
106        } else if (type == Integer.TYPE) {
107            v.visitInteger(type);
108        } else if (type == Long.TYPE) {
109            v.visitLong(type);
110        } else if (type == Float.TYPE) {
111            v.visitFloat(type);
112        } else if (type == Double.TYPE) {
113            v.visitDouble(type);
114        } else if (type == Void.TYPE) {
115            v.visitVoid(type);
116        } else {
117            throw new IllegalArgumentException("Not a known primitive type" + type.getName());
118        }
119    }
120    /**
121     * Call the correct visit method in the TypeVisitor based on the
122     * <code>type</code>.
123     */
124    public static void visitType(Class type, TypeVisitor v) {
125        if (type.isPrimitive()) {
126            _visitPrimitive(type, v);
127        } else if (type.isArray()) {
128            v.visitArray(type);
129        } else {
130            v.visitObject(type);
131        }
132    }
133        
134    // mods onMods  (~mods & onMods)
135    // 0    0       0
136    // 1    0       0
137    // 0    1       1
138    // 1    1       0
139    public static boolean checkMods(int mods, int onMods, int offMods) {
140        return (((~mods & onMods) == 0) && ((mods & offMods) == 0));
141    }
142 
143    public static java.util.Comparator getMethodComparator() {
144        return m_method_cmp;
145    }
146    
147    private static java.util.Comparator m_method_cmp = new java.util.Comparator() {
148            public int compare(Object o1, Object o2) {
149                return compare((Method)o1, (Method)o2);
150            }
151            private int compare(Method m1, Method m2) {
152                int r = m1.getName().compareTo(m2.getName());
153                if (r != 0) { return r; }
154                r = m1.getParameterTypes().length - m2.getParameterTypes().length;
155                if (r != 0) { return r; }
156                for (int i = 0; i < m1.getParameterTypes().length; i++) {
157                    r = m1.getParameterTypes()[i].getName()
158                        .compareTo(m2.getParameterTypes()[i].getName());
159                    if (r != 0) { return r; }
160                }
161                return r;
162            }
163        };
164    private static java.util.Comparator m_ctor_cmp = new java.util.Comparator() {
165            public int compare(Object o1, Object o2) {
166                return compare((Constructor)o1, (Constructor)o2);
167            }
168            private int compare(Constructor c1, Constructor c2) {
169                int r;
170                r = c1.getParameterTypes().length - c2.getParameterTypes().length;
171                if (r != 0) { return r; }
172                for (int i = 0; i < c1.getParameterTypes().length; i++) {
173                    r = c1.getParameterTypes()[i].getName()
174                        .compareTo(c2.getParameterTypes()[i].getName());
175                    if (r != 0) { return r; }
176                }
177                return r;
178            }
179        };
180}

[all classes][com.moesol.generator.core]
EMMA 2.0.5312 (C) Vladimir Roubtsov