org.modeshape.graph.request
Class UpdateValuesRequest

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

public class UpdateValuesRequest
extends ChangeRequest

Instruction to update the values for a certain property on the node at the specified location.

This request is capable of specifying specific values for the property that will be added or removed. Other values for the property not be affected by this request. The request contains a workspace name and a location that uniquely identify a node in the workspace as well as the name of property (that may or may not previously exist) on the node. The request also contains zero or more values to add and zero or more values to remove from the property. All values will be appended to the list of values. Removals are processed before additions.

Even if the property has no values after this call, the property itself will not be removed by this request.

Note that the number of values in a property (e.g., Property.size(), Property.isEmpty(), Property.isSingle(), and Property.isMultiple()) has no influence on whether the property should be removed. It is possible for a property to have no values.

See Also:
Serialized Form

Constructor Summary
UpdateValuesRequest(String workspaceName, Location on, Name propertyName, List<Object> addedValues, List<Object> removedValues)
           
 
Method Summary
 List<Object> addedValues()
          Get the list of values to be added.
 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.
 UpdateValuesRequest clone()
           This method does not clone the results.
 List<Object> getActualAddedValues()
          Get the actual added values.
 Location getActualLocationOfNode()
          Get the actual location of the node that was updated.
 Property getActualProperty()
          Get the actual node property that was created or updated.
 List<Object> getActualRemovedValues()
          Get the actual removed values.
 String inWorkspace()
          Get the name of the workspace in which the node exists.
 boolean isNewProperty()
          Get whether the property was created.
 boolean isReadOnly()
          Return whether this request only reads information.
 Location on()
          Get the location defining the node that is to be updated.
 Name property()
          Get the name of the property that is to be updated.
 List<Object> removedValues()
          Get the list of values to be removed.
 void setActualLocation(Location actual, List<Object> actualAddedValues, List<Object> actualRemovedValues)
           
 void setActualProperty(Property property, boolean created)
          Record that the property did not exist prior to the processing of this request and was actually created by this request.
 
Methods inherited from class org.modeshape.graph.request.Request
cancel, freeze, getError, hasError, isCancelled, isFrozen, setError, setLatchForFreezing
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UpdateValuesRequest

public UpdateValuesRequest(String workspaceName,
                           Location on,
                           Name propertyName,
                           List<Object> addedValues,
                           List<Object> removedValues)
Method Detail

on

public Location on()
Get the location defining the node that is to be updated.

Returns:
the location of the node; never null

property

public Name property()
Get the name of the property that is to be updated.

Returns:
the name of the property; 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

addedValues

public List<Object> addedValues()
Get the list of values to be added.

Returns:
the values (if any) to be added; never null

removedValues

public List<Object> removedValues()
Get the list of values to be removed.

Returns:
the values (if any) to be removed; never null

changedLocation

public Location changedLocation()
Description copied from class: ChangeRequest
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

changedWorkspace

public String changedWorkspace()
Description copied from class: ChangeRequest
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

changes

public boolean changes(String workspace,
                       Path path)
Description copied from class: ChangeRequest
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

isReadOnly

public boolean isReadOnly()
Description copied from class: Request
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

setActualLocation

public void setActualLocation(Location actual,
                              List<Object> actualAddedValues,
                              List<Object> actualRemovedValues)

setActualProperty

public void setActualProperty(Property property,
                              boolean created)
Record that the property did not exist prior to the processing of this request and was actually created by this request. This method must be called when processing the request, and the actual location must have a path.

Parameters:
property - the property being created or updated (may not be null)
created - true if the property was created by this request, or false if this request updated an existing property
Throws:
IllegalStateException - if the request is frozen
IllegalArgumentException - if the property is null

getActualProperty

public Property getActualProperty()
Get the actual node property that was created or updated.

Returns:
the actual property or null if the actual property was not set

getActualLocationOfNode

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

Returns:
the actual location, or null if the actual location was not set

getActualAddedValues

public List<Object> getActualAddedValues()
Get the actual added values. This should always be identical to the list of values that were requested to be added.

Returns:
the values that were added to the node when this request was processed; never null

getActualRemovedValues

public List<Object> getActualRemovedValues()
Get the actual removed values. This will differ from the values that were requested to be removed if some of the values that were requested to be removed were not already values for the property.

Returns:
the values that were removed from the node when this request was processed; never null

isNewProperty

public boolean isNewProperty()
Get whether the property was created.

Returns:
true if this request created the property, or false if this request changed an existing property

clone

public UpdateValuesRequest 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.