|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.commands.CompositeDynamicAttributeCommand
public class CompositeDynamicAttributeCommand
A command which manages the order of execution and rollback for a group of sub-commands.
This command also allows for the application of dynamic attributes to each of the sub-commands when the sub-commands have unique names.
Field Summary |
---|
Fields inherited from interface com.sas.commands.DynamicAttributeCommandInterface |
---|
COMMAND_NAME_PREFIX |
Fields inherited from interface com.sas.util.ApplyInterface |
---|
ABORT, CONTINUE |
Constructor Summary | |
---|---|
CompositeDynamicAttributeCommand()
Default constructor |
|
CompositeDynamicAttributeCommand(java.lang.String name)
Name Constructor. |
Method Summary | |
---|---|
void |
add(DynamicAttributeCommandInterface command,
java.util.Map dynamicAttributeNames)
Add a command to be executed during this Composite command's execute() . |
int |
apply(java.lang.Object obj)
Executes all executable sub-commands. |
protected void |
applyCommandAttributes(DynamicAttributeCommandInterface command)
|
java.lang.Object |
clone()
Clones this command. |
void |
execute(java.lang.Object obj)
Executes all the executable sub-commands in the order that they were added. |
java.util.Collection |
getCommandAttributeNames()
Returns a collection containing the names of all the composite command's dynamic attributes. |
java.util.List |
getCommands()
|
java.util.Locale |
getLocale()
Returns the command's locale |
java.lang.String |
getName()
Returns the name of the command. |
static java.lang.String |
getNextCommandName()
Returns a unique command name. |
java.lang.String |
getText()
Placeholder to satisy interface requirements. |
boolean |
isExecutable()
Returns true if any sub-command is executable. |
boolean |
isUndoable()
Returns the boolean indicating whether the last operation this command executed can be undone ( rolled back ). |
void |
remove(DynamicAttributeCommandInterface command)
Removes a command from the list of commands to be executed during this Composite command's execute() . |
static void |
setCommonAttribute(java.util.Collection commands,
java.lang.String attributeName,
java.lang.Object attributeValue)
Sets the specified attribute on all sub-commands of type DynamicAttributeCommandInterface. |
void |
setCommonAttribute(java.lang.String attributeName,
java.lang.Object attributeValue)
Sets the specified attribute on all sub-commands. |
void |
setLocale(java.util.Locale loc)
Sets the command's locale |
void |
setName(java.lang.String name)
Sets the name of the command. |
void |
setText(java.lang.String text)
Placeholder to satisy interface requirements. |
void |
undo()
Undo all the sub-commands in reverse order of their execution(). |
Methods inherited from class com.sas.entities.BaseEntity |
---|
containsAttributeNamed, equals, equals, getAttribute, getAttribute, getAttributeCount, getAttributes, getEntityKey, getPropertyDescriptors, getStringAttribute, listAttributeNames, removeAllAttributes, removeAttribute, reset, sameEntity, setAttribute, setAttributes, setEntityKey, toString |
Methods inherited from interface com.sas.entities.BaseEntityValueInterface |
---|
getAttribute, setAttribute |
Constructor Detail |
---|
public CompositeDynamicAttributeCommand()
public CompositeDynamicAttributeCommand(java.lang.String name)
name
- The name of this command.execute(java.lang.Object)
,
add(com.sas.commands.DynamicAttributeCommandInterface, java.util.Map)
Method Detail |
---|
public java.lang.String getName()
getName
in interface DynamicAttributeCommandInterface
setName(java.lang.String)
public void setName(java.lang.String name)
To ensure unique command names
use the getNextCommandName()
method.
setName
in interface DynamicAttributeCommandInterface
name
- unique name of the command.getName()
public void setLocale(java.util.Locale loc)
loc
- the localegetLocale()
public java.util.Locale getLocale()
setLocale(java.util.Locale)
public static java.lang.String getNextCommandName()
Convenience method for ensuring commands are given unique names.
setName(java.lang.String)
public void add(DynamicAttributeCommandInterface command, java.util.Map dynamicAttributeNames)
execute()
.
command
- The command to be added.dynamicAttributeNames
- Mappings from the composite's attribute name to the command's corresponding attribute name.
java.lang.IllegalArgumentException
- if command is null.
java.lang.IllegalStateException
- if a composite attribute name is already registered.execute(java.lang.Object)
public void remove(DynamicAttributeCommandInterface command)
execute()
.
command
- The command to be remove.
java.lang.IllegalArgumentException
- if command is null.execute(java.lang.Object)
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in interface com.sas.PublicClonable
clone
in interface com.sas.util.Command
clone
in class BaseEntity
java.lang.CloneNotSupportedException
- this class supports cloning, but a subclass may notpublic boolean isExecutable()
true
if any sub-command is executable.
If present, dynamic attributes are applied to each sub-command before each command
is asked isExecutable()
.
Note that it should do no harm to call execute(object) even if isExecutable() returns false.
isExecutable
in interface com.sas.util.Command
true
if any of the sub-commands are executable.
false
otherwiseexecute(java.lang.Object)
public void execute(java.lang.Object obj)
This method does no error checking on the success of each command execution. It will execute all executable commands unless an exception is thrown.
execute
in interface com.sas.util.SimpleCommand
obj
- passed to the execute(Object)
method of all sub-commandsundo()
public int apply(java.lang.Object obj)
If any executable command implements ApplyInterface
, then
its apply method is called, otherwise its execute() method is called.
If the apply method does not return ApplyInterface.CONTINUE
,
then the next command will not be executed and the value will be returned.
apply
in interface com.sas.util.ApplyInterface
obj
- passed to the apply(Object)
or execute(Object)
methods of both commands
ApplyInterface.CONTINUE
or
ApplyInterface.ABORT
execute(java.lang.Object)
,
ApplyInterface.CONTINUE
public boolean isUndoable()
Returns true
if all the executed sub-commands are undoable.
isUndoable
in interface com.sas.util.Command
undo()
public void undo()
undo
in interface com.sas.util.Command
execute(java.lang.Object)
public java.lang.String getText()
getText
in interface com.sas.lang.StringDataInterface
setText(java.lang.String)
public void setText(java.lang.String text)
Does nothing
setText
in interface com.sas.lang.StringDataInterface
text
- the command's textgetText()
public void setCommonAttribute(java.lang.String attributeName, java.lang.Object attributeValue)
For use when all sub-commands need the same attribute set with the same value.
Internally it calls setCommonAttribute(List commands, String attributeName, Object attributeValue )
setCommonAttribute
in interface CompositeDynamicAttributeCommandInterface
attributeName
- The name of the attribute to set on all sub-commands.attributeValue
- The value of the attribute.public static void setCommonAttribute(java.util.Collection commands, java.lang.String attributeName, java.lang.Object attributeValue)
For use when all sub-commands need the same attribute set with the same value.
commands
- The collection of DynamicAttributeCommandInterface sub-commands.attributeName
- The name of the attribute to set on all sub-commands.attributeValue
- The value of the attribute.protected void applyCommandAttributes(DynamicAttributeCommandInterface command)
public java.util.Collection getCommandAttributeNames()
getCommandAttributeNames
in interface CompositeDynamicAttributeCommandInterface
public java.util.List getCommands()
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |