The application can access the dimension value properties via PropertyMap objects.
After a dimension value (DimVal
object) has been retrieved, the application can access the dimension value properties by calling:
Working with dimension value properties is similar to working with record properties. In both cases, the same PropertyMap
object is returned.
The following code fragments which show how to iterate through all properties of a dimension value.
Example 51. Java example of accessing dimension value properties
// Loop over refinement list // refs is a DimValList object for (int k=0; k < refs.size(); k++) { // Get refinement dimension value DimVal ref = refs.getDimValue(k); // Get properties for refinement value PropertyMap pmap = ref.getProperties(); // Get all property names and their values Iterator props = pmap.entrySet().iterator(); while (props.hasNext()) { Property prop = (Property)props.next(); String pkey = prop.getKey(); String pval = prop.getValue(); // Perform operation on pkey and/or pval } }
Example 52. .NET example of accessing dimension value properties
// Loop over refinement list // refs is a DimValList object for (int k=0; k < refs.Count; k++) { // Get refinement dimension value DimVal ref = refs[k]; // Get properties for refinement value PropertyMap pmap = ref.Properties; // Get all property names and their values System.Collections.IList props = pmap.EntrySet; foreach (Property prop in props) { String pkey = prop.Key; String pval = prop.Value; // Perform operation on pkey and/or pval } }
Note that instead of iterating through all properties for a given dimension value, you can also get specific properties by name from the PropertyMap
object, as shown in these examples.
Example 53. Java example of getting a specific property
<% // Get properties for refinement value PropertyMap pmap = ref.getProperties(); // Get the desired property String propVal = ""; if (pmap.get("DisplayColor") != null) { propVal = pmap.get("DisplayColor"); %> <FONT COLOR="<%= propVal %>">Best Buy</FONT> <% }
Example 54. .NET example of getting a specific property
<% // Get properties for refinement value PropertyMap pmap = ref.Properties; // Get the desired property String propVal = ""; // If property has a value if ((String)pmap["DisplayColor"] != "") propVal = (String)pmap["DisplayColor"]; %> <FONT COLOR="<%= propVal %>">Best Buy</FONT> <% }