org.modeshape.graph.request
Class MoveBranchRequest

java.lang.Object
  extended by org.modeshape.graph.request.Request
      extended by org.modeshape.graph.request.ChangeRequest
          extended by org.modeshape.graph.request.MoveBranchRequest
All Implemented Interfaces:
Serializable, Cloneable

public class MoveBranchRequest
extends ChangeRequest

Instruction that a branch be moved from one location into another.

See Also:
Serialized Form

Field Summary
static NodeConflictBehavior DEFAULT_CONFLICT_BEHAVIOR
           
 
Constructor Summary
MoveBranchRequest(Location from, Location into, Location before, String workspaceName, Name newNameForMovedNode, NodeConflictBehavior conflictBehavior)
          Create a request to move a branch from one location into another.
MoveBranchRequest(Location from, Location into, String workspaceName)
          Create a request to move a branch from one location into another.
MoveBranchRequest(Location from, Location into, String workspaceName, Name newNameForMovedNode)
          Create a request to move a branch from one location into another.
MoveBranchRequest(Location from, Location into, String workspaceName, NodeConflictBehavior conflictBehavior)
          Create a request to move a branch from one location into another.
 
Method Summary
 Location before()
          Get the location defining the node before which the branch is to be placed
 void cancel()
          Cancel this request.
 Location changedLocation()
          Get the location of the top-most node that is to be changed by this request.
 String changedWorkspace()
          Get the name of the workspace that was changed by this request.
 boolean changes(String workspace, Path path)
          Determine if this request changes the branch at the given path.
 MoveBranchRequest clone()
           This method does not clone the results.
 NodeConflictBehavior conflictBehavior()
          Get the expected behavior when copying the branch and the destination already has a node with the same name.
 Name desiredName()
          Get the name of the copy if it is to be different than that of the original.
 boolean equals(Object obj)
          
 Location from()
          Get the location defining the top of the branch to be moved
 Location getActualLocationAfter()
          Get the actual location of the node after being moved.
 Location getActualLocationBefore()
          Get the actual location of the node before being moved.
 int hashCode()
          
 boolean hasNoEffect()
          Determine whether this move request can be determined to have no effect.
 Location into()
          Get the location defining the parent where the branch is to be placed
 String inWorkspace()
          Get the name of the workspace in which the branch exists.
 boolean isReadOnly()
          Return whether this request only reads information.
 void setActualLocations(Location oldLocation, Location newLocation)
          Sets the actual and complete location of the node being renamed and its new location.
 String toString()
          
 
Methods inherited from class org.modeshape.graph.request.Request
freeze, getError, hasError, isCancelled, isFrozen, setError, setLatchForFreezing
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_CONFLICT_BEHAVIOR

public static final NodeConflictBehavior DEFAULT_CONFLICT_BEHAVIOR
Constructor Detail

MoveBranchRequest

public MoveBranchRequest(Location from,
                         Location into,
                         String workspaceName)
Create a request to move a branch from one location into another.

Parameters:
from - the location of the top node in the existing branch that is to be moved
into - the location of the existing node into which the branch should be moved
workspaceName - the name of the workspace
Throws:
IllegalArgumentException - if any of the parameters are null

MoveBranchRequest

public MoveBranchRequest(Location from,
                         Location into,
                         String workspaceName,
                         Name newNameForMovedNode)
Create a request to move a branch from one location into another.

Parameters:
from - the location of the top node in the existing branch that is to be moved
into - the location of the existing node into which the branch should be moved
workspaceName - the name of the workspace
newNameForMovedNode - the new name for the node being moved, or null if the name of the original should be used
Throws:
IllegalArgumentException - if any of the parameters are null

MoveBranchRequest

public MoveBranchRequest(Location from,
                         Location into,
                         String workspaceName,
                         NodeConflictBehavior conflictBehavior)
Create a request to move a branch from one location into another.

Parameters:
from - the location of the top node in the existing branch that is to be moved
into - the location of the existing node into which the branch should be moved
workspaceName - the name of the workspace
conflictBehavior - the expected behavior if an equivalently-named child already exists at the into location
Throws:
IllegalArgumentException - if any of the parameters are null

MoveBranchRequest

public MoveBranchRequest(Location from,
                         Location into,
                         Location before,
                         String workspaceName,
                         Name newNameForMovedNode,
                         NodeConflictBehavior conflictBehavior)
