org.planx.msd.number
Class NumberDiscriminator<T>

java.lang.Object
  extended by org.planx.msd.util.AbstractDiscriminator<T>
      extended by org.planx.msd.number.NumberDiscriminator<T>
All Implemented Interfaces:
Discriminator<T>
Direct Known Subclasses:
ByteDiscriminator, DoubleDiscriminator, FloatDiscriminator, IntegerDiscriminator, LongDiscriminator, ShortDiscriminator

public abstract class NumberDiscriminator<T>
extends AbstractDiscriminator<T>

This class provides a skeletal implementation of a Discriminator of numbers. The numbers are chopped into chunks of size 16 bits.

Author:
Thomas Ambus

Nested Class Summary
protected  class NumberDiscriminator.ChunkExtractor<U>
          A ChunkExtractor is capable of extracting an integer chunk of bitsize CHUNK_BITSIZE beginning from the offset set by setOffset from the type U.
 
Field Summary
protected static int CHUNK_BITSIZE
           
protected static int CHUNK_MASK
           
protected  Memory memory
           
 
Constructor Summary
protected NumberDiscriminator(Memory memory)
           
 
Method Summary
protected abstract  int bitsize()
          Returns the total bitsize of the specific type of number.
protected abstract
<U> NumberDiscriminator.ChunkExtractor<U>
chunkExtractor(Extractor<U,? extends T,?> e)
          returns a ChunkExtractor for the specific type of number.
<U,S> Collection<List<S>>
discriminate(List<? extends U> values, Extractor<U,? extends T,S> e)
          Discriminates a List of values using an Extractor, and returns a Collection of Lists, each representing an equivalence class containing elements from values that are equivalent.
 
Methods inherited from class org.planx.msd.util.AbstractDiscriminator
discriminate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHUNK_BITSIZE

protected static final int CHUNK_BITSIZE
See Also:
Constant Field Values

CHUNK_MASK

protected static final int CHUNK_MASK
See Also:
Constant Field Values

memory

protected Memory memory
Constructor Detail

NumberDiscriminator

protected NumberDiscriminator(Memory memory)
Method Detail

discriminate

public <U,S> Collection<List<S>> discriminate(List<? extends U> values,
                                              Extractor<U,? extends T,S> e)
Description copied from interface: Discriminator
Discriminates a List of values using an Extractor, and returns a Collection of Lists, each representing an equivalence class containing elements from values that are equivalent. The Extractor performs the task of extracting two kinds of objects from the input values: The label which is the object equivalence is defined upon, and the value which is the object that will be returned. That is, the label determines which equivalence class the value goes into.

The Collection of Lists returned should be considered unmodifiable (though, in some cases they might actually be modifiable, but this behaviour should not be relied upon).

Specified by:
discriminate in interface Discriminator<T>
Specified by:
discriminate in class AbstractDiscriminator<T>

bitsize

protected abstract int bitsize()
Returns the total bitsize of the specific type of number.


chunkExtractor

protected abstract <U> NumberDiscriminator.ChunkExtractor<U> chunkExtractor(Extractor<U,? extends T,?> e)
returns a ChunkExtractor for the specific type of number.



Copyright © 2010. All Rights Reserved.