Package adams.data
Class AbstractAnonymizer<T>
- java.lang.Object
-
- adams.data.AbstractAnonymizer<T>
-
- Type Parameters:
T- the type of object
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
DoubleAnonymizer,IntegerAnonymizer,StringAnonymizer
public abstract class AbstractAnonymizer<T> extends Object implements Serializable
Allows anonymizing of values.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ArrayList<Integer>m_Bufferthe buffer of unused random IDs.protected intm_BufferSizethe buffer size.protected Stringm_IDthe ID of the anonymizer (used for hashcode).protected Hashtable<T,Integer>m_Mappingthe current mapping (actual value <-> random).protected Randomm_Randomfor shuffling the IDs.protected longm_Seedthe seed value.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractAnonymizer()Default constructor.protectedAbstractAnonymizer(String id, int bufferSize)Initializes the anonymizer with a random seed value.protectedAbstractAnonymizer(String id, long seed, int bufferSize)Initializes the anonymizer.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Tanonymize(T value)Returns an anonymized value.protected voidfillBuffer()Fills up the buffer with random values again.intgetBufferSize()Returns the buffer size of this anonymizer.StringgetID()Returns the ID of this anonymizer.longgetSeed()Returns the seed of this anonymizer.inthashCode()Returns the hashcode for this anonymizer (based on its ID).protected abstract TtoAnonymized(Integer id)Turns the anonymous integer ID into the appropriate data type.StringtoString()Returns a short description of the anonymizer.
-
-
-
Constructor Detail
-
AbstractAnonymizer
protected AbstractAnonymizer()
Default constructor. Uses a random ID and buffer size 100.
-
AbstractAnonymizer
protected AbstractAnonymizer(String id, int bufferSize)
Initializes the anonymizer with a random seed value.- Parameters:
id- the ID of the anonymizerbufferSize- the size of the buffer for unused IDs
-
AbstractAnonymizer
protected AbstractAnonymizer(String id, long seed, int bufferSize)
Initializes the anonymizer.- Parameters:
id- the ID of the anonymizerseed- the seed value for the random number generatorbufferSize- the size of the buffer for unused IDs
-
-
Method Detail
-
getID
public String getID()
Returns the ID of this anonymizer.- Returns:
- the ID
-
getSeed
public long getSeed()
Returns the seed of this anonymizer.- Returns:
- the seed
-
getBufferSize
public int getBufferSize()
Returns the buffer size of this anonymizer.- Returns:
- the buffer size
-
toAnonymized
protected abstract T toAnonymized(Integer id)
Turns the anonymous integer ID into the appropriate data type.- Parameters:
id- the ID to convert- Returns:
- the final result
-
fillBuffer
protected void fillBuffer()
Fills up the buffer with random values again.
-
anonymize
public T anonymize(T value)
Returns an anonymized value.- Parameters:
value- the value to anonymize- Returns:
- the anonymous value
-
hashCode
public int hashCode()
Returns the hashcode for this anonymizer (based on its ID).
-
-