com.ibm.mashups.enabler.navigation.persistence
Interface TypeMappingRegistry


public TypeMappingRegistry

Registry to set type mappings. Type mappings map custom artifacts to enabler types.


Method Summary
 void addTypeMappingFilter(Object filter)
           Adds a custom type mapping filter.
 

Method Detail

addTypeMappingFilter

void addTypeMappingFilter(Object filter)
Adds a custom type mapping filter.
In order to determine the type of a resource, the set filters are processed one after another by invoking the filter function with the artifact's underlying data representation, i.e. json or xml. If a filter function returns a type, the resource is resolved to this type. If a filter returns null, the next filter is processed until the type of the artifact can be resolved, or all filters are processed. The filters added last are processed first.

Parameters:
filter - filter object defined as follows:
filter = {
  json: {
    fn: FUNCTION,
    scope: SCOPE
  },
  xml: {
    fn: FUNCTION,
    scope: SCOPE
  }
}
where
  • FUNCTION is a function defined as type function(data), which returns the type of the input data, or null if the type is not recognized with this filter. The returned type must be one of the following:
    • com.ibm.mashups.enabler.navigation.Constants.NAVIGATION_PAGE
    • com.ibm.mashups.enabler.navigation.Constants.NAVIGATION_LABEL
    • com.ibm.mashups.enabler.navigation.Constants.NAVIGATION_URL
    The filter function is mandatory.
  • SCOPE is the scope to execute the filter function in; optional, defaults to global scope

Notes:
  • You may specify a filter for json, xml, or both with one filter.
  • You may specify a filter to resolve to one or multiple types.
  • Resources must be resolvable to a type in all representations it can occur in. Otherwise, representation switching might not work correctly.
  • Primed resources are considered to be in json representation.

Example:
com.ibm.mashups.enabler.navigation.persistence.TypeMappingRegistry.addTypeMappingFilter( {
  json: {
    fn: function(data) {
      return data.type == "customPageType" ? com.ibm.mashups.enabler.navigation.Constants.NAVIGATION_PAGE : null;
    }
  }
});
Since:
3.0.0.2


Copyright IBM Corp. 2010 All Rights Reserved.