Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle TopLink
11g Release 1 (11.1.1)

E28847-01


org.eclipse.persistence.sdo.helper
Class SDOEqualityHelper

java.lang.Object
  extended by org.eclipse.persistence.sdo.helper.SDOEqualityHelper


public class SDOEqualityHelper
extends java.lang.Object

Purpose: A helper class for checking deep or shallow equality of DataObjects.

ChangeSummary is not in scope for equality checking.

Since:
Oracle TopLink 11.1.1.0.0
See Also:
SDODataObject

Field Summary
private  HelperContext aHelperContext
          hold the context containing all helpers so that we can preserve inter-helper relationships

 

Constructor Summary
SDOEqualityHelper()
          INTERNAL: This default constructor must be used in conjunction with the setHelperContext() function.
SDOEqualityHelper(HelperContext aContext)
          Constructor that takes in a HelperContext instance that contains this equalityHelper.

 

Method Summary
private  boolean arePropertiesEqual(Property prop1, Property prop2)
          INTERNAL: Convenience method that compares two Property objects for equality
private  boolean compare(DataObject dataObject1, DataObject dataObject2, boolean isDeep, java.util.List properties)
          INTERNAL: iterativly, compare the values of shared properties in two target DataObjects
private  boolean compareDataObjects(DataObject dataObject1, DataObject dataObject2, boolean isDeep)
          INTERNAL: Separately, checks the declared properties and open content properties.
private  boolean compareManyProperty(DataObject dataObject1, DataObject dataObject2, boolean isDeep, Property p)
          INTERNAL: iteratively check value of property p when p is many type property.
private  boolean compareProperty(DataObject dataObject1, DataObject dataObject2, boolean isDeep, SDOProperty p)
          INTERNAL: Recursively [PreOrder sequence] compare corresponding properties of 2 DataObjects check value of property p when p is not a many type property.
private  boolean compareSequences(SDOSequence aSequence, SDOSequence aSequenceCopy, boolean isDeep)
          INTERNAL: Return whether the 2 sequences are equal.
 boolean equal(DataObject dataObject1, DataObject dataObject2)
          Two DataObjects are equal(Deep) if they are equalShallow, all their compared Properties are equal, and all reachable DataObjects in their graphs excluding containers are equal.
 boolean equalShallow(DataObject dataObject1, DataObject dataObject2)
          Two DataObjects are equalShallow if they have the same Type and all their compared Properties are equal.
 HelperContext getHelperContext()
          INTERNAL: Return the helperContext containing this equalityHelper.
private  int getIndexOfNextDataTypeSetting(SDOSequence aSequence, int index)
          INTERNAL: Convenience method for returning the index of the next DataType Setting in a given sequence.
private  boolean isADataObjectInList(DataObject dataObject1, java.util.List objects)
          INTERNAL:
 void setHelperContext(HelperContext helperContext)
          INTERNAL: Set the helperContext if this equalityHelper was created using the default constructor.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

aHelperContext

private HelperContext aHelperContext
hold the context containing all helpers so that we can preserve inter-helper relationships

Constructor Detail

SDOEqualityHelper

public SDOEqualityHelper()
INTERNAL: This default constructor must be used in conjunction with the setHelperContext() function. The custom constructor that takes a HelperContext parameter is recommended over this default constructor.

SDOEqualityHelper

public SDOEqualityHelper(HelperContext aContext)
Constructor that takes in a HelperContext instance that contains this equalityHelper.
This is the recommended constructor.
Parameters:
aContext -

Method Detail

equalShallow

public boolean equalShallow(DataObject dataObject1,
                            DataObject dataObject2)

Two DataObjects are equalShallow if they have the same Type and all their compared Properties are equal. The set of Properties compared are the instance properties where property.getType().isDataType() is true and property.getType() is not ChangeSummaryType.
Two of these Property values are equal if they are both not set, or set to an equal value dataObject1.get(property).equals(dataObject2.get(property))
If the type is a sequenced type, the sequence entries must be the same. For each entry x in the sequence where the property is used in the comparison, dataObject1.getSequence().getValue(x).equals( dataObject2.getSequence().getValue(x)) and dataObject1.getSequence().getProperty(x) == dataObject2.getSequence().getProperty(x) must be true.

Returns true the objects have the same Type and all values of all compared Properties are equal.
Parameters:
dataObject1 - DataObject to be compared
dataObject2 - DataObject to be compared
Returns:
true the objects have the same Type and all values of all compared Properties are equal.

equal

public boolean equal(DataObject dataObject1,
                     DataObject dataObject2)

