Author: rfrovarp
Date: Thu Dec 13 11:03:32 2007
New Revision: 603984
URL: http://svn.apache.org/viewvc?rev=603984&view=rev
Log:
Override equals() so that it takes lastModified into account to allow for the updating of images. This is for bug 42385.
Modified:
lenya/trunk/src/modules/svg/java/src/org/apache/lenya/modules/svg/ProtocolHandler.java
Modified: lenya/trunk/src/modules/svg/java/src/org/apache/lenya/modules/svg/ProtocolHandler.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/svg/java/src/org/apache/lenya/modules/svg/ProtocolHandler.java?rev=603984&r1=603983&r2=603984&view=diff
==============================================================================
--- lenya/trunk/src/modules/svg/java/src/org/apache/lenya/modules/svg/ProtocolHandler.java (original)
+++ lenya/trunk/src/modules/svg/java/src/org/apache/lenya/modules/svg/ProtocolHandler.java Thu Dec 13 11:03:32 2007
@@ -70,6 +70,7 @@
private Source source;
private SourceResolver resolver;
private String url;
+ private long lastModified;
public ParsedUrlData(String protocol, SourceResolver resolver, String url) {
this.url = url;
@@ -80,6 +81,7 @@
this.resolver = resolver;
try {
this.source = resolver.resolveURI(url);
+ this.lastModified = this.source.getLastModified();
this.contentType = this.source.getMimeType();
} catch (Exception e) {
throw new RuntimeException(e);
@@ -106,6 +108,30 @@
return url + source.getLastModified();
}
+ /**
+ * Object.equals
+ */
+ public boolean equals(Object obj) {
+ if(obj == null) {
+ return false;
+ }
+ if( ! (obj instanceof ParsedUrlData)) {
+ return false;
+ }
+ // super.equals() doesn't take lastModified into account
+ ParsedUrlData pud = (ParsedUrlData)obj;
+ if(pud.url.equals(this.url) && pud.lastModified == this.lastModified ) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns hashCode for object
+ */
+ public int hashCode() {
+ return (url + lastModified).hashCode();
+ }
}
public void start() throws Exception {
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.