org.jboss.dna.graph.commands.basic
Class BasicRecordBranchCommand

java.lang.Object
  extended by org.jboss.dna.graph.commands.basic.BasicGraphCommand
      extended by org.jboss.dna.graph.commands.basic.BasicRecordBranchCommand
All Implemented Interfaces:
ActsOnPath, GraphCommand, RecordBranchCommand

@NotThreadSafe
public class BasicRecordBranchCommand
extends BasicGraphCommand
implements RecordBranchCommand

Author:
Randall Hauch

Constructor Summary
BasicRecordBranchCommand(Path topOfBranch, NodeConflictBehavior conflictBehavior)
           
BasicRecordBranchCommand(Path topOfBranch, NodeConflictBehavior conflictBehavior, List<CreateNodeCommand> commands)
           
BasicRecordBranchCommand(Path topOfBranch, NodeConflictBehavior conflictBehavior, List<CreateNodeCommand> commands, int maxDepthOfBranch)
           
 
Method Summary
 List<CreateNodeCommand> getCreateNodeCommands()
          Return the commands to create the nodes, in the order they were recorded.
 int getMaxDepth()
           
 Path getPath()
          Get the path to which this command applies.
 boolean record(Path path, Iterable<Property> properties)
          Sets the properties of the supplied node.
 boolean record(Path path, Iterator<Property> properties)
          Sets the properties of the supplied node.
 boolean record(Path path, Property... properties)
          Sets the properties of the supplied node.
 String toString()
          
 
Methods inherited from class org.jboss.dna.graph.commands.basic.BasicGraphCommand
getError, hasError, hasNoError, isCancelled, setCancelled, setError
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.dna.graph.commands.GraphCommand
getError, hasError, hasNoError, isCancelled, setError
 

Constructor Detail

BasicRecordBranchCommand

public BasicRecordBranchCommand(Path topOfBranch,
                                NodeConflictBehavior conflictBehavior)
Parameters:
topOfBranch - the top node in the branch that is to be recorded; may not be null
conflictBehavior - the desired behavior when a node exists at the path; may not be null

BasicRecordBranchCommand

public BasicRecordBranchCommand(Path topOfBranch,
                                NodeConflictBehavior conflictBehavior,
                                List<CreateNodeCommand> commands)
Parameters:
topOfBranch - the top node in the branch that is to be recorded; may not be null
conflictBehavior - the desired behavior when a node exists at the path; may not be null
commands - the list into which the CreateNodeCommands should be place; may be null

BasicRecordBranchCommand

public BasicRecordBranchCommand(Path topOfBranch,
                                NodeConflictBehavior conflictBehavior,
                                List<CreateNodeCommand> commands,
                                int maxDepthOfBranch)
Parameters:
topOfBranch - the top node in the branch that is to be recorded; may not be null
conflictBehavior - the desired behavior when a node exists at the path; may not be null
commands - the list into which the CreateNodeCommands should be place; may be null
maxDepthOfBranch - the maximum depth of the branch that should be recorded, or Integer.MAX_VALUE if there is no limit
Method Detail

getPath

public Path getPath()
Get the path to which this command applies. If the path does not exist, an PathNotFoundException exception should be recorded as an error.

Specified by:
getPath in interface ActsOnPath
Returns:
the path; never null

record

public boolean record(Path path,
                      Iterable<Property> properties)
Sets the properties of the supplied node.

If the supplied path is a relative path, it is assumed to be relative to the branch root. If the supplied path is an absolute path, it must be a decendant of the branch root; if not, this method returns false and ignores the call.

This method should not be called multiple times with the same path. The behavior for such cases is not defined.

Specified by:
record in interface RecordBranchCommand
Parameters:
path - the path for the node; may not be null
properties - the properties for the node; may be null if there are no properties
Returns:
true if the children of the node should be recorded, or false if this new node is as deep as the recording should go

record

public boolean record(Path path,
                      Iterator<Property> properties)
Sets the properties of the supplied node.

If the supplied path is a relative path, it is assumed to be relative to the branch root. If the supplied path is an absolute path, it must be a decendant of the branch root; if not, this method returns false and ignores the call.

This method should not be called multiple times with the same path. The behavior for such cases is not defined.

Specified by:
record in interface RecordBranchCommand
Parameters:
path - the path for the node; may not be null
properties - the properties for the node; may be null if there are no properties
Returns:
true if the children of the node should be recorded, or false if this new node is as deep as the recording should go

record

public boolean record(Path path,
                      Property... properties)
Sets the properties of the supplied node.

If the supplied path is a relative path, it is assumed to be relative to the branch root. If the supplied path is an absolute path, it must be a decendant of the branch root; if not, this method returns false and ignores the call.

This method should not be called multiple times with the same path. The behavior for such cases is not defined.

Specified by:
record in interface RecordBranchCommand
Parameters:
path - the path for the node; may not be null
properties - the properties for the node; may be null if there are no properties
Returns:
true if the children of the node should be recorded, or false if this new node is as deep as the recording should go

getMaxDepth

public int getMaxDepth()
Returns:
maxDepth

getCreateNodeCommands

public List<CreateNodeCommand> getCreateNodeCommands()
Return the commands to create the nodes, in the order they were recorded.

Returns:
the mutable list of create node commands; never null

toString

public String toString()

Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2008-Present JBoss a division of Red Hat. All Rights Reserved.