Two DataObjects are equal(Deep) if they are equalShallow, all their compared Properties are equal, and all reachable DataObjects in their graphs excluding containers are equal. The set of Properties compared are the instance properties where property.getType().isDataType() is false, and is not a container property, ie !property.getOpposite().isContainment()
Two of these Property values are equal if they are both not set, or all the DataObjects they refer to are equal in the context of dataObject1 and dataObject2.
Note that properties to a containing DataObject are not compared which means two DataObject trees can be equal even if their containers are not equal.
If the type is a sequenced type, the sequence entries must be the same. For each entry x in the sequence where the property is used in the comparison, equal(dataObject1.getSequence().getValue(x), dataObject2.getSequence().getValue(x)) and dataObject1.getSequence().getProperty(x) == dataObject2.getSequence().getProperty(x) must be true.

A DataObject directly or indirectly referenced by dataObject1 or dataObject2 can only be equal to exactly one DataObject directly or indirectly referenced by dataObject1 or dataObject2, respectively. This ensures that dataObject1 and dataObject2 are equal if the graph formed by all their referenced DataObjects have the same shape.

Returns true if the trees of DataObjects are equal(Deep).
Parameters:
dataObject1 - DataObject to be compared
dataObject2 - DataObject to be compared
Returns:
true if the trees of DataObjects are equal(Deep).

compareDataObjects

private boolean compareDataObjects(DataObject dataObject1,
                                   DataObject dataObject2,
                                   boolean isDeep)
INTERNAL: Separately, checks the declared properties and open content properties.
Parameters:
dataObject1 - the DataObject to be compared
dataObject2 - the DataObject to be compared
isDeep - if comparison is deep
Returns:
true if two DataObjects meet requirements of shallow equal or deep equal

compareSequences

private boolean compareSequences(SDOSequence aSequence,
                                 SDOSequence aSequenceCopy,
                                 boolean isDeep)
INTERNAL: Return whether the 2 sequences are equal. Element properties and unstructured text will be compared - attributes are out of scope.

For shallow equal - only dataType=true objects are compared, DataObject values are ignored but should be defaults. Note: A setting object should handle its own isEqual() behavior

Parameters:
aSequence -
aSequenceCopy -
isDeep -
Returns:

getIndexOfNextDataTypeSetting

private int getIndexOfNextDataTypeSetting(SDOSequence aSequence,
                                          int index)
INTERNAL: Convenience method for returning the index of the next DataType Setting in a given sequence.
Parameters:
aSequence -
index -
Returns:
the next Setting after index in the sequence, or -1 if none

arePropertiesEqual

private boolean arePropertiesEqual(Property prop1,
                                   Property prop2)
INTERNAL: Convenience method that compares two Property objects for equality
Parameters:
prop1 -
prop2 -
Returns:

compare

private boolean compare(DataObject dataObject1,
                        DataObject dataObject2,
                        boolean isDeep,
                        java.util.List properties)
INTERNAL: iterativly, compare the values of shared properties in two target DataObjects
Parameters:
dataObject1 - the DataObject to be compared
dataObject2 - the DataObject to be compared
isDeep - if comparison is deep
properties - list of properties shared by two DataObjects
Returns:
true if two DataObjects meet requirements of shallow equal or deep equal

compareProperty

private boolean compareProperty(DataObject dataObject1,
                                DataObject dataObject2,
                                boolean isDeep,
                                SDOProperty p)
INTERNAL: Recursively [PreOrder sequence] compare corresponding properties of 2 DataObjects check value of property p when p is not a many type property.
Parameters:
dataObject1 - the DataObject to be compared
dataObject2 - the DataObject to be compared
isDeep - if comparison is deep
p - the property shared by two DataObjects
Returns:
true if two DataObjects meet requirements of shallow equal or deep equal

compareManyProperty

private boolean compareManyProperty(DataObject dataObject1,
                                    DataObject dataObject2,
                                    boolean isDeep,
                                    Property p)
INTERNAL: iteratively check value of property p when p is many type property.
Parameters:
dataObject1 - the DataObject to be compared
dataObject2 - the DataObject to be compared
isShallow - if comparison is shallow
p - the property shared by two DataObjects
Returns:
true if two DataObjects meet requirements of shallow equal or deep equal

isADataObjectInList

private boolean isADataObjectInList(DataObject dataObject1,
                                    java.util.List objects)
INTERNAL:
Parameters:
dataObject1 -
objects -
Returns:

getHelperContext

public HelperContext getHelperContext()
INTERNAL: Return the helperContext containing this equalityHelper.
Returns:

setHelperContext

public void setHelperContext(HelperContext helperContext)
INTERNAL: Set the helperContext if this equalityHelper was created using the default constructor.
Parameters:
helperContext -

Skip navigation links

Copyright © 1998, 2012, Oracle. All Rights Reserved.