EMMA Coverage Report (generated Sat Feb 02 18:43:55 MSK 2008)
[all classes][net.sourceforge.retroweaver.runtime.java.lang]

COVERAGE SUMMARY FOR SOURCE FILE [Class_.java]

nameclass, %method, %block, %line, %
Class_.java100% (1/1)91%  (20/22)95%  (231/244)92%  (46/50)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Class_100% (1/1)91%  (20/22)95%  (231/244)92%  (46/50)
Class_ (): void 0%   (0/1)0%   (0/3)0%   (0/2)
isSynthetic (Class): boolean 0%   (0/1)0%   (0/5)0%   (0/1)
getAnnotation (Class, Class): Annotation 100% (1/1)58%  (7/12)67%  (2/3)
asSubclass (Class, Class): Class 100% (1/1)100% (12/12)100% (3/3)
cast (Class, Object): Object 100% (1/1)100% (14/14)100% (3/3)
getAnnotations (Class): Annotation [] 100% (1/1)100% (4/4)100% (1/1)
getCanonicalName (Class): String 100% (1/1)100% (36/36)100% (7/7)
getDeclaredAnnotations (Class): Annotation [] 100% (1/1)100% (4/4)100% (1/1)
getEnclosingClass (Class): Class 100% (1/1)100% (4/4)100% (1/1)
getEnclosingConstructor (Class): Constructor 100% (1/1)100% (4/4)100% (1/1)
getEnclosingMethod (Class): Method 100% (1/1)100% (4/4)100% (1/1)
getEnumConstants (Class): Object [] 100% (1/1)100% (10/10)100% (3/3)
getGenericInterfaces (Class): Type [] 100% (1/1)100% (4/4)100% (1/1)
getGenericSuperclass (Class): Type 100% (1/1)100% (4/4)100% (1/1)
getSimpleName (Class): String 100% (1/1)100% (46/46)100% (9/9)
getTypeParameters (Class): TypeVariable [] 100% (1/1)100% (4/4)100% (1/1)
isAnnotation (Class): boolean 100% (1/1)100% (13/13)100% (1/1)
isAnnotationPresent (Class, Class): boolean 100% (1/1)100% (8/8)100% (1/1)
isAnonymousClass (Class): boolean 100% (1/1)100% (8/8)100% (1/1)
isEnum (Class): boolean 100% (1/1)100% (20/20)100% (4/4)
isLocalClass (Class): boolean 100% (1/1)100% (10/10)100% (1/1)
isMemberClass (Class): boolean 100% (1/1)100% (15/15)100% (3/3)

