cz.cuni.versatile.api
Interface DeliveryContext

All Superinterfaces:
PropertyRegistry

public interface DeliveryContext
extends PropertyRegistry

DeliveryContext serves as the developer's "window to the outer-world". All the parameters needed to make the versioning decisions in the application scope of a given module or a component should be registered in its DeliveryContext. During application runtime, the DeliveryContext is used to acquire property values needed during instantiation of queries out of the pre-defined query templates. With a properly configured DeliveryContext the developer does not need to care about retrieving property values and/or fall-back (default-value) policies as all this should be already built-in in the DeliveryContext.

Remarks: The main purpose of using derived (mapped) properties in the DeliveryContext is to transform raw (typically domain-specific -- e.g. UAProf) meta-data into pre-processed application-specific properties which better correspond to the inherent logic of the application. The transformations in such a case are typically value adding (information adding): e.g. canonicalization, hierarchical classification. Alternatively, the usage of the property mappings can be as simple as property renaming (aliasing) due to the need to use multiple overlapping vocabularies (namespaces).

Author:
Jaroslav Gergic

Method Summary
 java.lang.Object getValue(Property prop)
          Returns the current value of the specified Property.
 java.lang.Object getValue(java.lang.String uniqueName)
          Returns the current value of the specified property.
 ValueProvider getValueProvider(Property prop)
          Returns the ValueProvider for the specified Property.
 boolean hasValue(Property prop)
          Checks whether the specified Property has value in the current state of the delivery context.
 boolean hasValue(java.lang.String uniqueName)
          Checks whether the property of the specified uniqueName has value in the current state of the delivery context.
 void registerProperty(Property prop, ValueProvider vp)
          Registers a leaf property and its associated value provider.
 
Methods inherited from interface cz.cuni.versatile.api.PropertyRegistry
getProperties, getProperty, getPropertyMapping, hasProperty, hasProperty, isMappedProperty, registerProperty, unregisterProperty
 

Method Detail

registerProperty

public void registerProperty(Property prop,
                             ValueProvider vp)
Registers a leaf property and its associated value provider. If the Property has already been registered, it redefines the Property

For registering a derived (mapped) property to the DeliveryContext use PropertyRegistry.registerProperty(Property, PropertyMapping); the property being registered must be in the range set of the PropertyMapping and consequently, all the properties of the mapping's domain set must be already registered in the delivery context.

Parameters:
prop - a Property to register
vp - ValueProvider for the Property
See Also:
PropertyRegistry.registerProperty(Property, PropertyMapping)

getValueProvider

public ValueProvider getValueProvider(Property prop)
                               throws UnregisteredPropertyException,
                                      PropertyKindException
Returns the ValueProvider for the specified Property.

Parameters:
prop - a Property instance
Returns:
ValueProvider for the specified Property
Throws:
UnregisteredPropertyException - in case the property is not registered
PropertyKindException - in case there is no ValueProvider registered for the given Property

hasValue

public boolean hasValue(Property prop)
                 throws UnregisteredPropertyException
Checks whether the specified Property has value in the current state of the delivery context.

Parameters:
prop - a Property instance
Returns:
true if the property can be evaluated, false if the property value is undefined
Throws:
UnregisteredPropertyException - in case the specified Property in not registered
See Also:
ValueProvider.hasValue()

hasValue

public boolean hasValue(java.lang.String uniqueName)
                 throws UnregisteredPropertyException
Checks whether the property of the specified uniqueName has value in the current state of the delivery context.

Parameters:
uniqueName - a unique identifier of the property
Returns:
true if the property can be evaluated, false if the property value is undefined
Throws:
UnregisteredPropertyException - in case the specified Property in not registered
See Also:
ValueProvider.hasValue()

getValue

public java.lang.Object getValue(Property prop)
                          throws UnregisteredPropertyException,
                                 UndefinedPropertyValueException
Returns the current value of the specified Property. In case of a leaf property it directly invokes its ValueProvider. In case of a derived property it builds a dependency tree based on its potentially nested) property mappings and proceeds with a recursive bottom-up evaluation starting with the leaf properties.

Parameters:
prop - a Property instance
Returns:
the current value of the specified Property
Throws:
UnregisteredPropertyException - in case the specified Property in not registered
UndefinedPropertyValueException - in case the property value is undefined

getValue

public java.lang.Object getValue(java.lang.String uniqueName)
                          throws UnregisteredPropertyException,
                                 UndefinedPropertyValueException
Returns the current value of the specified property. In case of a leaf property it directly invokes its ValueProvider. In case of a derived property it builds a dependency tree based on its potentially nested) property mappings and proceeds with a recursive bottom-up evaluation starting with the leaf properties.

Parameters:
uniqueName - a unique identifier of the property
Returns:
the current value of the specified property
Throws:
UnregisteredPropertyException - in case the property of the specified uniqueName in not registered
UndefinedPropertyValueException - in case the property value is undefined