|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.moyoman.module.ModuleConfig
Read and write configuration information related to modules. This class is responsible for the following types of information:
| Field Summary | |
private HashMap |
allModules
|
private HashMap |
hashmaps
The key is the mode name. |
private static HelperConfigTool |
hct
The HelperConfigTool object. |
private static ModuleConfig |
mc
Only one ModuleConfig object is created. |
private ModuleType[] |
orderedModuleTypes
The ModuleType objects are ordered from first to last. |
private static ServerConfig |
sc
The ServerConfig object. |
private static String |
topDir
The top level directory of the moyoman distribution. |
| Constructor Summary | |
protected |
ModuleConfig()
Create the ModuleConfig object. |
| Method Summary | |
protected void |
addMode(Mode newMode,
Mode oldMode)
Add a new mode which has the same ordering of module names as the existing mode. |
protected void |
addModuleName(ModuleName mn)
Add the module name at the end of the list for the given module type. |
protected void |
addModuleType(ModuleType mt,
int index)
Insert module type into the ordered list of modules. |
protected void |
cancel()
Undo all changes made since the last call to save() or cancel(). |
boolean |
checkModuleTypeOrder(ModuleType earlier,
ModuleType later)
Check the relationship in question. |
protected void |
deleteMode(String name)
Delete the mode. |
protected void |
deleteModuleName(ModuleName mn)
Delete the ModuleName from the list for the given module type. |
protected void |
deleteModuleType(ModuleType mt)
Delete the ModuleType object from the list. |
protected ModuleName[] |
getAllModuleNames()
Get an array of all module names, in no particular order. |
protected ModuleType[] |
getAllModuleTypes()
Get an array of all module types in ascending order. |
ModuleName |
getFirstModuleName(Mode mode,
ModuleType type)
Get the most highly ranked ModuleName for the given mode and module type. |
static ModuleConfig |
getModuleConfig()
Get the singleton ModuleConfig object. |
ModuleName[] |
getModuleNames(Mode mode,
ModuleType type)
Get the module names for the mode and module type. |
private ModuleName[] |
getModuleNamesForTypeAndMode(Element elem,
ModuleType mt,
Properties props)
Get the ModuleName objects in order for the module type and mode. |
private void |
indentLine(BufferedWriter bw,
int level)
Convenience method to write out the appropriate number of spaces. |
private void |
processNodes(NodeList nl,
ModuleType mt,
Properties props)
This method processes the module.xml entry for a single module type. |
protected void |
save()
Save the information in this object to permanent storage. |
void |
setModuleNameOrder(Mode mode,
ModuleType type,
ModuleName[] names)
Set the module name order for a given module type and mode. |
void |
setModuleTypeOrder(ModuleType[] types)
Set the mode type order. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private HashMap hashmaps
private ModuleType[] orderedModuleTypes
private HashMap allModules
private static String topDir
private static ServerConfig sc
private static ModuleConfig mc
private static HelperConfigTool hct
| Constructor Detail |
protected ModuleConfig()
throws InternalErrorException
InternalErrorException - Thrown is the operation fails for any reason.| Method Detail |
private void processNodes(NodeList nl,
ModuleType mt,
Properties props)
throws InconsistentStateException
nl - A NodeList object obtained by the XML parser.mt - The ModuleType being parsed.props - A Properties file containing module name information.
InconsistentStateExceptionpublic static ModuleConfig getModuleConfig()
protected ModuleType[] getAllModuleTypes()
protected ModuleName[] getAllModuleNames()
private ModuleName[] getModuleNamesForTypeAndMode(Element elem,
ModuleType mt,
Properties props)
throws InconsistentStateException
elem - The Element corresponding to the Mode entrymt - The ModuleType being processed.props - The properties object with the module name information.
InconsistentStateException - - Thrown if the ranking information
does not consist of one entry for each integer between 1 and the number
of ModuleName objects.
public boolean checkModuleTypeOrder(ModuleType earlier,
ModuleType later)
earlier - A module type to be used by later.later - A module type that wishes to use earlier.
public ModuleName getFirstModuleName(Mode mode,
ModuleType type)
throws NoSuchDataException
mode - The specific mode.type - The specific module type.
NoSuchDataException - Thrown if there is no ModuleName specified for the parameters.
public ModuleName[] getModuleNames(Mode mode,
ModuleType type)
mode - The mode of the game, such as BEST.type - The module type.
protected void addModuleType(ModuleType mt,
int index)
throws IllegalArgumentException,
DataAlreadyExistsException
mt - The ModuleType object to be added.index - The position to insert the module type at; first position is 0.
IllegalArgumentException
DataAlreadyExistsException
protected void deleteModuleType(ModuleType mt)
throws PermissionsException,
NoSuchDataException
mt - The ModuleType object to delete.
PermissionsException - Throw an exception if there are any ModuleName objects
associated with this ModuleType object.
NoSuchDataException - Thrown if the module type is not in the list.protected void addModuleName(ModuleName mn)
mn - The ModuleName object.protected void deleteModuleName(ModuleName mn)
mn - The ModuleName object to be deleted.
protected void addMode(Mode newMode,
Mode oldMode)
throws DataAlreadyExistsException
newMode - The mode to be added.oldMode - The mode for which the ordering of module names is to be copied from.
DataAlreadyExistsException - Thrown if the new mode already exists.
protected void deleteMode(String name)
throws PermissionsException,
NoSuchDataException
name - The name of the mode.
PermissionsException - Thrown if the mode is a standard mode.
NoSuchDataException - Thrown if the mode does not exist.
protected void cancel()
throws InternalErrorException
InternalErrorException - Thrown if the operation fails for any reason.
protected void save()
throws InternalErrorException
InternalErrorException
private void indentLine(BufferedWriter bw,
int level)
throws InternalErrorException
bw - The BufferedWriter to write the spaces to.level - The number of levels to indent.
InternalErrorException - Thrown if the operation fails for any reason.
public void setModuleNameOrder(Mode mode,
ModuleType type,
ModuleName[] names)
mode - The mode of the game, such as FAST.type - The module type.names - The module names in order from most preferred to least preferred.public void setModuleTypeOrder(ModuleType[] types)
types - An array of module types, from first to last.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||