net.sf.ivmaidns.storage
Class StorageEvent

java.lang.Object
  extended by net.sf.ivmaidns.storage.StorageEvent
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Immutable, Indexable, ReallyCloneable, Verifiable

public final class StorageEvent
extends java.lang.Object
implements Immutable, ReallyCloneable, java.io.Serializable, Indexable, Verifiable

Class for storage updation events (addition, modification and removal).

Version:
2.0
Author:
Ivan Maidanski
See Also:
Serialized Form

Field Summary
protected  int location
           
protected  java.lang.Object oldValue
          NOTE: oldValue may be == null.
protected  int prevLoc
           
protected  Storage source
          NOTE: source must be !
 
Constructor Summary
StorageEvent(Storage source, int prevLoc, int location, java.lang.Object oldValue)
          NOTE: source must be !
 
Method Summary
 java.lang.Object clone()
          Creates and returns a copy of this object.
 boolean equals(java.lang.Object obj)
           
 java.lang.Object getAt(int index)
          NOTE: Result is (new Object[] { getSource(), new Integer(getPrevLoc()), new Integer(getLocation()), getOldValue() })[index].
 int getLocation()
           
 java.lang.Object getOldValue()
           
 int getPrevLoc()
           
 int hashCode()
          NOTE: source is not hashed.
 void integrityCheck()
          NOTE: Check for integrity of this object. source storage is not checked.
 int length()
          NOTE: Result is the number of elements accessible through getAt(int).
 Storage source()
          NOTE: Result !
 java.lang.String toString()
          NOTE: source is not represented in the result.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

source

protected final Storage source
NOTE: source must be != null.


prevLoc

protected final int prevLoc

location

protected final int location

oldValue

protected final java.lang.Object oldValue
NOTE: oldValue may be == null.

Constructor Detail

StorageEvent

public StorageEvent(Storage source,
                    int prevLoc,
                    int location,
                    java.lang.Object oldValue)
             throws java.lang.NullPointerException
NOTE: source must be != null. If location > 0 then storage event is addition or modification (if oldValue != null) at location. Else if -location > 0 and oldValue != null then storage event is removal of oldValue after prevLoc (if 0 >= prevLoc then first child of -prevLoc is removed) at -location.

Throws:
java.lang.NullPointerException
Method Detail

source

public final Storage source()
NOTE: Result != null.

Since:
2.0

getPrevLoc

public final int getPrevLoc()

getLocation

public final int getLocation()

getOldValue

public final java.lang.Object getOldValue()

length

public int length()
NOTE: Result is the number of elements accessible through getAt(int).

Specified by:
length in interface Indexable
Returns:
amount (non-negative value) of elements.
Since:
2.0
See Also:
Indexable.getAt(int)

getAt

public java.lang.Object getAt(int index)
                       throws java.lang.ArrayIndexOutOfBoundsException
NOTE: Result is (new Object[] { getSource(), new Integer(getPrevLoc()), new Integer(getLocation()), getOldValue() })[index].

Specified by:
getAt in interface Indexable
Parameters:
index - the index (must be in the range) at which to return an element.
Returns:
an element (may be null) at index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if index is negative or is not less than length().
Since:
2.0
See Also:
Indexable.length()

clone

public java.lang.Object clone()
Description copied from interface: ReallyCloneable
Creates and returns a copy of this object. By the clone() standard definition, this method creates a new instance of the class of this object and initializes all its fields with exactly the contents of the corresponding fields of this object. Typically, native clone() method of Object class is used inside this method.

Specified by:
clone in interface ReallyCloneable
Overrides:
clone in class java.lang.Object
Returns:
a copy (not null and != this) of this instance.

hashCode

public int hashCode()
NOTE: source is not hashed.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
NOTE: source is not represented in the result.

Overrides:
toString in class java.lang.Object

integrityCheck

public void integrityCheck()
NOTE: Check for integrity of this object. source storage is not checked. For debug purpose only.

Specified by:
integrityCheck in interface Verifiable
Since:
2.0