aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org
diff options
context:
space:
mode:
authorMaximilian Berger <maxberger@apache.org>2009-09-15 15:07:51 +0000
committerMaximilian Berger <maxberger@apache.org>2009-09-15 15:07:51 +0000
commit482b874cecd6ca20609da6a175fe435ffabe3c46 (patch)
treef78405214020fb99ebcf9660931cb43525f3c399 /src/java/org
parenta164040a67faa144709d0c4ffbf6ee37bb189f1a (diff)
downloadxmlgraphics-fop-482b874cecd6ca20609da6a175fe435ffabe3c46.tar.gz
xmlgraphics-fop-482b874cecd6ca20609da6a175fe435ffabe3c46.zip
equals implementation violated spec -> replaced with new contentEquals function
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@815358 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
-rw-r--r--src/java/org/apache/fop/pdf/PDFColor.java9
-rw-r--r--src/java/org/apache/fop/pdf/PDFDocument.java4
-rw-r--r--src/java/org/apache/fop/pdf/PDFFileSpec.java9
-rw-r--r--src/java/org/apache/fop/pdf/PDFFunction.java11
-rw-r--r--src/java/org/apache/fop/pdf/PDFGState.java6
-rw-r--r--src/java/org/apache/fop/pdf/PDFGoTo.java9
-rw-r--r--src/java/org/apache/fop/pdf/PDFGoToRemote.java9
-rw-r--r--src/java/org/apache/fop/pdf/PDFLaunch.java9
-rw-r--r--src/java/org/apache/fop/pdf/PDFLink.java9
-rw-r--r--src/java/org/apache/fop/pdf/PDFObject.java16
-rw-r--r--src/java/org/apache/fop/pdf/PDFPattern.java9
-rw-r--r--src/java/org/apache/fop/pdf/PDFShading.java10
12 files changed, 38 insertions, 72 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFColor.java b/src/java/org/apache/fop/pdf/PDFColor.java
index 5bac9532c..f2ae2da33 100644
--- a/src/java/org/apache/fop/pdf/PDFColor.java
+++ b/src/java/org/apache/fop/pdf/PDFColor.java
@@ -541,13 +541,8 @@ public class PDFColor extends PDFPathPaint {
return (new byte[0]);
}
- /**
- * Check for equality of color with another object.
- *
- * @param obj the object to compare
- * @return true if colors are equal
- */
- public boolean equals(Object obj) {
+ /** {@inheritDoc} */
+ protected boolean contentEquals(PDFObject obj) {
if (!(obj instanceof PDFColor)) {
return false;
}
diff --git a/src/java/org/apache/fop/pdf/PDFDocument.java b/src/java/org/apache/fop/pdf/PDFDocument.java
index 9bc4c0d2e..46effdfd6 100644
--- a/src/java/org/apache/fop/pdf/PDFDocument.java
+++ b/src/java/org/apache/fop/pdf/PDFDocument.java
@@ -526,8 +526,8 @@ public class PDFDocument {
private Object findPDFObject(List list, PDFObject compare) {
for (Iterator iter = list.iterator(); iter.hasNext();) {
- Object obj = iter.next();
- if (compare.equals(obj)) {
+ PDFObject obj = (PDFObject) iter.next();
+ if (compare.contentEquals(obj)) {
return obj;
}
}
diff --git a/src/java/org/apache/fop/pdf/PDFFileSpec.java b/src/java/org/apache/fop/pdf/PDFFileSpec.java
index a2bc6aefe..8de4164af 100644
--- a/src/java/org/apache/fop/pdf/PDFFileSpec.java
+++ b/src/java/org/apache/fop/pdf/PDFFileSpec.java
@@ -63,13 +63,8 @@ public class PDFFileSpec extends PDFObject {
* endobj
*/
- /**
- * Check if this equals another object.
- *
- * @param obj the object to compare
- * @return true if this equals other object
- */
- public boolean equals(Object obj) {
+ /** {@inheritDoc} */
+ protected boolean contentEquals(PDFObject obj) {
if (this == obj) {
return true;
}
diff --git a/src/java/org/apache/fop/pdf/PDFFunction.java b/src/java/org/apache/fop/pdf/PDFFunction.java
index 14cc318ba..d57cabb50 100644
--- a/src/java/org/apache/fop/pdf/PDFFunction.java
+++ b/src/java/org/apache/fop/pdf/PDFFunction.java
@@ -696,15 +696,8 @@ public class PDFFunction extends PDFObject {
}
- /**
- * Check if this function is equal to another object.
- * This is used to find if a particular function already exists
- * in a document.
- *
- * @param obj the obj to compare
- * @return true if the functions are equal
- */
- public boolean equals(Object obj) {
+ /** {@inheritDoc} */
+ protected boolean contentEquals(PDFObject obj) {
if (obj == null) {
return false;
}
diff --git a/src/java/org/apache/fop/pdf/PDFGState.java b/src/java/org/apache/fop/pdf/PDFGState.java
index 93151149b..4b997a145 100644
--- a/src/java/org/apache/fop/pdf/PDFGState.java
+++ b/src/java/org/apache/fop/pdf/PDFGState.java
@@ -175,10 +175,8 @@ public class PDFGState extends PDFObject {
* endobj
*/
- /**
- * {@inheritDoc}
- */
- public boolean equals(Object obj) {
+ /** {@inheritDoc} */
+ protected boolean contentEquals(PDFObject obj) {
if (obj == this) {
return true;
}
diff --git a/src/java/org/apache/fop/pdf/PDFGoTo.java b/src/java/org/apache/fop/pdf/PDFGoTo.java
index b3ff6bcdc..ad04650c6 100644
--- a/src/java/org/apache/fop/pdf/PDFGoTo.java
+++ b/src/java/org/apache/fop/pdf/PDFGoTo.java
@@ -143,13 +143,8 @@ public class PDFGoTo extends PDFAction {
* endobj
*/
- /**
- * Check if this equals another object.
- *
- * @param obj the object to compare
- * @return true if this equals other object
- */
- public boolean equals(Object obj) {
+ /** {@inheritDoc} */
+ protected boolean contentEquals(PDFObject obj) {
if (this == obj) {
return true;
}
diff --git a/src/java/org/apache/fop/pdf/PDFGoToRemote.java b/src/java/org/apache/fop/pdf/PDFGoToRemote.java
index e04a1668f..ee7660875 100644
--- a/src/java/org/apache/fop/pdf/PDFGoToRemote.java
+++ b/src/java/org/apache/fop/pdf/PDFGoToRemote.java
@@ -127,13 +127,8 @@ public class PDFGoToRemote extends PDFAction {
* endobj
*/
- /**
- * Check if this equals another object.
- *
- * @param obj the object to compare
- * @return true if this equals other object
- */
- public boolean equals(Object obj) {
+ /** {@inheritDoc} */
+ protected boolean contentEquals(PDFObject obj) {
if (this == obj) {
return true;
}
diff --git a/src/java/org/apache/fop/pdf/PDFLaunch.java b/src/java/org/apache/fop/pdf/PDFLaunch.java
index d87fa2523..386a7a9a3 100644
--- a/src/java/org/apache/fop/pdf/PDFLaunch.java
+++ b/src/java/org/apache/fop/pdf/PDFLaunch.java
@@ -42,13 +42,8 @@ public class PDFLaunch extends PDFAction {
return sb.toString();
}
- /**
- * Check if this equals another object.
- *
- * @param obj the object to compare
- * @return true if this equals other object
- */
- public boolean equals(Object obj) {
+ /** {@inheritDoc} */
+ protected boolean contentEquals(PDFObject obj) {
if (this == obj) {
return true;
}
diff --git a/src/java/org/apache/fop/pdf/PDFLink.java b/src/java/org/apache/fop/pdf/PDFLink.java
index a7c4c6548..6f5ffeb0d 100644
--- a/src/java/org/apache/fop/pdf/PDFLink.java
+++ b/src/java/org/apache/fop/pdf/PDFLink.java
@@ -106,13 +106,8 @@ public class PDFLink extends PDFObject {
* endobj
*/
- /**
- * Check if this equals another object.
- *
- * @param obj the object to compare
- * @return true if this equals other object
- */
- public boolean equals(Object obj) {
+ /** {@inheritDoc} */
+ protected boolean contentEquals(PDFObject obj) {
if (this == obj) {
return true;
}
diff --git a/src/java/org/apache/fop/pdf/PDFObject.java b/src/java/org/apache/fop/pdf/PDFObject.java
index 97e9f4976..21ff82394 100644
--- a/src/java/org/apache/fop/pdf/PDFObject.java
+++ b/src/java/org/apache/fop/pdf/PDFObject.java
@@ -393,4 +393,20 @@ public abstract class PDFObject implements PDFWritable {
return formatDateTime(time, TimeZone.getDefault());
}
+ /**
+ * Check if the other PDFObject has the same content as the current object.
+ * <p>
+ * Note: This function has a contract which is less binding than
+ * {@link #equals(Object)}. Whereas equals would require all values to be
+ * identical, this method is not required to check everything. In the case
+ * of PDFObjects, this means that the overriding function does not have to
+ * check for {@link #getObjectID()}.
+ *
+ * @param o
+ * object to compare to.
+ * @return true if the other object has the same content.
+ */
+ protected boolean contentEquals(PDFObject o) {
+ return this.equals(o);
+ }
}
diff --git a/src/java/org/apache/fop/pdf/PDFPattern.java b/src/java/org/apache/fop/pdf/PDFPattern.java
index 4e862c3f2..89ae1efcd 100644
--- a/src/java/org/apache/fop/pdf/PDFPattern.java
+++ b/src/java/org/apache/fop/pdf/PDFPattern.java
@@ -336,13 +336,8 @@ public class PDFPattern extends PDFPathPaint {
*/
public byte[] toPDF() { return null; }
- /**
- * Check if this pattern is equal to another.
- *
- * @param obj the object to compare against
- * @return true if the patterns are equal
- */
- public boolean equals(Object obj) {
+ /** {@inheritDoc} */
+ protected boolean contentEquals(PDFObject obj) {
if (obj == null) {
return false;
}
diff --git a/src/java/org/apache/fop/pdf/PDFShading.java b/src/java/org/apache/fop/pdf/PDFShading.java
index 5ac7245c9..fa4d454ed 100644
--- a/src/java/org/apache/fop/pdf/PDFShading.java
+++ b/src/java/org/apache/fop/pdf/PDFShading.java
@@ -529,14 +529,8 @@ public class PDFShading extends PDFObject {
return (p.toString());
}
- /**
- * Check if this shading is equal to another shading.
- * This is used to check if a shading already exists.
- *
- * @param obj the object to compare against
- * @return true if the shadings are equal
- */
- public boolean equals(Object obj) {
+ /** {@inheritDoc} */
+ protected boolean contentEquals(PDFObject obj) {
if (obj == null) {
return false;
}