net.sf.ivmaidns.storage
Class FilterStorage

java.lang.Object
  extended by net.sf.ivmaidns.util.ObservedCore
      extended by net.sf.ivmaidns.storage.Storage
          extended by net.sf.ivmaidns.storage.FilterStorage
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, MultiObservable, ReallyCloneable, Sortable, TrimToSizeable, Verifiable

public abstract class FilterStorage
extends Storage
implements java.io.Serializable

Abstract class for filter storage (virtual storage).

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

Field Summary
protected  Storage source
          NOTE: Filter storage must be synchronized with source if source !
 
Constructor Summary
FilterStorage()
           
 
Method Summary
 int childLocation(int parentLocation, boolean forward)
          NOTE: Must be synchronized outside with source if not null.
 java.lang.Object clone()
          NOTE: Must be synchronized outside with source if not null.
 int emptyLocation()
          NOTE: Result is an empty location (result > 0).
 int findLessGreater(java.lang.Object value, boolean greater, int prevLocation, boolean forward)
          NOTE: Must be synchronized outside with source if not null.
 java.lang.Object getAt(int location)
          NOTE: Not all non-empty locations may be valid.
 int insertAt(int prevLoc, int emptyLocation, java.lang.Object value)
          NOTE: Observers notification is performed.
 void integrityCheck()
          NOTE: Shallow check for integrity of this object. source storage is not checked.
 boolean isValidAt(int location)
          NOTE: Must be synchronized outside with source if not null.
 int locationOf(java.lang.Object value, int prevLocation, boolean forward)
          NOTE: Must be synchronized outside with source if not null.
protected  void minimizeCapacity()
          NOTE: The effectiveness is linear.
 int parentLocation(int location)
          NOTE: Must be synchronized outside with source if not null.
 java.lang.Object setAt(int location, java.lang.Object value)
          NOTE: Observers notification is performed.
 void setSource(Storage source)
          NOTE: source may be == null.
 int siblingLocation(int location, boolean forward)
          NOTE: Must be synchronized outside with source if not null.
protected  void update(int prevLoc, int location, java.lang.Object oldValue)
          NOTE: Called internally only from source observer agent (source !
 
Methods inherited from class net.sf.ivmaidns.storage.Storage
add, addAll, addAll, clear, contains, containsAll, containsAll, containsCount, equals, greaterThan, hasChildren, hashCode, insertAtAll, insertAtAll, nextLocation, notifyObservers, notifyObservers, remove, removeAll, removeAll, removeAt, toArray, toInlineString, toOutlineString, toString, trimToSize
 
Methods inherited from class net.sf.ivmaidns.util.ObservedCore
addObserver, hasObservers, removeObserver
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

source

protected Storage source
NOTE: Filter storage must be synchronized with source if source != null.

Constructor Detail

FilterStorage

public FilterStorage()
Method Detail

setSource

public void setSource(Storage source)
NOTE: source may be == null. If source == this then source is set to null. If source == oldSource then nothing more is performed. Proper observers notifications are performed. Must be synchronized outside with oldSource (if not null) and with source (if not null). When this storage is not needed any more, setSource(null) should be called to stop observing of source (if not null).


update

protected void update(int prevLoc,
                      int location,
                      java.lang.Object oldValue)
NOTE: Called internally only from source observer agent (source != null). Observers notification is performed (if needed). Must be synchronized outside with source. Should be protected.


minimizeCapacity

protected void minimizeCapacity()
Description copied from class: Storage
NOTE: The effectiveness is linear. Locations are not re-ordered. If OutOfMemoryError is thrown then storage remains unchanged. Must be synchronized outside.

Specified by:
minimizeCapacity in class Storage

emptyLocation

public final int emptyLocation()
Description copied from class: Storage
NOTE: Result is an empty location (result > 0). Storage state is not altered. The effectiveness is constant (typically). The order of empty locations is undefined. Requires no synchronization.

Specified by:
emptyLocation in class Storage

insertAt

public int insertAt(int prevLoc,
                    int emptyLocation,
                    java.lang.Object value)
             throws java.lang.IllegalArgumentException,
                    java.lang.ArrayStoreException
NOTE: Observers notification is performed. Must be synchronized outside with source if not null.

Specified by:
insertAt in class Storage
Throws:
java.lang.IllegalArgumentException
java.lang.ArrayStoreException

setAt

public java.lang.Object setAt(int location,
                              java.lang.Object value)
                       throws java.lang.IllegalArgumentException,
                              java.lang.ArrayStoreException
NOTE: Observers notification is performed. Must be synchronized outside with source if not null.

Specified by:
setAt in class Storage
Throws:
java.lang.IllegalArgumentException
java.lang.ArrayStoreException

getAt

public final java.lang.Object getAt(int location)
NOTE: Not all non-empty locations may be valid.

Specified by:
getAt in class Storage

isValidAt

public boolean isValidAt(int location)
NOTE: Must be synchronized outside with source if not null.

Specified by:
isValidAt in class Storage

childLocation

public int childLocation(int parentLocation,
                         boolean forward)
                  throws java.lang.IllegalArgumentException
NOTE: Must be synchronized outside with source if not null.

Specified by:
childLocation in class Storage
Throws:
java.lang.IllegalArgumentException

siblingLocation

public int siblingLocation(int location,
                           boolean forward)
                    throws java.lang.IllegalArgumentException
NOTE: Must be synchronized outside with source if not null.

Specified by:
siblingLocation in class Storage
Throws:
java.lang.IllegalArgumentException

parentLocation

public int parentLocation(int location)
                   throws java.lang.IllegalArgumentException
NOTE: Must be synchronized outside with source if not null.

Specified by:
parentLocation in class Storage
Throws:
java.lang.IllegalArgumentException

locationOf

public int locationOf(java.lang.Object value,
                      int prevLocation,
                      boolean forward)
               throws java.lang.IllegalArgumentException
NOTE: Must be synchronized outside with source if not null.

Specified by:
locationOf in class Storage
Throws:
java.lang.IllegalArgumentException

findLessGreater

public int findLessGreater(java.lang.Object value,
                           boolean greater,
                           int prevLocation,
                           boolean forward)
                    throws java.lang.IllegalArgumentException
NOTE: Must be synchronized outside with source if not null.

Specified by:
findLessGreater in class Storage
Throws:
java.lang.IllegalArgumentException

clone

public java.lang.Object clone()
NOTE: Must be synchronized outside with source if not null.

Specified by:
clone in interface ReallyCloneable
Overrides:
clone in class Storage
Returns:
a copy (may be null) of this instance.

integrityCheck

public void integrityCheck()
NOTE: Shallow check for integrity of this object. source storage is not checked. Must be synchronized outside with source if not null. For debug purpose only.

Specified by:
integrityCheck in interface Verifiable
Overrides:
integrityCheck in class Storage