/*
 * Bytecode Analysis Framework
 * Copyright (C) 2005, University of Maryland
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package edu.umd.cs.findbugs.ba;

import org.apache.bcel.Constants;

public abstract class AbstractClassMember implements ClassMember {
	private final String className;
	private final String name;
	private final String signature;
	private final int accessFlags;
	private int cachedHashCode = 0;

	protected AbstractClassMember(String className, String name, String signature, int accessFlags) {
		if (className.indexOf('/') >= 0) className = className.replace('/','.');
		if (signature.indexOf('/') >= 0) signature = signature.replace('/','.');
		this.className = className;
		this.name = name;
		this.signature = signature;
		this.accessFlags = accessFlags;
	}

	public String getClassName() {
		return className;
	}

	public String getName() {
		return name;
	}

	public String getSignature() {
		return signature;
	}

	public boolean isReferenceType() {
		return signature.startsWith("L") || signature.startsWith("[");
	}

	public int getAccessFlags() {
		return accessFlags;
	}

	public boolean isFinal() {
		return (accessFlags & Constants.ACC_FINAL) != 0;
	}

	public boolean isPublic() {
		return (accessFlags & Constants.ACC_PUBLIC) != 0;
	}
	
	public boolean isProtected() {
		return (accessFlags & Constants.ACC_PROTECTED) != 0;
	}
	
	public boolean isPrivate() {
		return (accessFlags & Constants.ACC_PRIVATE) != 0;
	}

	public int compareTo(ClassMember other) {
		// This may be compared to any kind of PackageMember object.
		// If the other object is a different kind of field,
		// just compare class names.
		if (this.getClass() != other.getClass())
			return this.getClass().getName().compareTo(other.getClass().getName());

		int cmp;
		cmp = className.compareTo(other.getClassName());
		if (cmp != 0)
			return cmp;
		cmp = name.compareTo(other.getName());
		if (cmp != 0)
			return cmp;
		return signature.compareTo(other.getSignature());
	}

	@Override
         public int hashCode() {
		if (cachedHashCode == 0) {
			cachedHashCode = className.hashCode() ^ name.hashCode() ^ signature.hashCode();
		}
		return cachedHashCode;
	}

	@Override
         public boolean equals(Object o) {
		if (o == null || this.getClass() != o.getClass())
			return false;
		AbstractClassMember other = (AbstractClassMember) o;
		return className.equals(other.className)
		        && name.equals(other.name)
		        && signature.equals(other.signature);
	}

	@Override
         public String toString() {
		return className + "." + name;
	}

}

@@ -1117,143 +1117,455 @@
  0;%0A
-%0A%09protected AbstractClassMember(String className, String name, String signature, int accessFlags) %7B%0A%09%09if (className.indexOf('/') %3E= 0) 
+%09static public int slashCountClass = 0;%0A%09static public int dottedCountClass = 0;%0A%09static public int slashCountSignature= 0;%0A%09static public int dottedCountSignature = 0;%0A%09%0A%0A%09protected AbstractClassMember(String className, String name, String signature, int accessFlags) %7B%0A%09%09if (className.indexOf('.') %3E= 0) %7B%0A%09%09%09// className = className.replace('.','/');%0A%09%09%09dottedCountClass++;%0A%09%09%7D else if (className.indexOf('/') %3E= 0)  %7B%0A%09%09%09slashCountClass++;%0A%09%09%09
 clas
@@ -1600,16 +1600,37 @@
 ','.');%0A
+%09%09%09assert false;%0A%09%09%7D%0A
 %09%09if (si
@@ -1638,33 +1638,33 @@
 nature.indexOf('
-/
+.
 ') %3E= 0) signatu
@@ -1656,16 +1656,21 @@
 ) %3E= 0) 
+%7B%0A%09%09%09
 signatur
@@ -1688,31 +1688,141 @@
 re.replace('
-/','.')
+.','/');%0A%09%09%09dottedCountSignature++;%0A%09%09%09assert false;%0A%09%09%7D else if (signature.indexOf('/') %3E= 0)  slashCountSignature++
 ;%0A%09%09this.cla

check that abstract class members use .'s for classnames and /'s for signatures