Implement hashCode() and equals() for ActionFile, FunctionFile, SkinFile and

Template classes. This is required for ZippedAppFile to when removing
Updatables that are no longer contained (revision 1.19 from Dec 7 2004).
Fixes bug 395.
This commit is contained in:
hns 2005-01-24 14:06:51 +00:00
parent e3d8976274
commit 24a973e662
4 changed files with 85 additions and 1 deletions

View file

@ -164,6 +164,28 @@ public final class SkinFile implements Updatable {
* @return ...
*/
public String toString() {
return "[SkinFile "+prototype.getName() + "/" + name+"]";
return new StringBuffer("[SkinFile ").append(prototype.getName())
.append("/").append(name).append("]").toString();
}
/**
* Override to produce hash code depending on file name
*
* @return a hash code value for this object.
*/
public int hashCode() {
return toString().hashCode();
}
/**
* Override to equal other SkinFile with the same source name
*
* @param obj the object to compare to
* @return true if obj is a SkinFile with the same source name
*/
public boolean equals(Object obj) {
return (obj instanceof SkinFile) &&
toString().equals(obj.toString());
}
}

View file

@ -189,4 +189,25 @@ public class ActionFile implements Updatable {
public String toString() {
return "ActionFile[" + sourceName + "]";
}
/**
* Override to produce hash code depending on source name
*
* @return a hash code value for this object.
*/
public int hashCode() {
return sourceName.hashCode();
}
/**
* Override to equal other ActionFile with the same source name
*
* @param obj the object to compare to
* @return true if obj is a ActionFile with the same source name
*/
public boolean equals(Object obj) {
return (obj instanceof ActionFile) &&
sourceName.equals(((ActionFile) obj).getSourceName());
}
}

View file

@ -123,4 +123,24 @@ public class FunctionFile implements Updatable {
public String toString() {
return sourceName;
}
/**
* Override to produce hash code depending on source name
*
* @return a hash code value for this object.
*/
public int hashCode() {
return sourceName.hashCode();
}
/**
* Override to equal other FunctionFiles with the same source name
*
* @param obj the object to compare to
* @return true if obj is a FunctionFile with the same source name
*/
public boolean equals(Object obj) {
return (obj instanceof FunctionFile) &&
sourceName.equals(((FunctionFile) obj).getSourceName());
}
}

View file

@ -235,4 +235,25 @@ public class Template extends ActionFile {
return "Template.Part [" + content + "," + isStatic + "]";
}
}
/**
* Override to produce hash code depending on source name
*
* @return a hash code value for this object.
*/
public int hashCode() {
return sourceName.hashCode();
}
/**
* Override to equal other Template with the same source name
*
* @param obj the object to compare to
* @return true if obj is a Template with the same source name
*/
public boolean equals(Object obj) {
return (obj instanceof Template) &&
sourceName.equals(((Template) obj).getSourceName());
}
}