org.jboss.dna.graph.request
Class RenameNodeRequest

java.lang.Object
  extended by org.jboss.dna.graph.request.Request
      extended by org.jboss.dna.graph.request.ChangeRequest
          extended by org.jboss.dna.graph.request.RenameNodeRequest
All Implemented Interfaces:
Serializable, Cloneable

public class RenameNodeRequest
extends ChangeRequest

Instruction to rename an existing node (but keep it under the same parent). The same-name-sibling index will be determined automatically, based upon it's current location within the list of children.

See Also:
Serialized Form

Constructor Summary
RenameNodeRequest(Location at, String workspaceName, Name newName)
          Create a request to rename the node at the supplied location.
 
Method Summary
 Location at()
          Get the location defining the node that is to be read.
 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.
 RenameNodeRequest clone()
           This method does not clone the results.
 boolean equals(Object obj)
          
 Location getActualLocationAfter()
          Get the actual location of the node after being renamed.
 Location getActualLocationBefore()
          Get the actual location of the node before being renamed.
 int hashCode()
          
 String inWorkspace()
          Get the name of the workspace in which the node 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.
 Name toName()
          Get the new name for the node.
 String toString()
          
 
Methods inherited from class org.jboss.dna.graph.request.Request
freeze, getError, hasError, isCancelled, isFrozen, setError, setLatchForFreezing
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RenameNodeRequest

public RenameNodeRequest(Location at,
                         String workspaceName,
                         Name newName)
Create a request to rename the node at the supplied location.

Parameters:
at - the location of the node to be read
workspaceName - the name of the workspace containing the node
newName - the new name for the node
Throws:
IllegalArgumentException - if the location or workspace name is null
Method Detail

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()

at

public Location at()
Get the location defining the node that is to be read.

Returns:
the location of the node; never null

inWorkspace

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

Returns:
the name of the workspace; never null

toName

public Name toName()
Get the new name for the node.

Returns:
the new name; never null

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 renamed
newLocation - the actual location of the node after being renamed
Throws:
IllegalArgumentException - if the either location is null or is missing its path, if the old location is not equal to the current location, if the new location does not have the same parent as the old location, or if the new location does not have the same name on last segment as that specified on the request
IllegalStateException - if the request is frozen

getActualLocationBefore

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

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

getActualLocationAfter

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

Returns:
the actual location of the node after being renamed, 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.jboss.dna.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 at() 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 RenameNodeRequest 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.