org.modeshape.graph.request
Class CreateNodeRequest

java.lang.Object
  extended by org.modeshape.graph.request.Request
      extended by org.modeshape.graph.request.ChangeRequest
          extended by org.modeshape.graph.request.CreateNodeRequest
All Implemented Interfaces:
Serializable, Cloneable, Iterable<Property>

public class CreateNodeRequest
extends ChangeRequest
implements Iterable<Property>

Instruction to create the node under the specified location. This command will create the node and set the initial properties.

See Also:
Serialized Form

Field Summary
static NodeConflictBehavior DEFAULT_CONFLICT_BEHAVIOR
           
 
Constructor Summary
CreateNodeRequest(Location parentLocation, String workspaceName, Name childName, Iterable<Property> properties)
          Create a request to create a node with the given properties under the supplied location.
CreateNodeRequest(Location parentLocation, String workspaceName, Name childName, Iterator<Property> properties)
          Create a request to create a node with the given properties under the supplied location.
CreateNodeRequest(Location parentLocation, String workspaceName, Name childName, NodeConflictBehavior conflictBehavior, Iterable<Property> properties)
          Create a request to create a node with the given properties under the supplied location.
CreateNodeRequest(Location parentLocation, String workspaceName, Name childName, NodeConflictBehavior conflictBehavior, Iterator<Property> properties)
          Create a request to create a node with the given properties under the supplied location.
CreateNodeRequest(Location parentLocation, String workspaceName, Name childName, NodeConflictBehavior conflictBehavior, Property... properties)
          Create a request to create a node with the given properties under the supplied location.
CreateNodeRequest(Location parentLocation, String workspaceName, Name childName, Property... properties)
          Create a request to create a node with the given properties under the supplied location.
 
Method Summary
 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.
 CreateNodeRequest 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.
 boolean equals(Object obj)
          
 Location getActualLocationOfNode()
          Get the actual location of the node that was created.
 RequestType getType()
          Returns the type of the request
 int hashCode()
          
 String inWorkspace()
          Get the name of the workspace in which the node is to be createde
 boolean isReadOnly()
          Return whether this request only reads information.
 Iterator<Property> iterator()
          
 Name named()
          Get the name for the new child.
 Collection<Property> properties()
          Get the properties for the node.
 void setActualLocationOfNode(Location actual)
          Sets the actual and complete location of the node being created.
 String toString()
          
 Location under()
          Get the location defining the parent of the new node that is to be created.
 
Methods inherited from class org.modeshape.graph.request.Request
checkNotFrozen, freeze, getError, hasError, isCancelled, isFrozen, setError, setLatchForFreezing
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_CONFLICT_BEHAVIOR

public static final NodeConflictBehavior DEFAULT_CONFLICT_BEHAVIOR
Constructor Detail

CreateNodeRequest

public CreateNodeRequest(Location parentLocation,
                         String workspaceName,
                         Name childName,
                         Property... properties)
Create a request to create a node with the given properties under the supplied location.

Parameters:
parentLocation - the location of the existing parent node, under which the new child should be created
workspaceName - the name of the workspace containing the parent
childName - the name of the new child to create under the existing parent
properties - the properties of the new node, which should include any identification properties for the new node
Throws:
IllegalArgumentException - if the location, workspace name, or child name is null

CreateNodeRequest

public CreateNodeRequest(Location parentLocation,
                         String workspaceName,
                         Name childName,
                         Iterable<Property> properties)
Create a request to create a node with the given properties under the supplied location.

Parameters:
parentLocation - the location of the existing parent node, under which the new child should be created
workspaceName - the name of the workspace containing the parent
childName - the name of the new child to create under the existing parent
properties - the properties of the new node, which should include any identification properties for the new node
Throws:
IllegalArgumentException - if the location, workspace name, or child name is null

CreateNodeRequest

public CreateNodeRequest(Location parentLocation,
                         String workspaceName,
                         Name childName,
                         Iterator<Property> properties)
Create a request to create a node with the given properties under the supplied location.

Parameters:
parentLocation - the location of the existing parent node, under which the new child should be created
workspaceName - the name of the workspace containing the parent
childName - the name of the new child to create under the existing parent
properties - the properties of the new node, which should include any identification properties for the new node
Throws:
IllegalArgumentException - if the location, workspace name, or child name is null

CreateNodeRequest

public CreateNodeRequest(Location parentLocation,
                         String workspaceName,
                         Name childName,
                         NodeConflictBehavior conflictBehavior,
                         Property... properties)
Create a request to create a node with the given properties under the supplied location.

Parameters:
parentLocation - the location of the existing parent node, under which the new child should be created
workspaceName - the name of the workspace containing the parent
childName - the name of the new child to create under the existing parent
properties - the properties of the new node, which should include any identification properties for the new node
conflictBehavior - the expected behavior if an equivalently-named child already exists under the into location
Throws:
IllegalArgumentException - if the location, workspace name, child name, or the conflict behavior is null

CreateNodeRequest

public CreateNodeRequest(Location parentLocation,
                         String workspaceName,
                         Name childName,
                         NodeConflictBehavior conflictBehavior,
                         Iterable<Property> properties)
Create a request to create a node with the given properties under the supplied location.

Parameters:
parentLocation - the location of the existing parent node, under which the new child should be created
workspaceName - the name of the workspace containing the parent
childName - the name of the new child to create under the existing parent
properties - the properties of the new node, which should include any identification properties for the new node
conflictBehavior - the expected behavior if an equivalently-named child already exists under the into location
Throws:
IllegalArgumentException - if the location, workspace name, child name, or the conflict behavior is null

CreateNodeRequest

public CreateNodeRequest(Location parentLocation,
                         String workspaceName,
                         Name childName,
                         NodeConflictBehavior conflictBehavior,
                         Iterator<Property> properties)
Create a request to create a node with the given properties under the supplied location.

Parameters:
parentLocation - the location of the existing parent node, under which the new child should be created
workspaceName - the name of the workspace containing the parent
childName - the name of the new child to create under the existing parent
properties - the properties of the new node, which should include any identification properties for the new node
conflictBehavior - the expected behavior if an equivalently-named child already exists under the into location
Throws:
IllegalArgumentException - if the location, workspace name, child name, or the conflict behavior is null
Method Detail

under

public Location under()
Get the location defining the parent of the new node that is to be created.

Returns:
the location of the parent node; never null

inWorkspace

public String inWorkspace()
Get the name of the workspace in which the node is to be createde

Returns:
the name of the workspace; never null

named

public Name named()
Get the name for the new child.

Returns:
the child's name; never null

iterator

public Iterator<Property> iterator()

Specified by:
iterator in interface Iterable<Property>
See Also:
Iterable.iterator()

properties

public Collection<Property> properties()
Get the properties for the node. If the node's location has identification properties, the resulting properties will include the identification properties.

Returns:
the collection of properties; never null

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

setActualLocationOfNode

public void setActualLocationOfNode(Location actual)
Sets the actual and complete location of the node being created. This method must be called when processing the request, and the actual location must have a path.

Parameters:
actual - the actual location of the node being created, or null if the current location should be used
Throws:
IllegalArgumentException - if the actual location is not equal to the current location, or if the actual location does not have a path.
IllegalStateException - if the request is frozen

getActualLocationOfNode

public Location getActualLocationOfNode()
Get the actual location of the node that was created.

Returns:
the actual location, 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.

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

getType

public RequestType getType()
Description copied from class: Request
Returns the type of the request

Specified by:
getType in class Request
Returns:
the type of the request


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