public class CFGSongNameEngine extends AbstractSongNameEngine
Modifier and Type | Class and Description |
---|---|
protected static class |
CFGSongNameEngine.RandomStrings
Container for random strings.
|
Modifier and Type | Field and Description |
---|---|
protected String |
startVariable
The start variable.
|
protected char |
stringSeparator
The separator.
|
protected static Pattern |
VARIABLE_PATTERN
The pattern for variable replacement.
|
protected Map<String,CFGSongNameEngine.RandomStrings> |
variableMap
The variable map.
|
randomSeed
Constructor and Description |
---|
CFGSongNameEngine() |
Modifier and Type | Method and Description |
---|---|
void |
configure(SongContext songContext,
Node node)
Configures the instance using the specified XML node.
|
String |
createSongName()
Generates and returns a song name.
|
Map<String,CFGSongNameEngine.RandomStrings> |
getVariableMap() |
static String |
replaceVariables(String string,
Map<String,CFGSongNameEngine.RandomStrings> variableMap,
Random random)
Recursively replaces all variables in the given string by a randomly chosen value from the corresponding variable map values.
|
void |
setVariableMap(Map<String,CFGSongNameEngine.RandomStrings> variableMap) |
getRandomSeed, setRandomSeed
protected static final Pattern VARIABLE_PATTERN
protected Map<String,CFGSongNameEngine.RandomStrings> variableMap
protected String startVariable
protected char stringSeparator
public String createSongName()
SongNameEngine
public void configure(SongContext songContext, Node node) throws XPathException
XMLConfigurable
songContext
- the song contextnode
- the parent XML node of the configuration tagsXPathException
- in case of an XPath problempublic static String replaceVariables(String string, Map<String,CFGSongNameEngine.RandomStrings> variableMap, Random random)
string
- the string to perform replacements invariableMap
- the variable maprandom
- the random generator to usepublic Map<String,CFGSongNameEngine.RandomStrings> getVariableMap()
public void setVariableMap(Map<String,CFGSongNameEngine.RandomStrings> variableMap)