net.sourceforge.jaulp.random
Class RandomUtils

java.lang.Object
  extended by net.sourceforge.jaulp.random.RandomUtils

public class RandomUtils
extends java.lang.Object

Utility class for producing random data.

Version:
1.0
Author:
Asterios Raptis

Constructor Summary
RandomUtils()
           
 
Method Summary
static java.lang.String createdRandomName(char[] donatedChars)
          Creates a random Name from the donated chararray.
static java.lang.String createRandomId()
          Creates a random id and returns it.
static java.lang.String getInfomailFromWebsite(java.lang.String url)
          Gets an infomail address from the given url.
static java.lang.String getRandomEmail()
          The Method getRandomEmail() gets a random email-address.
static
<T> T
getRandomEntry(java.util.List<T> list)
          Returns a random entry from the given List.
static
<K,V> java.lang.Object
getRandomEntry(java.util.Map<K,V> map)
          Returns a random entry from the given map.
static java.lang.String getRandomFaxnumber(java.lang.String phonenumber)
          Gets a random faxnumber from a phone.
static float getRandomFloat(int afterComma, int beforeComma)
          The Method getRandomFloat(int,int) gets an random float.
static java.lang.String getRandomHellenicBirthName(java.lang.String lastname)
          Returns a random hellenic birthname.
static java.lang.String getRandomHellenicCompany()
          Gets a random hellenic company.
static java.lang.String getRandomHellenicContactPerson()
          Gets a random hellenic contact person.
static java.lang.String getRandomHellenicFirstName()
          Returns a random hellenic firstname.
static java.lang.String getRandomHellenicLastName()
          Returns a random hellenic lastname.
static java.lang.String getRandomHellenicStreet()
          Get's a random hellenic streetname.
static java.lang.String[] getRandomHellenicZipAndCity()
          Get's a random hellenic zip and city.
static int getRandomIntBetween(int start, int end)
          Returns a random int between the range from start and end.
static
<K,V> java.lang.Object
getRandomKey(java.util.Map<K,V> map)
          Returns a random key from the given map.
static java.lang.String getRandomMobilnumber()
          Gets a random mobil number from a mobilphone.
static java.lang.String getRandomNumber(int length)
          The Method getRandomNumber(int) produces a random Number to the specified length.
static java.lang.String getRandomPassword(int length)
          The Method getRandomPassword(int) produces a random password.
static java.lang.String getRandomPhonenumber()
          Gets a random phonenumber.
static java.lang.String getRandomWebsite()
          Gets a random name for a website.
static boolean randomBoolean()
          Returns a random boolean.
static char randomChar(java.lang.String string)
          The Method randomChar(String) selects a random char from the given String.
static int randomInt(int range)
          The Method randomInt(int) gets an int to the spezified range.
static java.lang.String randomString(java.lang.String[] array)
          The Method randomString(String []) a random String from the Array For example: The Stringarray test as argument.
static java.lang.String randomString(java.lang.String chars, int length)
          The Method randomString(String, int) makes an random String from the given String and to the spezified length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomUtils

public RandomUtils()
Method Detail

createdRandomName

public static java.lang.String createdRandomName(char[] donatedChars)
Creates a random Name from the donated chararray.

Parameters:
donatedChars - The Characters for the name.
Returns:
A random Name.

createRandomId

public static java.lang.String createRandomId()
Creates a random id and returns it.

Returns:
the created random id.

getInfomailFromWebsite

public static java.lang.String getInfomailFromWebsite(java.lang.String url)
Gets an infomail address from the given url.

Parameters:
url - The url.
Returns:
Returns an infomail address from the given url.

getRandomEmail

public static java.lang.String getRandomEmail()
The Method getRandomEmail() gets a random email-address.

Returns:
The random email-address.

getRandomEntry

public static <T> T getRandomEntry(java.util.List<T> list)
Returns a random entry from the given List.

Parameters:
list - The map.
Returns:
Return's a random entry from the List.

getRandomEntry

public static <K,V> java.lang.Object getRandomEntry(java.util.Map<K,V> map)
Returns a random entry from the given map.

Parameters:
map - The map.
Returns:
Return's a random entry from the map.

getRandomFaxnumber

public static java.lang.String getRandomFaxnumber(java.lang.String phonenumber)
Gets a random faxnumber from a phone.

