@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class ValuePattern extends java.lang.Object implements java.io.Serializable
[[
" or "]]
") will be
replaced with single opening or closing square brackets to distinguish
them from the square brackets used in numeric ranges or URL
references.x
' character followed by a numeric value to be
used as the increment, an optional '%
' character followed
by a format string as allowed by the DecimalFormat
class to define how the resulting value should be formatted, and a
closing square bracket to indicate the end of the range.%
' character followed by a format string as
allowed by the DecimalFormat
class to define how the
resulting value should be formatted, and a closing square bracket to
indicate the end of the range.SimpleDateFormat
class.
A pattern of "[timestamp:min=XXX:max=XXX]" will be replaced with a
randomly selected timestamp in generalized time format between the
given minimum and maximum timestamps (inclusive), which must be in
generalized time format. A pattern of
"[timestamp:min=XXX:max=XXX:format=XXX]" will be replaced with a
randomly selected timestamp in the specified format between the given
minimum and maximum timestamps (where the minimum and maximum
timestamp values must be in the generalized time format).
long
values. In a sequential numeric
range, if the first value is larger than the second value, then values will
be chosen in descending rather than ascending order (and if an increment is
given, then it should be positive). In addition, once the end of a
sequential range has been reached, then the value will wrap around to the
beginning of that range.
Hello
-- The static text "Hello
".[[Hello]]
-- The static text "[Hello]
" (note
that the double square brackets were replaced with single square
brackets).[0:1000]
-- A sequential numeric range that will iterate
in ascending sequential order from 0 to 1000. The 1002nd value that is
requested will cause the value to be wrapped around to 0 again.[1000:0]
-- A sequential numeric range that will iterate
in descending sequential order from 1000 to 0. The 1002nd value that is
requested will cause the value to be wrapped around to 1000 again.[0:1000x5%0000]
-- A sequential numeric range that will
iterate in ascending sequential order from 0 to 1000 in increments of
five with all values represented as four-digit numbers padded with
leading zeroes. For example, the first four values generated by this
component will be "0000", "0005", "0010", and "0015".[0-1000]
-- A random numeric range that will choose values
at random between 0 and 1000, inclusive.[0-1000%0000]
-- A random numeric range that will choose
values at random between 0 and 1000, inclusive, and values will be
padded with leading zeroes as necessary so that they are represented
using four digits.[random:5]
-- Will generate a string of five randomly
selected lowercase letters to be used in place of the bracketed
range.[random:4:0123456789abcdef]
-- Will generate a string of
four randomly selected hexadecimal digits to be used in place of the
bracketed range.[random:5:abcdefghijklmnopqrstuvwxyz]
-- Will generate a
string of five randomly selected lowercase letters to be used in place
of the bracketed range.[file:///tmp/mydata.txt]
-- A URL reference that will
cause randomly-selected lines from the specified local file to be used
in place of the bracketed range. To make it clear that the file
contents are randomly accessed, you may use randomfile
in place
of file
. The entire file will be read into memory, so this may
not be a suitable option for very large files.[sequentialfile:///tmp/mydata.txt]
-- A URL reference that
will cause lines from the specified local file, selected in sequential
order, to be used in place of the bracketed range. The entire file
will be read into memory, so this may not be a suitable option for very
large files.[streamfile:///tmp/mydata.txt]
-- A URL reference that
will cause lines from the specified local file, selected in sequential
order, to be used in place of the bracketed range. A background thread
will be used to read data from the file and place it into a queue so
that it is available quickly, but only a small amount of data will be
held in memory at any time, so this is a suitable option for very
large files.[timestamp]
-- The current time in generalized time
format, with millisecond precision.[timestamp:format=milliseconds]
-- The current time
expressed as the number of milliseconds since January 1, 1970 at
midnight UTC (that is, the output of
System.currentTimeMillis()
.[timestamp:format=seconds]
-- The current time expressed
as the number of seconds since January 1, 1970 at midnight UTC.[timestamp:format=yyyy-MM-dd'T'HH:mm:ss.SSSZ]
-- The
current time expressed in the specified format string.[timestamp:min=20180101000000.000Z:max=20181231235959.999Z:
format=yyyyMMddHHmmss]
-- A randomly selected timestamp
sometime in the year 2018 in the specified format.[http://server.example.com/tmp/mydata.txt]
-- A URL
reference that will cause randomly-selected lines from the specified
remote HTTP-accessible file to be used in place of the bracketed
range.[uuid]
-- Will cause a randomly generated UUID to be used
in place of the bracketed range.dc=example,dc=com
-- A value pattern containing only
static text and no numeric components.[1000:9999]
-- A value pattern containing only a numeric
component that will choose numbers in sequential order from 1000 to
9999.(uid=user.[1-1000000])
-- A value pattern that combines
the static text "(uid=user.
" with a value chosen randomly
between one and one million, and another static text string of
")
".uid=user.[1-1000000],ou=org[1-10],dc=example,dc=com
-- A
value pattern containing two numeric components interspersed between
three static text components.uid=user.[1-1000000],ou=org[ref:1],dc=example,dc=com
-- A
value pattern in which the organization number will be the same as the
randomly-selected user number.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PUBLIC_JAVADOC_URL
The URL to the publicly-accessible javadoc for this class, which provides
a detailed overview of the supported value pattern syntax.
|
Constructor and Description |
---|
ValuePattern(java.lang.String s)
Creates a new value pattern from the provided string.
|
ValuePattern(java.lang.String s,
java.lang.Long r)
Creates a new value pattern from the provided string.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
nextValue()
Retrieves the next value generated from the value pattern.
|
java.lang.String |
toString()
Retrieves a string representation of this value pattern, which will be the
original pattern string used to create it.
|
@NotNull public static final java.lang.String PUBLIC_JAVADOC_URL
public ValuePattern(@NotNull java.lang.String s) throws java.text.ParseException
s
- The string representation of the value pattern to create. It
must not be null
.java.text.ParseException
- If the provided string cannot be parsed as a valid
value pattern string.public ValuePattern(@NotNull java.lang.String s, @Nullable java.lang.Long r) throws java.text.ParseException
s
- The string representation of the value pattern to create. It
must not be null
.r
- The seed to use for the random number generator. It may be
null
if no seed is required.java.text.ParseException
- If the provided string cannot be parsed as a valid
value pattern string.