Code Search for Developers
 
 
  

JavaClass.java from MASE: Agile Software Engineering at Krugle


Show JavaClass.java syntax highlighted

 package ca.ucalgary.cpsc.ebe.fitClipse.FixtureGenerater;

import java.util.HashMap;
import java.util.LinkedList;

public class JavaClass {
	private boolean isAbstract=false;
	private String name;
	private String access = "public";
	private LinkedList children;
	private LinkedList superClasses = null;
	private LinkedList interfaces = null;

	
	private HashMap insertedChildren = new HashMap();
	
	
	public JavaClass(String name){
		this.name = name;
		

		
	}
	public JavaClass(String name, String access){
		this.name = name;
		this.access = access;
		
		
	}

	public void makeAbstract(){
		isAbstract = true;
	}
	public String getAccess() {
		return access;
	}
	public void setAccess(String access) {
		this.access = access;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	private String childSource(){
		if(this.children == null)
			return "";
		
		StringBuffer childSource = new StringBuffer();
		for(int i=0; i < this.children.size(); i++){
			childSource.append("\t").append(((JavaClassChild)this.children.get(i)).render()).append("\n");
		}
		
		return childSource.toString();
	}
	
	public String renderSource(){
		String isAbstract = "";
		if(this.isAbstract)
			isAbstract = " abstract";
		StringBuffer source = new StringBuffer();
		source.append(this.access).append(isAbstract).append(" class ").append(this.name).append(renderInheritance()).append(renderRealizations());
		source.append(" {\n");
		
		source.append(childSource());
		
		source.append("}");
		
		return source.toString();
		
	}
	
	
	
	public void addChildElement(JavaClassChild child){
		if(this.children == null)
			this.children = new LinkedList();
		this.children.add(child);
		
		this.insertedChildren.put(child.getIdentifier(), "true");
		
	}
	public void addInterface(String name){
		if(interfaces == null)
			interfaces = new LinkedList();
		this.interfaces.add(name);
	}
	public void addSuperClass(String name){
		if(superClasses == null)
			superClasses = new LinkedList();
		this.superClasses.add(name);
	}
	
	private String renderInheritance(){
		StringBuffer inheritance = new StringBuffer();
		if(superClasses == null)
			return "";
		
		inheritance.append(" extends");
		for(int i = 0; i < superClasses.size(); i++){
			inheritance.append(" ").append(superClasses.get(i).toString());
		}
		
		return inheritance.toString();
	}
	

	private String renderRealizations(){
		StringBuffer realizations = new StringBuffer();
		if(interfaces == null)
			return "";
		
		realizations.append(" implements");
		for(int i = 0; i < interfaces.size(); i++){
			realizations.append(" ").append(interfaces.get(i).toString());
		}
		
		return realizations.toString();
	}
	
	public boolean containsMethod(JavaMethod meth){
		if(this.insertedChildren.containsKey(meth.getIdentifier()))
			return true;
		
		return false;
	}
	
	public boolean containsProperty(JavaProperty prop){
		if(this.insertedChildren.containsKey(prop.getIdentifier()))
			return true;
		
		return false;
	}
}




See more files for this project here

MASE: Agile Software Engineering

The MASE project investigates methods to support the coordination and executable acceptance testing of software projects. Keywords: Agile methods, distributed teams, Extreme Programming. See http://ebe.cpsc.ucalgary.ca/ebe for more information.

Project homepage: http://sourceforge.net/projects/mase
Programming language(s): Java,XML
License: other

  ActionFixtureSource.java
  FixtureSource.java
  FixtureSourceFactory.java
  JavaClass.java
  JavaClassChild.java
  JavaFile.java
  JavaMethod.java
  JavaMethodContent.java
  JavaMethodContentNode.java
  JavaMethodParameter.java
  JavaProperty.java
  JavaSourceUtil.java