toxgene.util.cdata.xmark.MultiWordNames Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ToxGene Show documentation
Show all versions of ToxGene Show documentation
Modified ToXGene for the iBench project.
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;
}
}