lava.util
Class EnumerationSynchronizer
java.lang.Object
|
+--lava.util.EnumerationSynchronizer
- All Implemented Interfaces:
- java.util.Enumeration
- public class EnumerationSynchronizer
- extends java.lang.Object
- implements java.util.Enumeration
EnumerationSynchronizer
is like the Unix "diff" command, except that it works on Enumerations rather than text files. In other words, this class synchronizes two Enumerations that are likely to return similar sequences of Objects. As this class gives its best effort to synchronize the two sequences, it will output synchronized objects as tuples (length-2 Object arrays). Each tuple returned is such that the equals method, when applied between any two non-null members of the tuple, returns true. Synchronizer is itself an Enumeration. Note that in places where the two enumerations differ, the tuples returned may contain a null value for one of the members, indicating an unmatched element.
- Since:
- 1998
- Author:
- Sharky
Constructor Summary |
EnumerationSynchronizer(java.util.Enumeration e1,
java.util.Enumeration e2,
int window_size)
Initializes a new EnumerationSynchronizer to read objects from the two provided Enumerations. |
Method Summary |
boolean |
hasMoreElements()
Determines whether there are more Object tuples to read. |
java.lang.Object |
nextElement()
Returns the next pair of synchronized elements. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EnumerationSynchronizer
public EnumerationSynchronizer(java.util.Enumeration e1,
java.util.Enumeration e2,
int window_size)
- Initializes a new EnumerationSynchronizer to read objects from the two provided Enumerations. The window_size indicates how far "into the future" the synchronizer may look when attempting to establish synchronization.
- Parameters:
e1
- one of the two Enumerationse2
- one of the two Enumerationswindow_size
- the size of the lookahead window
hasMoreElements
public boolean hasMoreElements()
- Determines whether there are more Object tuples to read.
- Specified by:
hasMoreElements
in interface java.util.Enumeration
- Returns:
- true if there are more tuples, false otherwise
nextElement
public java.lang.Object nextElement()
- Returns the next pair of synchronized elements. The pair is returned as a length-2 Object array. If the Enumerations are currently unsynchronized, only one element in the pair will be non-null.
- Specified by:
nextElement
in interface java.util.Enumeration
- Returns:
- the next pair of elements