Menu

SubnameFactory

William A. Hood

SubnameFactory

This object provides an easy way to append an incremental letter to a string. An example might be a test case identifier with an unspecified number of similar subordinate tests ("100A", "100B", "100C", etc.). The index value may be retrieved as a letter or numeric, with or without preceding zeros.

Constructors

SubnameFactory() - The default constructor.

SubnameFactory(long startingIndex) - Allows you to specify a Long value as the starting index. Specifying 2 would start with 'B'. This can be used to force a unique sequence of letters by passing "new Date().getTime()" as the startingIndex parameter.

SubnameFactory(long startingIndex, int totalPlaces) - In addition to specifying a starting index as above, this constructor also allows you to specify the total number of places in returned string values. Unused places will be zeros regardless of whether the letter or numeric index is retrieved.

Member Methods

void advance() - Advances the index by one.

String getCurrentIndexAsString() - Returns a string representation of the Long index value, prepended with the appropriate number of zeros.

String getNextIndexAsString() - Equivalent to calling advance() then getCurrentIndexAsString().

long getCurrentIndex() - Returns the current index as a Long integer value. Prepending with zeros is not supported, as the return value is not a string.

long getNextIndex() - Equivalent to calling advance() then getCurrentIndex().

String getCurrentSubname() - Returns the letter value of the current index. This starts as "A" through "Z", then "AA" through "AZ", then "BA" through "BZ", etc.

String getNextSubname() - Equivalent to calling advance() then getCurrentSubname().


Related

Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.