diff options
author | Sven Gothel <[email protected]> | 2014-05-13 16:06:10 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-05-13 23:05:54 +0200 |
commit | d44d189bfd816a9936ae20d8582ec8475c830189 (patch) | |
tree | 1a7d899e4996fe3edb0401fe5910d06e636a69f2 /api/src/main/java/org/osjava/jardiff | |
parent | 8989dfc820b14c25ef7d9cb4bad8e265719c5ef3 (diff) |
AbstractInfo: Add generic access to signature and descriptor ; Dumper: More info (access, desc + sig), allow passing PrintStream
Diffstat (limited to 'api/src/main/java/org/osjava/jardiff')
4 files changed, 86 insertions, 87 deletions
diff --git a/api/src/main/java/org/osjava/jardiff/AbstractInfo.java b/api/src/main/java/org/osjava/jardiff/AbstractInfo.java index bf892e6..ea69829 100644 --- a/api/src/main/java/org/osjava/jardiff/AbstractInfo.java +++ b/api/src/main/java/org/osjava/jardiff/AbstractInfo.java @@ -26,13 +26,13 @@ import org.objectweb.asm.Opcodes; public abstract class AbstractInfo { /** - * The string used to represent a class, method or field with public + * The string used to represent a class, method or field with public * access. */ public final String ACCESS_PUBLIC = "public"; - + /** - * The string used to represent a class, method or field with protected + * The string used to represent a class, method or field with protected * access. */ public final String ACCESS_PROTECTED = "protected"; @@ -55,12 +55,12 @@ public abstract class AbstractInfo * The access flags for this class, method or field. */ private final int access; - + /** * The internal name of this class, method or field. */ private final String name; - + /** * Construct a new AbstractInfo with the specified access and name. * @@ -71,7 +71,21 @@ public abstract class AbstractInfo this.access = access; this.name = name; } - + + /** + * Get the descriptor + * + * @return The descriptor. + */ + public abstract String getDesc(); + + /** + * Get the signature + * + * @return The signature. + */ + public abstract String getSignature(); + /** * Get the access flags for this class, method or field. * @@ -80,7 +94,7 @@ public abstract class AbstractInfo public final int getAccess() { return access; } - + /** * Get the internal name of this class, method or field. * @@ -89,7 +103,7 @@ public abstract class AbstractInfo public final String getName() { return name; } - + /** * Test if this class, method or field is public. * @@ -98,7 +112,7 @@ public abstract class AbstractInfo public final boolean isPublic() { return (access & Opcodes.ACC_PUBLIC) != 0; } - + /** * Test if this class, method or field is protected. * @@ -107,17 +121,17 @@ public abstract class AbstractInfo public final boolean isProtected() { return (access & Opcodes.ACC_PROTECTED) != 0; } - + /** * Test if this class, method or field is package private. * * @return true if it is package private. */ public final boolean isPackagePrivate() { - return (access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | + return (access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE)) == 0; } - + /** * Test if this class, method or field is private. * @@ -126,7 +140,7 @@ public abstract class AbstractInfo public final boolean isPrivate() { return (access & Opcodes.ACC_PRIVATE) != 0; } - + /** * Test if this class, method or field is abstract. * @@ -135,7 +149,7 @@ public abstract class AbstractInfo public final boolean isAbstract() { return (access & Opcodes.ACC_ABSTRACT) != 0; } - + /** * Test if this class, method or field is annotation * @@ -144,7 +158,7 @@ public abstract class AbstractInfo public final boolean isAnnotation() { return (access & Opcodes.ACC_ANNOTATION) != 0; } - + /** * Test if this class, method or field is a bridge * @@ -153,7 +167,7 @@ public abstract class AbstractInfo public final boolean isBridge() { return (access & Opcodes.ACC_BRIDGE) != 0; } - + /** * Test if this class, method or field is deprecated. * @@ -162,7 +176,7 @@ public abstract class AbstractInfo public final boolean isDeprecated() { return (access & Opcodes.ACC_DEPRECATED) != 0; } - + /** * Test if this class, method or field is an enum. * @@ -171,7 +185,7 @@ public abstract class AbstractInfo public final boolean isEnum() { return (access & Opcodes.ACC_ENUM) != 0; } - + /** * Test if this class, method or field is final. * @@ -180,7 +194,7 @@ public abstract class AbstractInfo public final boolean isFinal() { return (access & Opcodes.ACC_FINAL) != 0; } - + /** * Test if this class, method or field is an interface. * @@ -189,7 +203,7 @@ public abstract class AbstractInfo public final boolean isInterface() { return (access & Opcodes.ACC_INTERFACE) != 0; } - + /** * Test if this class, method or field is native. * @@ -198,7 +212,7 @@ public abstract class AbstractInfo public final boolean isNative() { return (access & Opcodes.ACC_NATIVE) != 0; } - + /** * Test if this class, method or field is static. * @@ -207,7 +221,7 @@ public abstract class AbstractInfo public final boolean isStatic() { return (access & Opcodes.ACC_STATIC) != 0; } - + /** * Test if this class, method or field is string. * @@ -216,7 +230,7 @@ public abstract class AbstractInfo public final boolean isStrict() { return (access & Opcodes.ACC_STRICT) != 0; } - + /** * Test if this class, method or field is super. * @@ -225,7 +239,7 @@ public abstract class AbstractInfo public final boolean isSuper() { return (access & Opcodes.ACC_SUPER) != 0; } - + /** * Test if this class, method or field is synchronized. * @@ -234,7 +248,7 @@ public abstract class AbstractInfo public final boolean isSynchronized() { return (access & Opcodes.ACC_SYNCHRONIZED) != 0; } - + /** * Test if this class, method or field is synthetic. * @@ -243,7 +257,7 @@ public abstract class AbstractInfo public final boolean isSynthetic() { return (access & Opcodes.ACC_SYNTHETIC) != 0; } - + /** * Test if this class or field is transient. * If this flag is set on a method it means something different. @@ -254,7 +268,7 @@ public abstract class AbstractInfo return !(this instanceof MethodInfo) && ((access & Opcodes.ACC_TRANSIENT) != 0); } - + /** * Test if this method is varargs. * If this flag is set on a class or field it means something different. @@ -264,19 +278,19 @@ public abstract class AbstractInfo * @return true if it is varargs. */ public final boolean isVarargs() { - return (this instanceof MethodInfo) && + return (this instanceof MethodInfo) && ((access & Opcodes.ACC_VARARGS) != 0); } - + /** * Test if this class, method or field is volatile. - * + * * @return true if it is volatile. */ public final boolean isVolatile() { return (access & Opcodes.ACC_VOLATILE) != 0; } - + /** * Retrieve the access level for this class, method or field. * diff --git a/api/src/main/java/org/osjava/jardiff/ClassInfo.java b/api/src/main/java/org/osjava/jardiff/ClassInfo.java index 5058048..a92aae9 100644 --- a/api/src/main/java/org/osjava/jardiff/ClassInfo.java +++ b/api/src/main/java/org/osjava/jardiff/ClassInfo.java @@ -27,36 +27,36 @@ public final class ClassInfo extends AbstractInfo /** * The classfile version number. */ - private int version; + private final int version; /** * The class signature. */ - private String signature; + private final String signature; /** * The internal classname of the superclass. */ - private String supername; + private final String supername; /** * An array of names of internal classnames of interfaces implemented * by the class. */ - private String[] interfaces; + private final String[] interfaces; /** - * A map of method signature to MethodInfo, for the methods provided + * A map of method signature to MethodInfo, for the methods provided * by this class. */ - private Map<String, MethodInfo> methodMap; + private final Map<String, MethodInfo> methodMap; /** - * A map of field signature to FieldInfo, for the fields provided by + * A map of field signature to FieldInfo, for the fields provided by * this class. */ - private Map<String, FieldInfo> fieldMap; - + private final Map<String, FieldInfo> fieldMap; + /** * Create a new classinfo. * @@ -80,7 +80,7 @@ public final class ClassInfo extends AbstractInfo this.methodMap = methodMap; this.fieldMap = fieldMap; } - + /** * Get the class file version. * @@ -89,16 +89,17 @@ public final class ClassInfo extends AbstractInfo public final int getVersion() { return version; } - - /** - * Get the class signature. - * - * @return the class signature - */ + + @Override + public final String getDesc() { + return null; + } + + @Override public final String getSignature() { return signature; } - + /** * Get the internal name of the superclass. * @@ -107,7 +108,7 @@ public final class ClassInfo extends AbstractInfo public final String getSupername() { return supername; } - + /** * Get the internal names of the interfaces implemented by this class * @@ -116,7 +117,7 @@ public final class ClassInfo extends AbstractInfo public final String[] getInterfaces() { return interfaces; } - + /** * Get the map of method signatures to methods. * @@ -125,7 +126,7 @@ public final class ClassInfo extends AbstractInfo public final Map<String, MethodInfo> getMethodMap() { return methodMap; } - + /** * Get the map of field signatures to fields. * diff --git a/api/src/main/java/org/osjava/jardiff/FieldInfo.java b/api/src/main/java/org/osjava/jardiff/FieldInfo.java index bf7f53e..ef86ea7 100644 --- a/api/src/main/java/org/osjava/jardiff/FieldInfo.java +++ b/api/src/main/java/org/osjava/jardiff/FieldInfo.java @@ -26,18 +26,18 @@ public final class FieldInfo extends AbstractInfo /** * The field descriptor for this field. */ - private String desc; - + private final String desc; + /** * The signature for this field. */ - private String signature; - + private final String signature; + /** * The initial value of this field. */ - private Object value; - + private final Object value; + /** * Create a new FieldInfo * @@ -54,25 +54,17 @@ public final class FieldInfo extends AbstractInfo this.signature = signature; this.value = value; } - - /** - * Get the descriptor for this FieldInfo. - * - * @return The field descriptor. - */ + + @Override public final String getDesc() { return desc; } - - /** - * Get the signature for this fieldinfo. - * - * @return The signature. - */ + + @Override public final String getSignature() { return signature; } - + /** * Get the initial value for this fieldinfo * diff --git a/api/src/main/java/org/osjava/jardiff/MethodInfo.java b/api/src/main/java/org/osjava/jardiff/MethodInfo.java index b7ac46b..0a59c60 100644 --- a/api/src/main/java/org/osjava/jardiff/MethodInfo.java +++ b/api/src/main/java/org/osjava/jardiff/MethodInfo.java @@ -26,18 +26,18 @@ public final class MethodInfo extends AbstractInfo /** * The method descriptor. */ - private String desc; + private final String desc; /** * The signature of the method. */ - private String signature; + private final String signature; /** * An array of the exceptions thrown by this method. */ - private String[] exceptions; - + private final String[] exceptions; + /** * Create a new MethodInfo with the specified parameters. * @@ -53,25 +53,17 @@ public final class MethodInfo extends AbstractInfo this.signature = signature; this.exceptions = exceptions; } - - /** - * Get the descriptor for the method. - * - * @return the descriptor - */ + + @Override public final String getDesc() { return desc; } - - /** - * Get the signature for the method. - * - * @return the signature - */ + + @Override public final String getSignature() { return signature; } - + /** * Get the array of exceptions which can be thrown by the method. * |