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

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

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

import java.util.Random;

import toxgene.interfaces.ToXgeneCdataGenerator;

/**
 * This class implements a simple CDATA generator that produces random
 * province names according to the rules 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 Provinces implements ToXgeneCdataGenerator{ private static Random pick; private static String result; /** * 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){ pick = new Random(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){ result = data[pick.nextInt(len)]; //length == -1 means that the string should not be trimmed if (length == -1){ return result; } if (result.length() > length) return result.substring(0,length); else return result; } /** * These are the actual strings. We can declare this array here * explicitly because there are not too many contants. */ public final static String[] data={ "Alabama","Alaska","Arizona","Arkansas","California","Colorado", "Connecticut","Delaware","District Of Columbia","Florida","Georgia", "Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky", "Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota", "Mississipi","Missouri","Montana","Nebraska","Nevada","New Hampshire", "New Jersey","New Mexico","New York","North Carolina","North Dakota", "Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island", "South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont", "Virginia","Washington","West Virginia","Wisconsin","Wyoming" }; public final static int len = data.length; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy