com.ibm.di.server
Class Compare

java.lang.Object
  extended by com.ibm.di.server.Compare

public class Compare
extends java.lang.Object

This class is used for making comparisons of entries and attributes.


Constructor Summary
Compare()
           
 
Method Summary
static Entry applyMods(Entry source, java.util.ArrayList<ModificationItem> mods)
          Applies a given ArrayList of modifications to an Entry object and returns it.
 java.lang.String compactDN(java.lang.String p1)
          Removes spaces in a given string, including those at the string beginning, end and those following a comma character.
 java.util.ArrayList<ModificationItem> compareEntries(Entry a, Entry b)
          Compares two given Entry objects and returns an ArrayList with the differences (attributes that were in one of the entries and not the other).
 boolean differs(Attribute a, Attribute b)
          Compares two Attribute objects and returns if they are different.
 boolean equalsDN(java.lang.String p1, java.lang.String p2)
          Checks if two strings are equal.
 void join(Attribute a, Attribute b)
          Adds all values from the second Attribute object to the first one (if they are not already present).
 boolean vectorContains(java.lang.Object val, java.util.Vector<java.lang.Object> v, boolean dn)
          Return true if and only if a Vector contains a value, and remove that value from the Vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Compare

public Compare()
Method Detail

join

public void join(Attribute a,
                 Attribute b)
          throws java.lang.Exception
Adds all values from the second Attribute object to the first one (if they are not already present).

Parameters:
a - the attribute that will accept additional values
b - the attribute whose values will be added to the first one
Throws:
java.lang.Exception - if a problem occurs

differs

public boolean differs(Attribute a,
                       Attribute b)
                throws java.lang.Exception
Compares two Attribute objects and returns if they are different.

Parameters:
a - first Attribute object
b - second Attribute object
Returns:
true if the attributes are different, otherwise false
Throws:
java.lang.Exception - if a problem occurs

vectorContains

public boolean vectorContains(java.lang.Object val,
                              java.util.Vector<java.lang.Object> v,
                              boolean dn)
Return true if and only if a Vector contains a value, and remove that value from the Vector. Look into the values if they are complex. If dn is true, also compact Strings (by removing some spaces).

Parameters:
val - an Object that will be searched
v - the vector whose contents will be checked
dn - determines whether strings need to be compact or not
Returns:
true if the vector contains the given Object, otherwise false

compareEntries

public java.util.ArrayList<ModificationItem> compareEntries(Entry a,
                                                            Entry b)
                                                     throws java.lang.Exception
Compares two given Entry objects and returns an ArrayList with the differences (attributes that were in one of the entries and not the other).

Parameters:
a - first Entry object
b - second Entry object
Returns:
a list of the differences found during the comparison
Throws:
java.lang.Exception - if a problem occurs

applyMods

public static Entry applyMods(Entry source,
                              java.util.ArrayList<ModificationItem> mods)
Applies a given ArrayList of modifications to an Entry object and returns it.

Parameters:
source - a source Entry
mods - ArrayList of modifications
Returns:
the updated Entry

equalsDN

public boolean equalsDN(java.lang.String p1,
                        java.lang.String p2)
Checks if two strings are equal. Insignificant space characters are ignored.

Parameters:
p1 - first string
p2 - second string
Returns:
true it the strings are equal, otherwise false

compactDN

public java.lang.String compactDN(java.lang.String p1)
Removes spaces in a given string, including those at the string beginning, end and those following a comma character.

Parameters:
p1 - the String to be processed
Returns:
the comacted String