// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
// 
// 	/**
// 	 * Indicates if this Synonym is short-lived or transient, meaning that
//      * it should not be stored in the synonyms file. Transient Synonyms
//      * are not stored, need to be calculated each run time.
// 	 *
// 	 * Transient synonyms are:
// 	 *
// 	 * <ol>
// 	 *     <li>Not stored in memory.</li>
// 	 *     <li>Not stored in the synonym file.</li>
// 	 * </ol>
// 	 *
// 	 * @return <code>true</code> if the synonym should be thrown away
// 	 * after use (not stored in the synonym file).
// 	 */
// 	boolean isShortLived();
// 
// 	/**
// 	 * @return The semantic data type of this Synonym, usually something
// 	 *         descriptive as "NAME" or "STREET".
// 	 */
// 	String getType();
// 
// 	/**
// 	 * @return The data which was in the original database for this Synonym
// 	 */
// 	Object getFrom();
// 
// 	/**
// 	 * 
// 	 * @return The data with which the original data in the database will be or
// 	 *         is replaced when the Anonymizer runs.
// 	 */
// 	Object getTo();
// }


import org.apache.log4j.Logger;
import com.rolfje.anonimatron.synonyms.Synonym;
package com.rolfje.anonimatron.anonymizer;



/**
 * Provides the same functionality as {@link CharacterStringAnonymizer}, but
 * uses the prefetch cycle to collect its output character set. This causes
 * the anonymized dataset to contain the same characters as used the input set,
 * enabling debugging/reproduction of strange character set issues.
 * 
 * @author rolf
 */
public class CharacterStringPrefetchAnonymizer extends CharacterStringAnonymizer implements Prefetcher {
	private static final Logger LOG = Logger.getLogger(CharacterStringPrefetchAnonymizer.class);

	public CharacterStringPrefetchAnonymizer() {
		CHARS = "";
	}

	@Override
	public void prefetch(Object sourceData) {
		if (sourceData == null) {
			return;
		}

		char[] sourcechars = sourceData.toString().toCharArray();
		for (char c : sourcechars) {
			if (CHARS.indexOf(c) == -1) {
				CHARS += c;
			}
		}
	}

	@Override
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
// 
// 	/**
// 	 * Indicates if this Synonym is short-lived or transient, meaning that
//      * it should not be stored in the synonyms file. Transient Synonyms
//      * are not stored, need to be calculated each run time.
// 	 *
// 	 * Transient synonyms are:
// 	 *
// 	 * <ol>
// 	 *     <li>Not stored in memory.</li>
// 	 *     <li>Not stored in the synonym file.</li>
// 	 * </ol>
// 	 *
// 	 * @return <code>true</code> if the synonym should be thrown away
// 	 * after use (not stored in the synonym file).
// 	 */
// 	boolean isShortLived();
// 
// 	/**
// 	 * @return The semantic data type of this Synonym, usually something
// 	 *         descriptive as "NAME" or "STREET".
// 	 */
// 	String getType();
// 
// 	/**
// 	 * @return The data which was in the original database for this Synonym
// 	 */
// 	Object getFrom();
// 
// 	/**
// 	 * 
// 	 * @return The data with which the original data in the database will be or
// 	 *         is replaced when the Anonymizer runs.
// 	 */
// 	Object getTo();
// }


// Path: src/main/java/com/rolfje/anonimatron/anonymizer/CharacterStringPrefetchAnonymizer.java
import org.apache.log4j.Logger;
import com.rolfje.anonimatron.synonyms.Synonym;

package com.rolfje.anonimatron.anonymizer;



/**
 * Provides the same functionality as {@link CharacterStringAnonymizer}, but
 * uses the prefetch cycle to collect its output character set. This causes
 * the anonymized dataset to contain the same characters as used the input set,
 * enabling debugging/reproduction of strange character set issues.
 * 
 * @author rolf
 */
public class CharacterStringPrefetchAnonymizer extends CharacterStringAnonymizer implements Prefetcher {
	private static final Logger LOG = Logger.getLogger(CharacterStringPrefetchAnonymizer.class);

	public CharacterStringPrefetchAnonymizer() {
		CHARS = "";
	}

	@Override
	public void prefetch(Object sourceData) {
		if (sourceData == null) {
			return;
		}

		char[] sourcechars = sourceData.toString().toCharArray();
		for (char c : sourcechars) {
			if (CHARS.indexOf(c) == -1) {
				CHARS += c;
			}
		}
	}

	@Override
	public Synonym anonymize(Object from, int size, boolean shortlived) {