Class NameGenerator


  • public class NameGenerator
    extends Object
    A NameGenerator generates a sequence of names as strings in the form "prefix"+i for integer i. Pads the counter with zeros to ensure a minimum number of digits determined by field digits.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int counter
      The number to use for the next name to generate.
      private String format
      The format string to generate a name; takes one integer parameter.
    • Constructor Summary

      Constructors 
      Constructor Description
      NameGenerator​(@Identifier String prefix)
      Generates names without 0-padding on counter.
      NameGenerator​(@Identifier String prefix, int initialValue, int lastValue)
      Creates an instance that generates names beginning with prefix, counts starting at the initialValue, and 0-padded to enough digits for lastValue.
    • Field Detail

      • counter

        private int counter
        The number to use for the next name to generate.
      • format

        private String format
        The format string to generate a name; takes one integer parameter.
    • Constructor Detail

      • NameGenerator

        public NameGenerator​(@Identifier String prefix,
                             int initialValue,
                             int lastValue)
        Creates an instance that generates names beginning with prefix, counts starting at the initialValue, and 0-padded to enough digits for lastValue.
        Parameters:
        prefix - a string to be used as the prefix for all generated names
        initialValue - integer starting value for name counter
        lastValue - the last expected number, to determine 0-padding; 0 for no padding
      • NameGenerator

        public NameGenerator​(@Identifier String prefix)
        Generates names without 0-padding on counter.
        Parameters:
        prefix - is a string to be used as a prefix for all names generated
    • Method Detail

      • next

        public @Identifier String next()
        Return a new gensym (unique identifier).
        Returns:
        the next identifier in the sequence produced by this