P
Petterson Mikael
Hi,
I am using a class, from an api, called JavaClass. I contains data about
the class. I will extract the following data:
String className
Field [] field
Method [] method
I will store the data in the following objects:
DataClass
DataField
DataMethod
This is how I think of writing the code for the DataClass ( see below
Listing 1).
Then each DataClass can contain zero or more DataField's and DataMethod's
My task is to compare the data of DataClass objects for two different api:s
clazz1 = (DataClass)vector1.getDataClass();
clazz2 = (DataClass)vector2.getDataClass();
if(clazz1.equals(clazz2)){
//Data is the same
}else{
//Data is not the same for class ......
}
How can I make sure that the DataClass's ( and depending objects
DataField and DataMethod ) data is compared?
Cheers,
//mikael
Listing 1
=========
import java.util.ArrayList;
public class DataClass {
private String className = null;
private ArrayList fields = null;
private ArrayList methods = null;
public DataClass(){
}
public void setClassName(String className){
this.className = className;
}
public String getClassName(){
return className;
}
public void setField(String field){
DataField df = new DataField();
df.setFieldName(field);
methods.add(df);
}
public void setMethod(String method){
DataMethod dm = new DataMethod();
dm.setMethodName(method);
methods.add(dm);
}
}
Listing 2
=========
public class DataField {
private String fieldName = null;
public void setField(String fieldName){
this.fieldName = fieldName;
}
}
I am using a class, from an api, called JavaClass. I contains data about
the class. I will extract the following data:
String className
Field [] field
Method [] method
I will store the data in the following objects:
DataClass
DataField
DataMethod
This is how I think of writing the code for the DataClass ( see below
Listing 1).
Then each DataClass can contain zero or more DataField's and DataMethod's
My task is to compare the data of DataClass objects for two different api:s
clazz1 = (DataClass)vector1.getDataClass();
clazz2 = (DataClass)vector2.getDataClass();
if(clazz1.equals(clazz2)){
//Data is the same
}else{
//Data is not the same for class ......
}
How can I make sure that the DataClass's ( and depending objects
DataField and DataMethod ) data is compared?
Cheers,
//mikael
Listing 1
=========
import java.util.ArrayList;
public class DataClass {
private String className = null;
private ArrayList fields = null;
private ArrayList methods = null;
public DataClass(){
}
public void setClassName(String className){
this.className = className;
}
public String getClassName(){
return className;
}
public void setField(String field){
DataField df = new DataField();
df.setFieldName(field);
methods.add(df);
}
public void setMethod(String method){
DataMethod dm = new DataMethod();
dm.setMethodName(method);
methods.add(dm);
}
}
Listing 2
=========
public class DataField {
private String fieldName = null;
public void setField(String fieldName){
this.fieldName = fieldName;
}
}