com.gentics.api.lib.resolving
Class PropertySetter

java.lang.Object
  extended by com.gentics.api.lib.resolving.PropertyResolver
      extended by com.gentics.api.lib.resolving.PropertySetter
All Implemented Interfaces:
Resolvable

public class PropertySetter
extends PropertyResolver

PropertySetter is an extension of PropertyResolver that also can change properties by paths based on a given Resolvable. The setting process resolves the given property path up to the next to last path part. When the result of this is a Changeable or a Collection of Changeables, the objects are modified by setting the property given by the last part of the property path.
Example: let the base object be a Resolvable representing a user. The call to setProperty(String, Object) with ("organisation.employees.email", "a.b@foo.com") would first resolve "organisation.employees" to a Collection of Changeables representing all employees of the user's organisation and would then change the email addresses by calling Changeable.setProperty(String, Object) with ("email", "a.b@foo.com") for each.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.gentics.api.lib.resolving.PropertyResolver
PropertyResolver.PropertyPathEntry
 
Field Summary
 
Fields inherited from class com.gentics.api.lib.resolving.PropertyResolver
m_startObject
 
Constructor Summary
PropertySetter(Resolvable baseObject)
          Create a propertySetter that resolves and sets properties based on the given Resolvable.
 
Method Summary
 void addToProperty(String path, Object value)
          Add the given property to the properties resolved by the given path.
 void addToProperty(String path, Object value, boolean allowDuplicates)
          Add the given property to the properties resolved by the given path.
 void performAssignment(Expression expression)
          Perform the given assignment expression
protected  void remove(Collection toModify, Object toRemove)
          Remove the given object from the given collection.
protected  void removeAll(Collection toModify, Collection toRemove)
          Remove all objects in the collection from the given collection.
 void removeFromProperty(String path, Object value)
          Remove the given value from the properties resolved by the given path.
 void setProperty(String path, Object value)
          Set the property (properties) given by the path to the given value
 
Methods inherited from class com.gentics.api.lib.resolving.PropertyResolver
canResolve, get, getProperty, resolve, resolve, resolve, resolve, resolvePath, resolvePath, resolvePath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertySetter

public PropertySetter(Resolvable baseObject)
Create a propertySetter that resolves and sets properties based on the given Resolvable.

Parameters:
baseObject - base object
Method Detail

setProperty

public void setProperty(String path,
                        Object value)
                 throws UnknownPropertyException,
                        InsufficientPrivilegesException
Set the property (properties) given by the path to the given value

Parameters:
path - path to a property/properties of an object/objects
value - new value to set
Throws:
UnknownPropertyException
InsufficientPrivilegesException

addToProperty

public void addToProperty(String path,
                          Object value)
                   throws UnknownPropertyException,
                          InsufficientPrivilegesException
Add the given property to the properties resolved by the given path. Duplicate values will not be allowed (i.e. the value will not be added if it already is present in the property)

Parameters:
path - property path
value - value to add
Throws:
UnknownPropertyException
InsufficientPrivilegesException

addToProperty

public void addToProperty(String path,
                          Object value,
                          boolean allowDuplicates)
                   throws UnknownPropertyException,
                          InsufficientPrivilegesException
Add the given property to the properties resolved by the given path.

Parameters:
path - property path
value - value to add
allowDuplicates - true when duplicates are allowed, false if not
Throws:
UnknownPropertyException
InsufficientPrivilegesException

removeFromProperty

public void removeFromProperty(String path,
                               Object value)
                        throws UnknownPropertyException,
                               InsufficientPrivilegesException
Remove the given value from the properties resolved by the given path.

Parameters:
path - path of the property
value - value to remove
Throws:
UnknownPropertyException
InsufficientPrivilegesException

performAssignment

public void performAssignment(Expression expression)
                       throws ExpressionParserException
Perform the given assignment expression

Parameters:
expression - assignment expression
Throws:
ExpressionParserException

remove

protected void remove(Collection toModify,
                      Object toRemove)
Remove the given object from the given collection. Do compares using the equals() method in both directions.

Parameters:
toModify - collection to modify
toRemove - object to remove

removeAll

protected void removeAll(Collection toModify,
                         Collection toRemove)
Remove all objects in the collection from the given collection. Do compares using the equals() method in both directions.

Parameters:
toModify - collection to modify
toRemove - collection of objects to remove


Copyright © 2013 Gentics Software GmbH. All Rights Reserved.