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

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

package toxgene.util.cdata.xmark;

import toxgene.core.random.ToxExponential;
import toxgene.interfaces.ToXgeneCdataGenerator;

/**
 * This class implements a simple CDATA generator that produces random
 * almost-readable text according to the grammar specified by the
 * XMark benchmark.
 * 

* This code is provided as part of ToXgene - (c) 2001 University of Toronto * and IBM Corporation. * * @author Denilson Barbosa * @version 1.0 */ public class Text implements ToXgeneCdataGenerator{ private static ToxExponential pickWord; private static String result; /** * Constructor. * * Note: cdata generated by this class uses the words stored by the * Names class. * * @see Names */ public Text(){ Names.init(); //this method loads the names into Names.data } /** * Specifies a seed for the random generator so that repeated * executions always produce the same content, if the same seed is * provided. * * @param seed random seed to initialize the random generator */ public void setRandomSeed(int seed){ pickWord = new ToxExponential(0,Names.len-1,3400,seed); } /** * Generates random text whose length is determined by the parameter * length. A value of -1 determines that a string of any length can * be returned; a positive value means that a string must be * truncated if necessary. * * @param length specifies the length of the CDATA value to be returned. */ public String getCdata(int length){ if (length == -1){ // this is dangerous: very long strings can be generated this way length = (int) (1024.0 * Math.random()); } result = new String(); while (result.length()




© 2015 - 2025 Weber Informatics LLC | Privacy Policy