|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.moyoman.helper.HelperConfig
Read and write configuration information related to helpers. This class is responsible for the following types of information:
Field Summary | |
private HashMap |
allHelpers
The key is a String (simple name) and the value is a HelperName object. |
private ArrayList |
allHelperTypes
Each element is a HelperType object. |
private HashMap |
hashmaps
The key is the mode name. |
private static HelperConfig |
hc
The HelperConfig object. |
private HashMap |
hhMapping
The key is the HelperType child, and the value the HelperType parent. |
private HashMap |
hmMapping
The key is the HelperType child, and the value the ModuleType parent. |
private static ServerConfig |
sc
The ServerConfig object. |
private static String |
topDir
The top directory of the Moyoman software. |
Constructor Summary | |
protected |
HelperConfig()
Create a HelperConfig object. |
Method Summary | |
protected void |
addHelperName(HelperName hn)
Add the helper name at the end of the list for the given helper type. |
protected void |
addHelperType(HelperType ht,
ComponentType parent)
Add helper type to the list. |
protected void |
addMode(Mode newMode,
Mode oldMode)
Create a new user defined mode. |
protected void |
associate(HelperType ht,
ComponentType parent)
Associate a helper type with a component type as its parent. |
protected void |
cancel()
Undo all operations performed since the last save() or cancel() call. |
protected void |
deleteHelperName(HelperName hn)
Delete the helper name from the list for the given helper type. |
void |
deleteHelperType(HelperType ht)
Delete the HelperType object from the list. |
protected void |
deleteMode(String name)
Delete the mode. |
HelperName[] |
getAllHelperNames()
Get all the HelperName objects. |
HelperType[] |
getAllHelperTypes()
Get all the HelperType objects. |
protected HelperType[] |
getAllHelperTypes(HelperType ht)
Return all of the helper types which have the specified helper type as a parent. |
protected HelperType[] |
getAllHelperTypes(ModuleType mt)
Return all of the helper types which have the specified module type as a parent. |
HelperName |
getFirstHelperName(Mode mode,
HelperType type)
Get the most preferred HelperName object for this mode and helper type. |
static HelperConfig |
getHelperConfig()
Get the singleton HelperConfig object. |
HelperName[] |
getHelperNames(Mode mode,
HelperType type)
Get the helper names for the mode and helper type. |
private HelperName[] |
getHelperNamesForTypeAndMode(Element elem,
HelperType ht,
Properties props)
Get the HelperType objects in order for the HelperType and mode. |
ComponentType |
getParent(HelperType ht)
Get the parent type of this type. |
private void |
indentLine(BufferedWriter bw,
int level)
Convenience method to write out the appropriate number of spaces. |
private void |
processNodes(NodeList nl,
HelperType ht,
Properties props)
This method processes the helper.xml entry for a single helper type. |
protected void |
save()
Save the information on all operations performed since the last save() or cancel() call. |
void |
setHelperNameOrder(Mode mode,
HelperType type,
HelperName[] names)
Set the helper name order for a given helper type and mode. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private HashMap hashmaps
private HashMap hhMapping
private HashMap hmMapping
private HashMap allHelpers
private ArrayList allHelperTypes
private static String topDir
private static ServerConfig sc
private static HelperConfig hc
Constructor Detail |
protected HelperConfig() throws InternalErrorException
InternalErrorException
- Thrown if the operation fails for any reason.Method Detail |
private void processNodes(NodeList nl, HelperType ht, Properties props) throws InconsistentStateException
nl
- A NodeList object obtained by the XML parser.ht
- The HelperType being parsed.props
- - A properties object containing the helper name information.
InconsistentStateException
- Thrown if some of the data for this
helper type is inconsistent in some way.public static HelperConfig getHelperConfig()
public HelperType[] getAllHelperTypes()
public HelperName[] getAllHelperNames()
private HelperName[] getHelperNamesForTypeAndMode(Element elem, HelperType ht, Properties props) throws InconsistentStateException
elem
- - The Element corresponding to the Mode entry.ht
- The HelperType being processed.props
- The properties object with the helper name information.
InconsistentStateException
- Thrown if the ranking information does not
consist of one value for each integer between 1 and the number of HelperName objects.public HelperName getFirstHelperName(Mode mode, HelperType type) throws NoSuchDataException
mode
- The mode in question.type
- The helper type.
NoSuchDataException
- Thrown if there is no HelperName object for this
helper type and mode.public HelperName[] getHelperNames(Mode mode, HelperType type)
mode
- The mode of the game, such as BEST.type
- The helper type.protected void addHelperType(HelperType ht, ComponentType parent) throws InconsistentStateException, DataAlreadyExistsException
ht
- The HelperType object to be added.parent
- The ComponentType that this HelperType is to be associated with.
InconsistentStateException
- Thrown if the parent is of an unknown type.
DataAlreadyExistsException
- Thrown if this HelperType object has already been added.public void deleteHelperType(HelperType ht) throws PermissionsException, NoSuchDataException
ht
- The HelperType object to delete.
PermissionsException
- Thrown if there are any HelperName objects
associated with this HelperType object.
NoSuchDataException
- Thrown if the HelperType is not associated.protected void addHelperName(HelperName hn)
hn
- The HelperName object.protected void deleteHelperName(HelperName hn)
hn
- The helper name to be deleted.protected void addMode(Mode newMode, Mode oldMode) throws NoSuchDataException
newMode
- The new mode.oldMode
- The mode to copy data from.
NoSuchDataException
- Thrown if either mode has been deleted.protected void deleteMode(String name) throws NoSuchDataException
name
- The name of the 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
- Thrown if the operation fails for any reason.private void indentLine(BufferedWriter bw, int level) throws InternalErrorException
bw
- The BufferedWriter to write the spaces out to.level
- The number of levels to indent.
InternalErrorException
- Thrown if the operation fails for any reason.public void setHelperNameOrder(Mode mode, HelperType type, HelperName[] names)
mode
- The mode of the game, such as FAST.type
- The helper type.names
- The helper names in order from most preferred to least preferred.public ComponentType getParent(HelperType ht) throws InconsistentStateException
ht
- The helper type being queried.
InconsistentStateException
- Thrown if the parent cannot be determined.protected void associate(HelperType ht, ComponentType parent) throws InconsistentStateException, DataAlreadyExistsException
ht
- The helper type to be associated with its parentparent
- The parent of the helper type.
InconsistentStateException
- Thrown if the parent is of an unknown type.
DataAlreadyExistsException
- Thrown if the helper type is already associated with a parent.protected HelperType[] getAllHelperTypes(HelperType ht)
ht
- The parent helper type.
protected HelperType[] getAllHelperTypes(ModuleType mt)
mt
- The parent module type.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |