Package adams.data

Class AbstractAnonymizer<T>

    • Field Detail

      • m_ID

        protected String m_ID
        the ID of the anonymizer (used for hashcode).
      • m_Seed

        protected long m_Seed
        the seed value.
      • m_Random

        protected Random m_Random
        for shuffling the IDs.
      • m_BufferSize

        protected int m_BufferSize
        the buffer size.
      • m_Buffer

        protected ArrayList<Integer> m_Buffer
        the buffer of unused random IDs.
      • m_Mapping

        protected Hashtable<T,​Integer> m_Mapping
        the current mapping (actual value <-> random).
    • 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 anonymizer
        bufferSize - 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 anonymizer
        seed - the seed value for the random number generator
        bufferSize - 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).
        Overrides:
        hashCode in class Object
        Returns:
        the hashcode
      • toString

        public String toString()
        Returns a short description of the anonymizer.
        Overrides:
        toString in class Object
        Returns:
        the description