|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sourceforge.worldsaver.names.Names
This is Names, the class doing all the work in this package. With some configuration this class can be used to generate pronouncable words (currently just with the english alphabet). If you want to use this class, you should carefully read the methods to make sure you know what you are doing.
This class can also be called directly by java as a commandline tool.
Field Summary | |
protected Localizer |
lang
|
static java.lang.String |
VERSION
Version information. |
Fields inherited from interface net.sourceforge.worldsaver.util.MiscUtils |
CONSOLE_WIDTH, NEWLINE, RANDOM |
Constructor Summary | |
Names()
The constructor initializes a properties object with some standard values. |
Method Summary | |
void |
cleanFilters()
This methods cleans out unnecessary entries in the filters. |
void |
createConfigvalues()
This method creates new configvalues by analyzing the inputfile. |
void |
createFiltervalues()
This is the method which creates the filters magically. |
java.lang.String |
getConfigfile()
Returns the name of the configfile |
java.lang.String |
getFilterfile()
Returns the name of the filterfile |
java.lang.String |
getInputfile()
Returns the name of the inputfile |
int[] |
getLengthOfMagic()
Returns the length of names generated by createFiltervalues(). |
java.lang.String |
getLengthOfMagicString()
Returns the length of names generated by createFiltervalues(). |
int |
getLengthOfNames()
Returns the length of generated names |
int |
getLengthOfTask()
Returns the length of the current task. |
java.lang.String |
getMessage()
Returns a message on what the running thread is doing right now. |
java.lang.String |
getName(int length)
Ever wanted to get a name computed without using your fantasy? |
java.lang.String |
getNames()
This method returns the predefined number of names as one string (names seperated by newlines). |
int |
getNumberOfNames()
Returns the number of generated names at once |
int |
getNumberToGenerate()
Returns the amount of names that are generated for each setLengthOfMagic item when calling createFiltervalues() |
java.lang.String |
getOptionsfile()
Returns the name of the optionsfile |
int |
getStatus()
Indicates the percentile of completion of the current running thread. |
boolean |
getVerbose()
Returns whether there will be output on stdout |
boolean |
hasConfig()
Indicates if configuration data has been created or loaded or not. |
boolean |
hasInput()
Indicates if an inputfile has already been loaded. |
boolean |
isReady()
Indicates whether a thread is running in this names object or not. |
void |
loadOptions()
Simply loads options from file. |
static void |
main(java.lang.String[] args)
Run this to run the cmdline application Names. |
static void |
printUsage(Localizer l)
Just prints out cmdline-usage and exits. |
void |
prooveConfig()
You must run this method to make sure that the instance can be used to create names. |
void |
readConfigfile()
This method reads configvalues from file and overrides the old ones. |
void |
readFilterfile()
This methods appends a filterfile to the actual values. |
void |
readInputfile()
This method loads a textfile into memory and splits it into words. |
void |
saveConfigfile()
Saves configfile to disk. |
void |
saveFilterfile()
Saves the filterfile. |
void |
saveOptions()
Simply saves current options to file. |
void |
setConfigfile(java.lang.String v)
Sets the name of the configfile |
void |
setFilterfile(java.lang.String v)
Sets the name of the filterfile |
void |
setInputfile(java.lang.String v)
Sets the name of the inputfile |
void |
setLengthOfMagic(int[] a)
Sets the length and (partially) the number of names that are generated by createFiltervalues(). |
void |
setLengthOfMagic(java.lang.String v)
Sets the length and (partially) the number of names that are generated by createFiltervalues(). |
void |
setLengthOfNames(int v)
Sets the length of names to be generated |
void |
setNumberOfNames(int v)
Sets the number of names to generate at once |
void |
setNumberToGenerate(int v)
Sets the amount of names that are generated for each setLengthOfMagic item when calling createFiltervalues() |
void |
setOptionsfile(java.lang.String v)
Sets the name of the optionsfile |
void |
setReady(boolean v)
Sets that a thread runs now in this instance. |
void |
setVerbose(boolean v)
Sets whether there should be output on stdout or not. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String VERSION
protected Localizer lang
Constructor Detail |
public Names() throws java.io.IOException
Method Detail |
public void setOptionsfile(java.lang.String v)
v
- The new filenamepublic java.lang.String getOptionsfile()
public void setConfigfile(java.lang.String v)
v
- The new filenamepublic java.lang.String getConfigfile()
public void setFilterfile(java.lang.String v)
v
- The new filenamepublic java.lang.String getFilterfile()
public void setInputfile(java.lang.String v)
v
- The new filenamepublic java.lang.String getInputfile()
public void setLengthOfNames(int v)
v
- The new lengthpublic int getLengthOfNames()
public void setNumberOfNames(int v)
v
- The new numberpublic int getNumberOfNames()
public void setNumberToGenerate(int v)
v
- The new numberpublic int getNumberToGenerate()
public void setVerbose(boolean v)
v
- false means no outputpublic boolean getVerbose()
public void setLengthOfMagic(java.lang.String v)
v
- A comma seperated list of integers, e.g. v="2,3"public void setLengthOfMagic(int[] a)
v
- An integer array containing the valuespublic int[] getLengthOfMagic()
public java.lang.String getLengthOfMagicString()
public boolean isReady()
public boolean hasInput()
public boolean hasConfig()
public int getStatus()
public void setReady(boolean v)
public java.lang.String getMessage()
public int getLengthOfTask()
public void loadOptions() throws java.io.IOException
public void saveOptions() throws java.io.IOException
public void prooveConfig() throws WrongConfigvaluesException
public void saveConfigfile() throws java.io.IOException
java.io.IOException
- if the file could not be readpublic void createConfigvalues()
public void readConfigfile() throws java.io.IOException, java.lang.ClassNotFoundException
public void readInputfile() throws java.io.IOException
public void createFiltervalues()
This is the method which creates the filters magically. It generates (by default) 10000 two character names and 10000 three character names. Each of them is prooved to occur in the inputfile's words at the beginning, in the middle and in the ends. If the `name' is not found, we have a new filter.
You can run this method as often as you want to, but beware: it costs a LOT of time.
NOTE: This method can hang, if the inputfile is too small/bad or the filterfile contains too much filters. (It's not really this method that hangs then, but the getName[s]() method; although this situation only occurs when adding new filters.)
public void readFilterfile() throws java.io.IOException
public void saveFilterfile() throws java.io.IOException
public void cleanFilters()
public java.lang.String getName(int length)
public java.lang.String getNames()
public static void printUsage(Localizer l)
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |