Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.graph.request
Class UpdatePropertiesRequest

    java.lang.Object
      org.modeshape.graph.request.Request
          org.modeshape.graph.request.ChangeRequest
              org.modeshape.graph.request.UpdatePropertiesRequest

All Implemented Interfaces:
  Serializable, Cloneable, PropertyChangeRequest

    public class UpdatePropertiesRequest

extends ChangeRequest
implements PropertyChangeRequest

Instruction to update the properties on the node at the specified location.

This request is capable of specifying that certain properties are to have new values and that other properties are to be removed. The request has a single map of properties keyed by their name. If a property is to be set with new values, the map will contain an entry with the property keyed by its name. However, if a property is to be removed, the entry will contain the property name for the key but will have a null entry value.

The use of the map also ensures that a single property appears only once in the request (it either has new values or it is to be removed).

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
`UpdatePropertiesRequest(Location on, String workspaceName, Map<Name,Property> properties)` Create a request to update the properties on the node at the supplied location.
`UpdatePropertiesRequest(Location on, String workspaceName, Map<Name,Property> properties, boolean removeOtherProperties)` Create a request to update the properties on the node at 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.
`UpdatePropertiesRequest` | `clone()` This method does not clone the results.
`boolean` | `equals(Object obj)`
`boolean` | `freeze()` Freeze this request to prevent any further modification.
`Location` | `getActualLocationOfNode()` Get the actual location of the node that was updated.
`Set<Name>` | `getNewPropertyNames()` Get the names of the `properties` that were created by this request.
`RequestType` | `getType()` Returns the type of the request
`int` | `hashCode()`
`String` | `inWorkspace()` Get the name of the workspace in which the node exists.
`boolean` | `isAllNewProperties()` Determine whether this request only added the properties.
`boolean` | `isNewProperty(Name name)` Determine whether the named property was created by this request
`boolean` | `isReadOnly()` Return whether this request only reads information.
`Location` | `on()` Get the location defining the node that is to be updated.
`Map<Name,Property>` | `properties()` Get the map of properties for the node, keyed by property name.
`boolean` | `removeOtherProperties()` Return whether any properties not being updated should be removed.
`void` | `setActualLocationOfNode(Location actual)` Sets the actual and complete location of the node being updated.
`void` | `setNewProperties(Iterable<Name> nameOfCreatedProperties)` Record that the named properties did not exist prior to the processing of this request and were actually created by this request.
`void` | `setNewProperties(Name... nameOfCreatedProperties)` Record that the named properties did not exist prior to the processing of this request and were actually created by this request.
`void` | `setNewProperty(Name nameOfCreatedProperty)` Record that the named property did not exist prior to the processing of this request and was actually created by this request.
`String` | `toString()`

Methods inherited from class org.modeshape.graph.request.Request
`checkNotFrozen, getError, hasError, isCancelled, isFrozen, printable, printable, setError, setLatchForFreezing`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### UpdatePropertiesRequest

    public UpdatePropertiesRequest(Location on,
                                   String workspaceName,
                                   Map<Name,Property> properties)

  Create a request to update the properties on the node at the supplied location.

  Parameters:
    `on` - the location of the node to be read
    `workspaceName` - the name of the workspace containing the node
    `properties` - the map of properties (keyed by their name), which is reused without copying
  Throws:
    `IllegalArgumentException` - if the location or workspace name is null or if there are no properties to update

### UpdatePropertiesRequest

    public UpdatePropertiesRequest(Location on,
                                   String workspaceName,
                                   Map<Name,Property> properties,
                                   boolean removeOtherProperties)

  Create a request to update the properties on the node at the supplied location.

  Parameters:
    `on` - the location of the node to be read
    `workspaceName` - the name of the workspace containing the node
    `properties` - the map of properties (keyed by their name), which is reused without copying
    `removeOtherProperties` - if any properties not being updated should be removed
  Throws:
    `IllegalArgumentException` - if the location or workspace name is null or if there are no properties to update

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

### on

    public Location on()

  Get the location defining the node that is to be updated.

  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

### properties

    public Map<Name,Property> properties()

  Get the map of properties for the node, keyed by property name. Any property to be removed will have a map entry with a null value.

  Returns:
    the properties being updated; never null and never empty

### removeOtherProperties

    public boolean removeOtherProperties()

  Return whether any properties not being updated should be removed.

  Returns:
    true if the node's existing properties not updated with this request should be removed, or false if this request should leave other properties unchanged

### setActualLocationOfNode

    public void setActualLocationOfNode(Location actual)

  Sets the actual and complete location of the node being updated. 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 updated, or null if the `current location` should be used
  Throws:
    `IllegalArgumentException` - if the actual location is null or does not have a path.
    `IllegalStateException` - if the request is frozen
  See Also:
    `setNewProperties(Iterable)`, `setNewProperties(Name...)`, `setNewProperty(Name)`

### 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

### setNewProperty

    public void setNewProperty(Name nameOfCreatedProperty)

  Record that the named property did not exist prior to the processing of this request and was actually created by this request. This method (or one of its sibling methods) must be called at least once when processing the request, and may be called repeatedly for additional properties.

  Parameters:
    `nameOfCreatedProperty` - the name of one of the `properties` that was created by this request
  Throws:
    `IllegalStateException` - if the request is frozen
    `IllegalArgumentException` - if the name is null or if it is not the name of one of the `properties`
  See Also:
    `setActualLocationOfNode(Location)`, `setNewProperties(Name...)`, `setNewProperties(Iterable)`

### setNewProperties

    public void setNewProperties(Name... nameOfCreatedProperties)

  Record that the named properties did not exist prior to the processing of this request and were actually created by this request. This method (or one of its sibling methods) must be called at least once when processing the request, and may be called repeatedly for additional properties.

  Parameters:
    `nameOfCreatedProperties` - the names of the `properties` that were created by this request
  Throws:
    `IllegalStateException` - if the request is frozen
    `IllegalArgumentException` - if the name is null or if it is not the name of one of the `properties`
  See Also:
    `setActualLocationOfNode(Location)`, `setNewProperties(Iterable)`, `setNewProperty(Name)`

### setNewProperties

    public void setNewProperties(Iterable<Name> nameOfCreatedProperties)

  Record that the named properties did not exist prior to the processing of this request and were actually created by this request. This method (or one of its sibling methods) must be called at least once when processing the request, and may be called repeatedly for additional properties.

  Parameters:
    `nameOfCreatedProperties` - the names of the `properties` that were created by this request
  Throws:
    `IllegalStateException` - if the request is frozen
    `IllegalArgumentException` - if any of the names are not in the updated `properties`
  See Also:
    `setActualLocationOfNode(Location)`, `setNewProperties(Name...)`, `setNewProperty(Name)`

### getNewPropertyNames

    public Set<Name> getNewPropertyNames()

  Get the names of the `properties` that were created by this request.

  Returns:
    the names of the properties

### isNewProperty

    public boolean isNewProperty(Name name)

  Determine whether the named property was created by this request

  Parameters:
    `name` - the property name
  Returns:
    true if the named property was created by the request, or false otherwise

### isAllNewProperties

    public boolean isAllNewProperties()

  Determine whether this request only added the properties.

  Returns:
    true if the properties being updated were all new properties, or false otherwise

### freeze

    public boolean freeze()

  Freeze this request to prevent any further modification. This method does nothing if the request is already frozen.

  Overrides:
    `freeze` in class `Request`
  Returns:
    true if this request was frozen, or false if it was already frozen
  See Also:
    `Request.freeze()`

### 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)`

### 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)`

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

### toString

    public String toString()

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

### clone

    public UpdatePropertiesRequest 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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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