1package net.sourceforge.retroweaver.runtime.java.lang;
2 
3import java.lang.reflect.Constructor;
4import java.lang.reflect.Method;
5 
6import net.sourceforge.retroweaver.runtime.java.lang.annotation.AIB;
7import net.sourceforge.retroweaver.runtime.java.lang.annotation.Annotation;
8import net.sourceforge.retroweaver.runtime.java.lang.reflect.GenericSignatureFormatError;
9import net.sourceforge.retroweaver.runtime.java.lang.reflect.MalformedParameterizedTypeException;
10import net.sourceforge.retroweaver.runtime.java.lang.reflect.ReflectionDescriptor;
11import net.sourceforge.retroweaver.runtime.java.lang.reflect.Type;
12import net.sourceforge.retroweaver.runtime.java.lang.reflect.TypeVariable;
13 
14/**
15 * Replacements for methods added to java.lang.Class in Java 1.5.
16 */
17public final class Class_ {
18 
19        private Class_() {
20                // private constructor
21        }
22 
23          public static boolean isAnnotation( Class c ) {
24            return         Annotation.class.isAssignableFrom(c);
25          }
26 
27          /**
28           * Returns this element's annotation for the specified type if such an annotation is present, else null.
29           * 
30           */
31          public static <T extends Annotation> T getAnnotation( Class c, Class<T> annotationType ) {
32                  if ( annotationType == null ) {
33              throw new NullPointerException( "Null annotationType" );
34            }
35 
36            return AIB.getAib(c).getClassAnnotation(annotationType);
37          }
38 
39          /**
40           * Returns all annotations present on this element.
41           */
42          public static Annotation[] getAnnotations( Class c ) {
43            return AIB.getAib(c).getClassAnnotations();
44          }
45 
46          /**
47           * Returns all annotations that are directly present on this element.
48           */
49          public static Annotation[] getDeclaredAnnotations( Class c ) {
50            return AIB.getAib(c).getDeclaredClassAnnotations();
51          }
52 
53          /**
54           * Returns true if an annotation for the specified type is present on this element, else false.
55           */
56          public static boolean isAnnotationPresent( Class c, Class<? extends Annotation> annotationType ) {
57            return getAnnotation( c, annotationType ) != null;
58          }
59 
60        /**
61         * Replacement for Class.asSubclass(Class).
62         * 
63         * @param c a Class
64         * @param superclass another Class which must be a superclass of <i>c</i>
65         * @return <i>c</i>
66         * @throws java.lang.ClassCastException if <i>c</i> is
67         */
68        public static Class asSubclass(Class<?> c, Class<?> superclass) {
69                if (!superclass.isAssignableFrom(c)) {
70                        throw new ClassCastException(superclass.getName());
71                }
72                return c;
73        }
74 
75        /**
76         * Replacement for Class.cast(Object). Throws a ClassCastException if <i>obj</i>
77         * is not an instance of class <var>c</var>, or a subtype of <var>c</var>.
78         * 
79         * @param c Class we want to cast <var>obj</var> to
80         * @param object object we want to cast
81         * @return The object, or <code>null</code> if the object is
82         * <code>null</code>.
83         * @throws java.lang.ClassCastException if <var>obj</var> is not
84         * <code>null</code> or an instance of <var>c</var>
85         */
86        public static Object cast(Class c, Object object) {
87                if (object == null || c.isInstance(object)) {
88                        return object;
89                } else {
90                        throw new ClassCastException(c.getName());
91                }
92        }
93 
94        /**
95         * Replacement for Class.isEnum().
96         * 
97         * @param class_ class we want to test.
98         * @return true if the class was declared as an Enum.
99         */
100        public static <T> boolean isEnum(Class<T> class_) {
101                Class c = class_.getSuperclass();
102 
103                if (c == null) {
104                        return false;
105                }
106 
107                return Enum.class.isAssignableFrom(c);
108        }
109 
110        /**
111         * Replacement for Class.getEnumConstants().
112         * 
113         * @param class_ class we want to get Enum constants for.
114         * @return The elements of this enum class or null if this does not represent an enum type.
115         */
116        public static <T> T[] getEnumConstants(Class<T> class_) {
117                if (!isEnum(class_)) {
118                        return null;
119                }
120 
121                return Enum.getEnumValues(class_).clone();
122        }
123 
124        /**
125        * replacement for Class.isAnonymousClass()
126        */
127        public static boolean isAnonymousClass(Class class_) {
128                return getSimpleName(class_).length() == 0;
129        }
130 
131        /**
132        * replacement for Class.getSimpleName()
133        */
134        public static String getSimpleName(Class class_) {
135                if (class_.isArray()) {
136                        return getSimpleName(class_.getComponentType()) + "[]";
137                }
138 
139                String className = class_.getName();
140 
141                int i = className.lastIndexOf('$');
142                if (i != -1) {
143                        do {
144                                i++;
145                        } while (i < className.length() && Character.isDigit(className.charAt(i)));
146                        return className.substring(i);
147                }
148 
149                return className.substring(className.lastIndexOf('.') + 1);
150        }
151 
152        /**
153         * replacement for Class.isSynthetic()
154         */
155        public static boolean isSynthetic(Class class_) {
156                throw new UnsupportedOperationException("NotImplemented");
157        }
158 
159        public static TypeVariable[] getTypeParameters(Class class_)
160                        throws GenericSignatureFormatError {
161                return ReflectionDescriptor.getReflectionDescriptor(class_).getTypeParameters();
162        }
163 
164        public static Type getGenericSuperclass(Class class_)
165                        throws GenericSignatureFormatError, TypeNotPresentException,
166                        MalformedParameterizedTypeException
167        {
168                return ReflectionDescriptor.getReflectionDescriptor(class_).getGenericSuperclass();
169        }
170 
171        public static Type[] getGenericInterfaces(Class class_) throws GenericSignatureFormatError,
172                        TypeNotPresentException, MalformedParameterizedTypeException
173        {
174                return ReflectionDescriptor.getReflectionDescriptor(class_).getGenericInterfaces();
175        }
176 
177        public static Method getEnclosingMethod(Class class_) {
178                return ReflectionDescriptor.getReflectionDescriptor(class_).getEnclosingMethod();
179        }
180 
181        public static Constructor<?> getEnclosingConstructor(Class class_) {
182                return ReflectionDescriptor.getReflectionDescriptor(class_).getEnclosingConstructor();
183        }
184 
185        public static Class<?> getEnclosingClass(Class class_) {
186                return ReflectionDescriptor.getReflectionDescriptor(class_).getEnclosingClass();
187        }
188 
189        public static String getCanonicalName(Class class_) {
190                if (class_.isArray()) {
191                        Class component = class_.getComponentType();
192                        String s = getCanonicalName(component);
193                        return s == null ? null : s + "[]";
194                }
195 
196                if (isLocalClass(class_) || isAnonymousClass(class_)) {
197                        return null;
198                }
199 
200                return class_.getName().replace('$', '.');
201        }
202 
203        public static boolean isLocalClass(Class class_) {
204                return getEnclosingMethod(class_) != null && !isAnonymousClass(class_);
205        }
206 
207        public static boolean isMemberClass(Class class_) {
208                if (getEnclosingClass(class_) != null) {
209                        return !(isLocalClass(class_) || isAnonymousClass(class_));
210                }
211                return false;
212        }
213 
214}

[all classes][net.sourceforge.retroweaver.runtime.java.lang]
EMMA 2.0.8001 (unsupported private build) (C) Vladimir Roubtsov