Browse Source

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
tags/fop-1_0
Maximilian Berger 14 years ago
parent
commit
482b874cec

+ 2
- 7
src/java/org/apache/fop/pdf/PDFColor.java View File

@@ -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;
}

+ 2
- 2
src/java/org/apache/fop/pdf/PDFDocument.java View File

@@ -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;
}
}

+ 2
- 7
src/java/org/apache/fop/pdf/PDFFileSpec.java View File

@@ -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;
}

+ 2
- 9
src/java/org/apache/fop/pdf/PDFFunction.java View File

@@ -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;
}

+ 2
- 4
src/java/org/apache/fop/pdf/PDFGState.java View File

@@ -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;
}

+ 2
- 7
src/java/org/apache/fop/pdf/PDFGoTo.java View File

@@ -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;
}

+ 2
- 7
src/java/org/apache/fop/pdf/PDFGoToRemote.java View File

@@ -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;
}

+ 2
- 7
src/java/org/apache/fop/pdf/PDFLaunch.java View File

@@ -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;
}

+ 2
- 7
src/java/org/apache/fop/pdf/PDFLink.java View File

@@ -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;
}

+ 16
- 0
src/java/org/apache/fop/pdf/PDFObject.java View File

@@ -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);
}
}

+ 2
- 7
src/java/org/apache/fop/pdf/PDFPattern.java View File

@@ -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;
}

+ 2
- 8
src/java/org/apache/fop/pdf/PDFShading.java View File

@@ -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;
}

Loading…
Cancel
Save