Class Xeger


  • public class Xeger
    extends Object
    An object that will generate text from a regular expression. In a way, it's the opposite of a regular expression matcher: an instance of this class will produce text that is guaranteed to match the regular expression passed in. slight modifications by Marcin Grzejszczak
    • Constructor Detail

      • Xeger

        public Xeger​(String regex,
                     Random random)
        Constructs a new instance, accepting the regular expression and the randomizer.
        Parameters:
        regex - The regular expression. (Not null.)
        random - The object that will randomize the way the String is generated. (Not null.)
        Throws:
        IllegalArgumentException - If the regular expression is invalid.
    • Method Detail

      • generate

        public String generate()
        Generates a random String that is guaranteed to match the regular expression passed to the constructor.
        Returns:
        generated regexp
      • getRandom

        public Random getRandom()
      • setRandom

        public void setRandom​(Random random)