org.xshare.base.counter
Interface BaseCounter

All Known Subinterfaces:
DynamicCounter, StaticCounter

public interface BaseCounter

Base interface for the DynamicCounter and the StaticCounter, specifing all operations to retrieve information about the results of a counter.

A counter represents an object, which contains a set of so called counting rules and key/value pairs containing the result of the counting process. The user has the ability to pass objects via passThrough(...) to the counter, which takes all elements and overhands them to its internal safed rules. Rules can be true or false for an object. Every time a rule becomes true for an object, the counter will increase a numerical value of an specific key/value pair. The association between a rules and a key/value pair is implementation specific.

Please read the small introduction to the counters of this package can be found in the user guide.

Version:
$Revision: 1.4 $
Author:
Oliver Fischer
See Also:
User guide

Method Summary
 int getResultFor(java.lang.Object pKey)
          Gets a specific result from a counting result key/value pair of the counter.
 java.util.Iterator getResultKeys()
          Returns a iteration with all keys of all currently known key/value pairs.
 boolean hasResultFor(java.lang.Object pKey)
          Method to check if the counter has specific counting result key/value pair or not.
 void passThrough(java.util.Iterator pIterator)
          Overhands all elements of a given iteration to all internal counting rules.
 void passThrough(java.lang.Object pVictim)
          Overhands a given object to all internal counting rules.
 void reset()
          Discards all results collected by this counter instance and brings it back to creation state.
 

Method Detail

passThrough

public void passThrough(java.lang.Object pVictim)
Overhands a given object to all internal counting rules.

Parameters:
pVictim - an Object instance representing the element to pass to the internal rules. Can be null.

passThrough

public void passThrough(java.util.Iterator pIterator)
Overhands all elements of a given iteration to all internal counting rules.

Parameters:
pIterator - an Iterator object pointing to all elements to pass to the internal rules.

hasResultFor

public boolean hasResultFor(java.lang.Object pKey)
Method to check if the counter has specific counting result key/value pair or not.

Parameters:
pKey - an Object object representing the key of the key/value pair those existence has to be checked.
Returns:
a boolean value which is true if a pair with this key exists.

getResultFor

public int getResultFor(java.lang.Object pKey)
                 throws java.util.NoSuchElementException
Gets a specific result from a counting result key/value pair of the counter.

Parameters:
pKey - an Object object, representing the key of the key/value pair, those value should be returned.
Returns:
an int value representing the counting result for the given key.
Throws:
java.util.NoSuchElementException - if the key/value couldn't be found.

getResultKeys

public java.util.Iterator getResultKeys()
Returns a iteration with all keys of all currently known key/value pairs.

Returns:
an Iterator object pointing to all currently known key objects.

reset

public void reset()
Discards all results collected by this counter instance and brings it back to creation state.



jKiska Base 0.2.1 Release Esche [http://jkiska.sourceforge.net]