Create a request to move a branch from one location into another.

Parameters:
from - the location of the top node in the existing branch that is to be moved
into - the location of the existing node into which the branch should be moved
before - the location of the child of the into node that the branch should be placed before; null indicates that the branch should be the last child of its new parent
workspaceName - the name of the workspace
newNameForMovedNode - the new name for the node being moved, or null if the name of the original should be used
conflictBehavior - the expected behavior if an equivalently-named child already exists at the into location
Throws:
IllegalArgumentException - if any of the parameters are null
Method Detail

from

public Location from()
Get the location defining the top of the branch to be moved

Returns:
the from location; never null

into

public Location into()
Get the location defining the parent where the branch is to be placed

Returns:
the to location; or null if the node is being reordered within the same parent

before

public Location before()
Get the location defining the node before which the branch is to be placed

Returns:
the to location; null indicates that the branch should be the last child node of its new parent

inWorkspace

public String inWorkspace()
Get the name of the workspace in which the branch exists.

Returns:
the name of the workspace containing the branch; never null

desiredName

public Name desiredName()
Get the name of the copy if it is to be different than that of the original.

Returns:
the desired name of the copy, or null if the name of the original is to be used

conflictBehavior

public NodeConflictBehavior conflictBehavior()
Get the expected behavior when copying the branch and the destination already has a node with the same name.

Returns:
the behavior specification

isReadOnly

public boolean isReadOnly()
Return whether this request only reads information.

Specified by:
isReadOnly in class Request
Returns:
true if this request reads information, or false if it requests that the repository content be changed in some way
See Also:
Request.isReadOnly()

hasNoEffect

public boolean hasNoEffect()
Determine whether this move request can be determined to have no effect.

A move is known to have no effect when all of the following conditions are true:

If all of these conditions are not true, this method returns false.

Returns:
true if this move request really doesn't change the parent of the node, or false if it cannot be determined

setActualLocations

public void setActualLocations(Location oldLocation,
                               Location newLocation)
Sets the actual and complete location of the node being renamed and its new location. This method must be called when processing the request, and the actual location must have a path.

Parameters:
oldLocation - the actual location of the node before being moved
newLocation - the actual new location of the node
Throws:
IllegalArgumentException - if the either location is null, if the old location is not equal to the from location, if the new location is not equal to the into location, or if the either location does not have a path
IllegalStateException - if the request is frozen

getActualLocationBefore

public Location getActualLocationBefore()
Get the actual location of the node before being moved.

Returns:
the actual location of the node before being moved, or null if the actual location was not set

getActualLocationAfter

public Location getActualLocationAfter()
Get the actual location of the node after being moved.

Returns:
the actual location of the node after being moved, or null if the actual location was not set

changes

public boolean changes(String workspace,
                       Path path)
Determine if this request changes the branch at the given path.

Specified by:
changes in class ChangeRequest
Parameters:
workspace - the name of the workspace; may not be null
path - the path; may not be null
Returns:
true if this request changes a node under the given path
See Also:
ChangeRequest.changes(java.lang.String, org.modeshape.graph.property.Path)

changedLocation

public Location changedLocation()
Get the location of the top-most node that is to be changed by this request. If this request has been completed, this location will always have a path.

This method returns the getActualLocationAfter() location, or if null the into() location.

Specified by:
changedLocation in class ChangeRequest
Returns:
the location changed by this request
See Also:
ChangeRequest.changedLocation()

changedWorkspace

public String changedWorkspace()
Get the name of the workspace that was changed by this request.

Specified by:
changedWorkspace in class ChangeRequest
Returns:
the name of the workspace changed by this request
See Also:
ChangeRequest.changedWorkspace()

cancel

public void cancel()
Cancel this request. After this method is called, the cancellation flag is set, and any current or future processing of the request may be affected by the cancellation. (Note however, that processors may choose to not respect this request.)

This method is safe to be called by different threads.

Overrides:
cancel in class Request
See Also:
Request.cancel()

hashCode

public int hashCode()

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

equals

public boolean equals(Object obj)

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

toString

public String toString()

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

clone

public MoveBranchRequest clone()

This method does not clone the results.

This method does not clone the results.

Specified by:
clone in class ChangeRequest
See Also:
ChangeRequest.clone()


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