Parameters

NOTE! This document is outdated and has been replaced with newer documentation. See The database schema and the Data Layer API

This document explains how parameter values are implemented in BASE. The parameter value classes are used by other classes that needs to save values dynamically.

See also

Last updated: $Date: 2009-04-06 14:52:39 +0200 (må, 06 apr 2009) $


ParameterValueData

The ParameterValueData [API] class is an abstract base class that can hold multiple values. It should be used when declaring the generic for collection classes. That way a collection can hold mixed type of parameter value classes. The values will be saved as correct type in the database.

private Map<String, ParameterValueData<?>> configurationValues;
/**
  Used by Hibernate to link with configuration values.
  @hibernate.map table="`PluginConfigurationValues`" lazy="true" cascade="all"
  @hibernate.collection-key column="`pluginconfiguration_id`"
  @hibernate.collection-index column="`name`" type="string" length="255"
  @hibernate.collection-many-to-many column="`value_id`" 
    class="net.sf.basedb.core.data.ParameterValueData"
*/
public Map<String, ParameterValueData<?>> getConfigurationValues()
{
  return configurationValues;
}
void setConfigurationValues(Map<String, ParameterValueData<?>> configurationValues)
{
  this.configurationValues = configurationValues;
}

Now it is possible for the collection to store all types of values, ie:

Map<String, ParameterValueData<?>> config = ...;
config.put("names", new StringParameterValueData("A", "B", "C"));
config.put("sizes", new IntegerParameterValueData(10, 20, 30));

Of course, when you later load those values again you have to cast them to the correct class.

Subclasses

Every type that can be saved have its own subclass. Except for the item classes that all share the same subclass, a subclass that can hold BasicItems [API] derives.