EMMA Coverage Report (generated Mon Nov 29 14:43:38 PST 2010)
[all classes][com.jeantessier.classreader.impl]

COVERAGE SUMMARY FOR SOURCE FILE [Method_info.java]

nameclass, %method, %block, %line, %
Method_info.java100% (1/1)100% (16/16)82%  (222/271)82%  (41.8/51)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Method_info100% (1/1)100% (16/16)82%  (222/271)82%  (41.8/51)
getDeclaration (): String 100% (1/1)65%  (76/117)59%  (11.8/20)
isBridge (): boolean 100% (1/1)78%  (7/9)77%  (0.8/1)
isNative (): boolean 100% (1/1)78%  (7/9)77%  (0.8/1)
isStrict (): boolean 100% (1/1)78%  (7/9)77%  (0.8/1)
isSynchronized (): boolean 100% (1/1)78%  (7/9)77%  (0.8/1)
Method_info (Classfile, DataInput): void 100% (1/1)100% (5/5)100% (2/2)
accept (Visitor): void 100% (1/1)100% (4/4)100% (2/2)
getCode (): Code_attribute 100% (1/1)100% (10/10)100% (3/3)
getExceptions (): Collection 100% (1/1)100% (23/23)100% (5/5)
getFeatureType (): String 100% (1/1)100% (2/2)100% (1/1)
getReturnType (): String 100% (1/1)100% (4/4)100% (1/1)
getSignature (): String 100% (1/1)100% (42/42)100% (9/9)
isAbstract (): boolean 100% (1/1)100% (9/9)100% (1/1)
isConstructor (): boolean 100% (1/1)100% (5/5)100% (1/1)
isStaticInitializer (): boolean 100% (1/1)100% (5/5)100% (1/1)
isVarargs (): boolean 100% (1/1)100% (9/9)100% (1/1)

1/*
2 *  Copyright (c) 2001-2009, Jean Tessier
3 *  All rights reserved.
4 *  
5 *  Redistribution and use in source and binary forms, with or without
6 *  modification, are permitted provided that the following conditions
7 *  are met:
8 *  
9 *      * Redistributions of source code must retain the above copyright
10 *        notice, this list of conditions and the following disclaimer.
11 *  
12 *      * Redistributions in binary form must reproduce the above copyright
13 *        notice, this list of conditions and the following disclaimer in the
14 *        documentation and/or other materials provided with the distribution.
15 *  
16 *      * Neither the name of Jean Tessier nor the names of his contributors
17 *        may be used to endorse or promote products derived from this software
18 *        without specific prior written permission.
19 *  
20 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 *  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR
24 *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 
33package com.jeantessier.classreader.impl;
34 
35import java.io.*;
36import java.util.*;
37 
38import com.jeantessier.classreader.*;
39 
40public class Method_info extends Feature_info implements com.jeantessier.classreader.Method_info {
41    private static final int ACC_SYNCHRONIZED = 0x0020;
42    private static final int ACC_BRIDGE = 0x0040;
43    private static final int ACC_VARARGS = 0x0080;
44    private static final int ACC_NATIVE = 0x0100;
45    private static final int ACC_ABSTRACT = 0x0400;
46    private static final int ACC_STRICT = 0x0800;
47 
48    public Method_info(Classfile classfile, DataInput in) throws IOException {
49        super(classfile, in);
50    }
51 
52    public String getFeatureType() {
53        return "method";
54    }
55 
56    public boolean isSynchronized() {
57        return (getAccessFlag() & ACC_SYNCHRONIZED) != 0;
58    }
59 
60    public boolean isBridge() {
61        return (getAccessFlag() & ACC_BRIDGE) != 0;
62    }
63 
64    public boolean isVarargs() {
65        return (getAccessFlag() & ACC_VARARGS) != 0;
66    }
67 
68    public boolean isNative() {
69        return (getAccessFlag() & ACC_NATIVE) != 0;
70    }
71 
72    public boolean isAbstract() {
73        return (getAccessFlag() & ACC_ABSTRACT) != 0;
74    }
75 
76    public boolean isStrict() {
77        return (getAccessFlag() & ACC_STRICT) != 0;
78    }
79 
80    public boolean isConstructor() {
81        return getName().equals("<init>");
82    }
83 
84    public boolean isStaticInitializer() {
85        return getName().equals("<clinit>");
86    }
87 
88    public Collection<Class_info> getExceptions() {
89        Collection<Class_info> result = Collections.emptyList();
90 
91        for (Attribute_info attribute : getAttributes()) {
92            if (attribute instanceof Exceptions_attribute) {
93                result = ((Exceptions_attribute) attribute).getExceptions();
94            }
95        }
96 
97        return result;
98    }
99 
100    public String getSignature() {
101        StringBuffer result = new StringBuffer();
102 
103        if (isConstructor()) {
104            result.append(getClassfile().getSimpleName());
105            result.append(DescriptorHelper.getSignature(getDescriptor()));
106        } else if (isStaticInitializer()) {
107            result.append("static {}");
108        } else {
109            result.append(getName());
110            result.append(DescriptorHelper.getSignature(getDescriptor()));
111        }
112 
113        return result.toString();
114    }
115 
116    public String getReturnType() {
117        return DescriptorHelper.getReturnType(getDescriptor());
118    }
119 
120    public String getDeclaration() {
121        StringBuffer result = new StringBuffer();
122 
123        if (isPublic()) result.append("public ");
124        if (isProtected()) result.append("protected ");
125        if (isPrivate()) result.append("private ");
126        if (isStatic() && !isStaticInitializer()) result.append("static ");
127        if (isFinal()) result.append("final ");
128        if (isSynchronized()) result.append("synchronized ");
129        if (isNative()) result.append("native ");
130        if (isAbstract()) result.append("abstract ");
131 
132        if (!isConstructor() && !isStaticInitializer()) {
133            result.append((getReturnType() != null) ? getReturnType() : "void").append(" ");
134        }
135 
136        result.append(getSignature());
137 
138        if (getExceptions().size() != 0) {
139            result.append(" throws ");
140            Iterator i = getExceptions().iterator();
141            while (i.hasNext()) {
142                result.append(i.next());
143                if (i.hasNext()) {
144                    result.append(", ");
145                }
146            }
147        }
148 
149        return result.toString();
150    }
151 
152    public com.jeantessier.classreader.Code_attribute getCode() {
153        CodeFinder finder = new CodeFinder();
154        accept(finder);
155        return finder.getCode();
156    }
157 
158    public void accept(Visitor visitor) {
159        visitor.visitMethod_info(this);
160    }
161}

[all classes][com.jeantessier.classreader.impl]
EMMA 2.0.5312 (C) Vladimir Roubtsov