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_Buffer
the buffer of unused random IDs.protected int
m_BufferSize
the buffer size.protected String
m_ID
the ID of the anonymizer (used for hashcode).protected Hashtable<T,Integer>
m_Mapping
the current mapping (actual value <-> random).protected Random
m_Random
for shuffling the IDs.protected long
m_Seed
the seed value.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractAnonymizer()
Default constructor.protected
AbstractAnonymizer(String id, int bufferSize)
Initializes the anonymizer with a random seed value.protected
AbstractAnonymizer(String id, long seed, int bufferSize)
Initializes the anonymizer.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description T
anonymize(T value)
Returns an anonymized value.protected void
fillBuffer()
Fills up the buffer with random values again.int
getBufferSize()
Returns the buffer size of this anonymizer.String
getID()
Returns the ID of this anonymizer.long
getSeed()
Returns the seed of this anonymizer.int
hashCode()
Returns the hashcode for this anonymizer (based on its ID).protected abstract T
toAnonymized(Integer id)
Turns the anonymous integer ID into the appropriate data type.String
toString()
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).
-
-