All Downloads are FREE. Search and download functionalities are using the official Maven repository.

toxgene.util.cdata.xmark.MultiWordNames Maven / Gradle / Ivy

The newest version!
/**
 * 
 */
package toxgene.util.cdata.xmark;

import java.util.Random;

import toxgene.interfaces.ToXgeneCdataGenerator;

/**
 * @author lord_pretzel
 *
 */
public class MultiWordNames implements ToXgeneCdataGenerator {

	private static Names words;
	private static Random pick;
	
	public MultiWordNames () {
		words = new Names();
	}
	
	/* (non-Javadoc)
	 * @see toxgene.interfaces.ToXgeneCdataGenerator#setRandomSeed(int)
	 */
	@Override
	public void setRandomSeed(int seed) {
		pick = new Random(seed);
		words.setRandomSeed(seed);
	}

	/* (non-Javadoc)
	 * @see toxgene.interfaces.ToXgeneCdataGenerator#getCdata(int)
	 */
	@Override
	public String getCdata(int length) {
		String result = words.getCdata(length);

		//length == -1 means that the string should not be trimmed
		if (length == -1){
			return result;
		}
		
		while (result.length() < length) {
			result += words.getCdata(length);
		}
		
		if (result.length() > length)
			return result.substring(0,length);
		else
			return result;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy