Clover coverage report - Dependency Finder
Coverage timestamp: Mon Nov 29 2010 15:00:50 PST
file stats: LOC: 193   Methods: 25
NCLOC: 118   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Feature_info.java 100% 93.5% 88% 92.2%
coverage coverage
 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   
 33    package com.jeantessier.classreader.impl;
 34   
 35    import java.io.*;
 36    import java.util.*;
 37   
 38    import org.apache.log4j.*;
 39   
 40    import com.jeantessier.classreader.*;
 41   
 42    public abstract class Feature_info implements com.jeantessier.classreader.Feature_info {
 43    private static final int ACC_PUBLIC = 0x0001;
 44    private static final int ACC_PRIVATE = 0x0002;
 45    private static final int ACC_PROTECTED = 0x0004;
 46    private static final int ACC_STATIC = 0x0008;
 47    private static final int ACC_FINAL = 0x0010;
 48    private static final int ACC_SYNTHETIC = 0x1000;
 49   
 50    private Classfile classfile;
 51    private int accessFlag;
 52    private int nameIndex;
 53    private int descriptorIndex;
 54    private Collection<Attribute_info> attributes = new LinkedList<Attribute_info>();
 55   
 56  5020 public Feature_info(Classfile classfile, DataInput in) throws IOException {
 57  5020 this(classfile, in, new AttributeFactory());
 58    }
 59   
 60  5020 public Feature_info(Classfile classfile, DataInput in, AttributeFactory attributeFactory) throws IOException {
 61  5020 this.classfile = classfile;
 62   
 63  5020 accessFlag = in.readUnsignedShort();
 64  5020 Logger.getLogger(getClass()).debug(getFeatureType() + " access flag: " + accessFlag);
 65   
 66  5020 nameIndex = in.readUnsignedShort();
 67  5020 Logger.getLogger(getClass()).debug(getFeatureType() + " name: " + nameIndex + " (" + getName() + ")");
 68   
 69  5020 descriptorIndex = in.readUnsignedShort();
 70  5020 Logger.getLogger(getClass()).debug(getFeatureType() + " Descriptor: " + descriptorIndex + " (" + getDescriptor() + ")");
 71   
 72  5020 int attributeCount = in.readUnsignedShort();
 73  5020 Logger.getLogger(getClass()).debug("Reading " + attributeCount + " " + getFeatureType() + " attribute(s)");
 74  5020 for (int i=0; i<attributeCount; i++) {
 75  4184 Logger.getLogger(getClass()).debug(getFeatureType() + " attribute " + i + ":");
 76  4184 attributes.add(attributeFactory.create(getClassfile().getConstantPool(), this, in));
 77    }
 78    }
 79   
 80  218637 public Classfile getClassfile() {
 81  218637 return classfile;
 82    }
 83   
 84  117669 public int getAccessFlag() {
 85  117669 return accessFlag;
 86    }
 87   
 88  16313 public boolean isPublic() {
 89  16313 return (getAccessFlag() & ACC_PUBLIC) != 0;
 90    }
 91   
 92  15347 public boolean isProtected() {
 93  15347 return (getAccessFlag() & ACC_PROTECTED) != 0;
 94    }
 95   
 96  15164 public boolean isPrivate() {
 97  15164 return (getAccessFlag() & ACC_PRIVATE) != 0;
 98    }
 99   
 100  99 public boolean isPackage() {
 101  99 return (getAccessFlag() & (ACC_PUBLIC | ACC_PROTECTED | ACC_PRIVATE)) == 0;
 102    }
 103   
 104  16136 public boolean isStatic() {
 105  16136 return (getAccessFlag() & ACC_STATIC) != 0;
 106    }
 107   
 108  15340 public boolean isFinal() {
 109  15340 return (getAccessFlag() & ACC_FINAL) != 0;
 110    }
 111   
 112  0 public int getNameIndex() {
 113  0 return nameIndex;
 114    }
 115   
 116  136824 public UTF8_info getRawName() {
 117  136824 return (UTF8_info) getClassfile().getConstantPool().get(nameIndex);
 118    }
 119   
 120  136760 public String getName() {
 121  136760 return getRawName().getValue();
 122    }
 123   
 124  267 public String getFullName() {
 125  267 return getClassfile().getClassName() + "." + getName();
 126    }
 127   
 128  0 public int getDescriptorIndex() {
 129  0 return descriptorIndex;
 130    }
 131   
 132  54433 public UTF8_info getRawDescriptor() {
 133  54433 return (UTF8_info) getClassfile().getConstantPool().get(descriptorIndex);
 134    }
 135   
 136  54433 public String getDescriptor() {
 137  54433 return getRawDescriptor().getValue();
 138    }
 139   
 140  21046 public Collection<Attribute_info> getAttributes() {
 141  21046 return attributes;
 142    }
 143   
 144  1065 public boolean isSynthetic() {
 145  1065 return isSyntheticFromAccessFlag() || isSyntheticFromAttribute();
 146    }
 147   
 148  1065 private boolean isSyntheticFromAccessFlag() {
 149  1065 return (getAccessFlag() & ACC_SYNTHETIC) != 0;
 150    }
 151   
 152  1065 private boolean isSyntheticFromAttribute() {
 153  1065 boolean result = false;
 154   
 155  1065 Iterator i = getAttributes().iterator();
 156  1065 while (!result && i.hasNext()) {
 157  776 result = i.next() instanceof Synthetic_attribute;
 158    }
 159   
 160  1065 return result;
 161    }
 162   
 163  8076 public boolean isDeprecated() {
 164  8076 boolean result = false;
 165   
 166  8076 Iterator i = getAttributes().iterator();
 167  8076 while (!result && i.hasNext()) {
 168  7489 result = i.next() instanceof Deprecated_attribute;
 169    }
 170   
 171  8076 return result;
 172    }
 173   
 174  5 public boolean isGeneric() {
 175  5 SignatureFinder finder = new SignatureFinder();
 176  5 accept(finder);
 177  5 return finder.getSignature() != null;
 178    }
 179   
 180  5397 public String getFullSignature() {
 181  5397 return getClassfile().getClassName() + "." + getSignature();
 182    }
 183   
 184    /**
 185    * Only used for pretty logging in constructor.
 186    * @return a printable string as to whether this is a field or a method
 187    */
 188    protected abstract String getFeatureType();
 189   
 190  0 public String toString() {
 191  0 return getFullName();
 192    }
 193    }