Package org.eclipse.epsilon.emg.random
Interface IEmgRandomGenerator<K extends CharacterSet>
-
- All Superinterfaces:
org.apache.commons.math3.random.RandomGenerator
- All Known Implementing Classes:
EmgOperationContributor
,EmgRandomGenerator
public interface IEmgRandomGenerator<K extends CharacterSet> extends org.apache.commons.math3.random.RandomGenerator
The Random Attribute Generator interface defines the different available methods to generate random data. This can be boolean values, numbers and strings, or more specialized data as names, cities, emails, phone numbers, etc.- Author:
- Hoacio Hoyos
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
IEmgRandomGenerator.DefaultCharacterSet
static class
IEmgRandomGenerator.Distribution
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<java.lang.Integer>
nextAddTo(int n, int m)
Returns an array of n integers that addvar to m.double
nextBinomialValue(int numberOfTrials, double probabilityOfSuccess)
Generates a random value from the Binomial Distribution.java.lang.String
nextCamelCaseString(int length, int minWordLength)
Generates a random string of the given length using the specified character set formatted in CameCase format.java.lang.String
nextCapitalisedString(java.lang.String charSet, int length)
Next capitalised string.double
nextDobule(double upper)
Returns a pseudorandom, uniformly distributed double value between 0 (inclusive) and the specified value (exclusive), drawn from this random attribute generator's sequence.double
nextDobule(double lower, double upper)
Returns a pseudorandom, uniformly distributed double value between lower and upper (endpoints included), drawn from this random attribute generator's sequence.double
nextExponentialValue(double mean)
Generates a random value from the Exponential Distribution.java.lang.Object
nextFromCollection(java.util.Collection<?> c)
Returns a single object selected randomly from the Collection c using a uniform distribution.java.lang.Object
nextFromList(java.lang.String listID)
Returns a single objects selected randomly from the list using a uniform distribution.java.lang.Object
nextFromListAsSample(java.lang.String listID)
The list is treated as a sample without replacement, i.e.java.lang.String
nextHttpURI(boolean addPort, boolean addPath, boolean addQuery, boolean addFragment)
Generates a random URI that complies to: http:[//host[:port]][/]path[?query][#fragment] The scheme is The host is generated from a random string and uses a top-level domain.int
nextInteger(int upper)
Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random attribute generator's sequence.int
nextInteger(int lower, int upper)
Returns a pseudorandom, uniformly distributed int value between lower and upper (endpoints included), drawn from this random attribute generator's sequence.long
nextLong(long upper)
Returns a pseudorandom, uniformly distributed long value between 0 (inclusive) and the specified value (exclusive), drawn from this random attribute generator's sequence.long
nextLong(long lower, long upper)
Returns a pseudorandom, uniformly distributed long value between lower and upper (endpoints included), drawn from this random attribute generator's sequence.java.util.List<java.lang.Object>
nextSample(java.lang.String listID, int k)
Returns an array of k objects selected randomly from the list using a uniform distribution.java.util.List<java.lang.Object>
nextSample(java.util.Collection<?> c, int k)
Returns an array of k objects selected randomly from the Collection c using a uniform distribution.java.lang.String
nextString(java.lang.String charSet, int length)
Generates a random string of the given length using the specified character set.java.lang.String
nextURI()
Generates a random URI.java.lang.String
nextURI(boolean addPort, boolean addPath, boolean addQuery, boolean addFragment)
Generates a random URI that complies to: scheme:[//[user:password@]host[:port]][/]path[?query][#fragment] The scheme is randomly selected from: http, ssh and ftp.double
nextValue()
Returns the next pseudorandom, value from this random attribute generator's sequence.
-
-
-
Method Detail
-
nextAddTo
java.util.List<java.lang.Integer> nextAddTo(int n, int m) throws EolRuntimeException
Returns an array of n integers that addvar to m.- Parameters:
n
-m
-- Returns:
- Throws:
EolRuntimeException
-
nextBinomialValue
double nextBinomialValue(int numberOfTrials, double probabilityOfSuccess) throws EolRuntimeException
Generates a random value from the Binomial Distribution.- Parameters:
Distribution
-- Returns:
- Throws:
EolRuntimeException
-
nextCamelCaseString
java.lang.String nextCamelCaseString(int length, int minWordLength) throws EolRuntimeException
Generates a random string of the given length using the specified character set formatted in CameCase format. Characters are picked from the LETTER set using a uniform distribution.- Parameters:
length
- the lengthminWordLenght
- the minimum word length- Returns:
- the string
- Throws:
EolRuntimeException
-
nextCapitalisedString
java.lang.String nextCapitalisedString(java.lang.String charSet, int length)
Next capitalised string.- Parameters:
charSet
- the char setlength
- the length- Returns:
- the string
-
nextDobule
double nextDobule(double upper) throws EolRuntimeException
Returns a pseudorandom, uniformly distributed double value between 0 (inclusive) and the specified value (exclusive), drawn from this random attribute generator's sequence.- Parameters:
upper
-- Returns:
- Throws:
EolRuntimeException
-
nextDobule
double nextDobule(double lower, double upper) throws EolRuntimeException
Returns a pseudorandom, uniformly distributed double value between lower and upper (endpoints included), drawn from this random attribute generator's sequence.- Parameters:
lower
-upper
-- Returns:
- Throws:
EolRuntimeException
-
nextExponentialValue
double nextExponentialValue(double mean) throws EolRuntimeException
Generates a random value from the Exponential Distribution.- Parameters:
Distribution
-- Returns:
- Throws:
EolRuntimeException
-
nextFromCollection
java.lang.Object nextFromCollection(java.util.Collection<?> c)
Returns a single object selected randomly from the Collection c using a uniform distribution.- Parameters:
list
- the list- Returns:
- the t
-
nextFromList
java.lang.Object nextFromList(java.lang.String listID) throws EolRuntimeException
Returns a single objects selected randomly from the list using a uniform distribution. Particular implementations need to define what a valid listID is and how the data associated with it will be retrieved.- Parameters:
listID
- the listID- Returns:
- the t
- Throws:
EolRuntimeException
-
nextFromListAsSample
java.lang.Object nextFromListAsSample(java.lang.String listID) throws EolRuntimeException
The list is treated as a sample without replacement, i.e. each call will return a unique member of the list. Throws an exception if list is empty or if the method is invoked more times than the number of items in the list. Particular implementations need to define what a valid listID is and how the data associated with it will be retrieved.- Parameters:
listID
-- Returns:
- Throws:
EolRuntimeException
-
nextHttpURI
java.lang.String nextHttpURI(boolean addPort, boolean addPath, boolean addQuery, boolean addFragment) throws EolRuntimeException
Generates a random URI that complies to: http:[//host[:port]][/]path[?query][#fragment] The scheme is The host is generated from a random string and uses a top-level domain. The optional parameters will add additional information to the URI. The number of paths and queries are random between 1 and 4.- Parameters:
addPort
-addPath
-addQuery
-addFragment
-- Returns:
- Throws:
EolRuntimeException
-
nextInteger
int nextInteger(int upper) throws EolRuntimeException
Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random attribute generator's sequence.- Parameters:
upper
-- Returns:
- Throws:
EolRuntimeException
-
nextInteger
int nextInteger(int lower, int upper) throws EolRuntimeException
Returns a pseudorandom, uniformly distributed int value between lower and upper (endpoints included), drawn from this random attribute generator's sequence.- Parameters:
lower
-upper
-- Returns:
- Throws:
EolRuntimeException
-
nextLong
long nextLong(long upper) throws EolRuntimeException
Returns a pseudorandom, uniformly distributed long value between 0 (inclusive) and the specified value (exclusive), drawn from this random attribute generator's sequence.- Parameters:
upper
-- Returns:
- Throws:
EolRuntimeException
-
nextLong
long nextLong(long lower, long upper) throws EolRuntimeException
Returns a pseudorandom, uniformly distributed long value between lower and upper (endpoints included), drawn from this random attribute generator's sequence.- Parameters:
lower
-upper
-- Returns:
- Throws:
EolRuntimeException
-
nextSample
java.util.List<java.lang.Object> nextSample(java.util.Collection<?> c, int k) throws EolRuntimeException
Returns an array of k objects selected randomly from the Collection c using a uniform distribution. Particular implementations need to define what a valid listID is and how the data associated with it will be retrieved. Sampling from c is without replacement; but if c contains identical objects, the sample may include repeats. If all elements of c are distinct, the resulting object collection represents a Simple Random Sample of size k from the elements of c.- Throws:
EolRuntimeException
-
nextSample
java.util.List<java.lang.Object> nextSample(java.lang.String listID, int k) throws EolRuntimeException
Returns an array of k objects selected randomly from the list using a uniform distribution. Particular implementations need to define what a valid listID is and how the data associated with it will be retrieved. Sampling from the list is without replacement; but if the list contains identical objects, the sample may include repeats. If all elements of the list are distinct, the resulting object collection represents a Simple Random Sample of size k from the elements of c.- Throws:
EolRuntimeException
-
nextString
java.lang.String nextString(java.lang.String charSet, int length)
Generates a random string of the given length using the specified character set. Characters are picked from the set using a uniform distribution.- Parameters:
charSet
-length
-- Returns:
-
nextURI
java.lang.String nextURI() throws EolRuntimeException
Generates a random URI. The port, path, query and fragment are added randomly.- Returns:
- Throws:
EolRuntimeException
-
nextURI
java.lang.String nextURI(boolean addPort, boolean addPath, boolean addQuery, boolean addFragment) throws EolRuntimeException
Generates a random URI that complies to: scheme:[//[user:password@]host[:port]][/]path[?query][#fragment] The scheme is randomly selected from: http, ssh and ftp. For ssh and ftp, a user and pasword are randomly generated. The host is generated from a random string and uses a top-level domain. The optional parameters will add additional information to the URI. The number of paths and queries are random between 1 and 4.- Parameters:
addPort
-addPath
-addQuery
-addFragment
-- Returns:
- Throws:
EolRuntimeException
-
nextValue
double nextValue() throws EolRuntimeException
Returns the next pseudorandom, value from this random attribute generator's sequence. The value is picked from the defined distribution.- Parameters:
Distribution
-- Returns:
- Throws:
EolRuntimeException
-
-