
net.sf.jagg.msd.AbstractExtractor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jagg-core Show documentation
Show all versions of jagg-core Show documentation
jAgg is a Java 5.0 API that supports “group by” operations on Lists of Java objects: aggregate operations such as count, sum, max, min, avg, and many more. It also allows custom aggregate operations.
The newest version!
package net.sf.jagg.msd;
/**
* An AbstractExtractor
encapsulates functionality needed by all
* Extractors
, specifically, determining whether an Extractor is
* complete, and a chained Extractor
.
*
* @param The type of element.
* @param The type of label generated by the chained extractor.
*
* @author Randy Gettman
* @since 0.5.0
*/
public abstract class AbstractExtractor
{
/**
* The index that influences label generation. This could be an array
* index, a List position, or any index that represents part of an element.
*/
protected int myIndex;
/**
* The chained Extractor
.
*/
protected Extractor myExtractor;
/**
* Controlled by a discriminator, this notes down whether an equivalence
* class is "complete", such that all elements in an equivalence class
* have been examined completely.
*/
protected boolean amIAllComplete;
/**
* Creates an AbstractExtractor
that uses the given
* Extractor
in a chain for its labels.
*
* @param extractor The chained Extractor
.
*/
public AbstractExtractor(Extractor extractor)
{
myExtractor = extractor;
}
/**
* Sets which portion is retrieved as the label.
*
* @param index The index.
*/
public void setIndex(int index)
{
myIndex = index;
}
/**
* Determines whether discrimination is complete for the given element, at
* the given index. All elements that would throw, for example, an
* IndexOutOfBoundsException
, would return true
* here so the algorithm doesn't call getLabel
. All
* AbstractExtractors
should check their chained
* Extractor
, to see if it's complete first.
* @param element The element.
* @return true
if discrimination is complete or cannot
* continue, usually because the discrimination has run off the end of
* the label, false
otherwise.
*/
public abstract boolean isComplete(E element);
/**
* The Discriminator
calls this method to indicate whether all
* elements in its current equivalence class were complete.
* @param allComplete Whether all elements were complete.
*/
public void setAllComplete(boolean allComplete)
{
amIAllComplete = allComplete;
}
/**
* The specific Discriminator
calls this method to determine
* whether all elements in the current equivalence class were complete.
* @return Whether all elements were complete.
*/
public boolean isAllComplete()
{
return amIAllComplete;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy