key = "#initial";\r
}\r
\r
+ /**\r
+ * Creates new state by cloning all commands of the provided state and \r
+ * then overriding one of them with the provided state changing command.\r
+ * \r
+ * @param previousState\r
+ * @param newCommand\r
+ */\r
public Pazpar2State (Pazpar2State previousState, Pazpar2Command newCommand) {\r
for (String commandName : previousState.commands.keySet()) {\r
this.commands.put(commandName, previousState.commands.get(commandName).copy());\r
}\r
\r
/**\r
- * Checks if the provided command represents a state change\r
+ * Checks if a command represents a change of this state\r
* \r
* @param command\r
* @return true if the command causes a change of state\r
}\r
} \r
\r
+ /**\r
+ * Returns a command from this state\r
+ * \r
+ * @param name\r
+ * @return\r
+ */ \r
public Pazpar2Command getCommand(String name) {\r
return commands.get(name);\r
}\r
}\r
}\r
\r
+ /**\r
+ * Gets a detached copy of a command. For the change manager\r
+ * to become aware of any changes to the copy it must be \r
+ * checked back in with 'checkIn(Pazpar2Command)'\r
+ * \r
+ * @param commandName\r
+ * @return Copy this state's instance of the given command\r
+ */\r
public Pazpar2Command checkOut (String commandName) {\r
return getCurrentState().getCommand(commandName).copy();\r
}\r
return states.get(currentKey);\r
}\r
\r
+ /**\r
+ * Changes the current state key. Invoked from the UI to have the state \r
+ * manager switch to another state than the current one. \r
+ * \r
+ * @param key\r
+ */\r
public void setCurrentStateKey(String key) { \r
if (currentKey.equals(key)) {\r
logger.debug("setCurrentStateKey: no key change detected");\r
}\r
}\r
\r
- \r
+ /**\r
+ * Sets a pending-state-change flag for the given command. Used by\r
+ * the beans to decide whether, say, a search should be executed before\r
+ * doing the next show. \r
+ * \r
+ * It is up to the client to set and reset this flag since the state\r
+ * manager is not otherwise informed about actual request activities \r
+ * (only about the definition of commands to be executed)\r
+ * \r
+ * @param command\r
+ * @param bool\r
+ */\r
public void hasPendingStateChange(String command, boolean bool) {\r
pendingStateChanges.put(command, new Boolean(bool));\r
}\r
\r
+ /**\r
+ * \r
+ * @param command\r
+ * @return true if there is a non-executed command change in this state\r
+ */\r
public boolean hasPendingStateChange (String command) {\r
return pendingStateChanges.get(command).booleanValue();\r
}\r