Parameters:
phonenumber - The phonenumber.
Returns:
Return's a random faxnumber from a phone.

getRandomFloat

public static float getRandomFloat(int afterComma,
                                   int beforeComma)
The Method getRandomFloat(int,int) gets an random float.

Parameters:
afterComma - How many decimal places after the comma.
beforeComma - How many decimal places before the comma.
Returns:
The produced float.

getRandomHellenicBirthName

public static java.lang.String getRandomHellenicBirthName(java.lang.String lastname)
Returns a random hellenic birthname. The encoding is the charset ISO-8859-7.

Returns:
Return's a random hellenic birthname.

getRandomHellenicCompany

public static java.lang.String getRandomHellenicCompany()
Gets a random hellenic company.

Returns:
Return's a random hellenic company.

getRandomHellenicContactPerson

public static java.lang.String getRandomHellenicContactPerson()
Gets a random hellenic contact person.

Returns:
Return's a random hellenic contact person.

getRandomHellenicFirstName

public static java.lang.String getRandomHellenicFirstName()
Returns a random hellenic firstname. The encoding is the charset ISO-8859-7.

Returns:
The random hellenic firstname.

getRandomHellenicLastName

public static java.lang.String getRandomHellenicLastName()
Returns a random hellenic lastname. The encoding is the charset ISO-8859-7.

Returns:
The random hellenic lastname.

getRandomHellenicStreet

public static java.lang.String getRandomHellenicStreet()
Get's a random hellenic streetname.

Returns:
Return's a random hellenic streetname.

getRandomHellenicZipAndCity

public static java.lang.String[] getRandomHellenicZipAndCity()
Get's a random hellenic zip and city.

Returns:
Return's a random hellenic zip and city.

getRandomIntBetween

public static int getRandomIntBetween(int start,
                                      int end)
Returns a random int between the range from start and end.

Parameters:
start - The int from where the range starts.
end - The int from where the range ends.
Returns:
A random int between the range from start and end.

getRandomKey

public static <K,V> java.lang.Object getRandomKey(java.util.Map<K,V> map)
Returns a random key from the given map.

Parameters:
map - The map.
Returns:
Return's a random key from the map.

getRandomMobilnumber

public static java.lang.String getRandomMobilnumber()
Gets a random mobil number from a mobilphone.

Returns:
Return's a random mobil number from a mobilphone.

getRandomNumber

public static java.lang.String getRandomNumber(int length)
The Method getRandomNumber(int) produces a random Number to the specified length.

Parameters:
length - The length from the random number.
Returns:
The random number as String.

getRandomPassword

public static java.lang.String getRandomPassword(int length)
The Method getRandomPassword(int) produces a random password.

Parameters:
length - The length from the password.
Returns:
The password.

getRandomPhonenumber

public static java.lang.String getRandomPhonenumber()
Gets a random phonenumber.

Returns:
Return's a random phonenumber.

getRandomWebsite

public static java.lang.String getRandomWebsite()
Gets a random name for a website.

Returns:
Returns a random name for a website.

randomBoolean

public static boolean randomBoolean()
Returns a random boolean.

Returns:
The random boolean.

randomChar

public static char randomChar(java.lang.String string)
The Method randomChar(String) selects a random char from the given String.

Parameters:
string - The String from who to select the char.
Returns:
The selected char.

randomInt

public static int randomInt(int range)
The Method randomInt(int) gets an int to the spezified range. For example: if you put bereich to 10 the random int is between 0-9.

Parameters:
range - The Range.
Returns:
an int not greater then the range.

randomString

public static java.lang.String randomString(java.lang.String chars,
                                            int length)
The Method randomString(String, int) makes an random String from the given String and to the spezified length. This can be used to produce passwords.

Parameters:
chars - The String to get the random chars.
length - The length from the random String.
Returns:
The produced random String.

randomString

public static java.lang.String randomString(java.lang.String[] array)
The Method randomString(String []) a random String from the Array For example: The Stringarray test as argument. Possible values: "blab", "flih", "klap", "teta", "brut", "gzft", "ccp". Possible selection can be one value from the Stringarray like "blab" or "klap".

Parameters:
array - The array with the String to be selected.
Returns:
The selected String from the array.


Copyright © 2010. All Rights Reserved.