2.17.2: 2011-06-17

net.sf.basedb.core.data
Interface ExtendableData

All Superinterfaces:
IdentifiableData
All Known Implementing Classes:
BaseFileImporter.RawDataProxy, BaseFileImporter.ReporterProxy, RawData, ReporterData, UserData

public interface ExtendableData
extends IdentifiableData

This class is inherited by data classes that supports per-server additions of columns to the underlying database table.

The added columns must be described in the extended-properties.xml configuration file. The format of the XML file is forced by a DTD. In summary:

<?xml version="1.0" ?>
<!DOCTYPE extended-properties SYSTEM "extended-properties.dtd" >
<extended-properties>
   <class name="ReporterData">
      <property
         name="extra1"
         title="Extra property"
         column="extra1"
         type="string"
         length="255"
         null="true"
         update="true"
         insert="true"
         averagemethod="geometric_mean"
         description="An extra property for all reporters"
      />
   </class>
</extended-properties>

The name attribute of the <class> tag is the name of the data class that the extra property should be added to. That class must of course implement this interface. The <class> tag may contain one or more <property> tags. Here is a short description of the attributes for the <property> tag.

Attribute Description
name (required) The property name of the extended property. See ExtendedProperty.getName(). The name must only contain letters, numbers and underscores but the first character can't be a number. The name must be unique within the class.
title The display title for the extended property. See ExtendedProperty.getTitle().
description A short description of the extended property. See ExtendedProperty.getDescription().
column (required) The database column name of the extended property. This value must be unique for each class. The value is validated by the DbEngine.isValidColumnName(String) which normally means it must follow the same rules as the name attribute. See ExtendedProperty.getColumn().
type (required) The type of the column. Allowed values are:
  • int
  • long
  • float
  • double
  • boolean
  • string
  • date
See ExtendedProperty.getType().
length The maximum allowed length of the value if it is a string property. See ExtendedProperty.getLength(). The default value is 255.
null If the column supports null values or not. Allowed values are:
  • true (default)
  • false
See ExtendedProperty.isNullable().
insert If the value for this property should be inserted into the database or not.
  • true (default)
  • false
See ExtendedProperty.isInsertable().
update If the value for this property should be updated in the database or not.
  • true (default)
  • false
See ExtendedProperty.isUpdateable().
averagable This attribute has been deprecated and is replaced by averagemethod!
If it makes sense to take the average of multiple values for this property. By default all numerical columns are averagable. For non-numerical columns, this attribute is ignored. The default method is to calculate the arithmetic mean.
  • true
  • false
See ExtendedProperty.isAveragable().
averagemethod The method to use when calculating the average of a set of values. This attribute replaces the averagable attribute. The following values can be used:
  • none: do not use this property when calculating averages
  • arithmetic_mean: calculate the arithmetic mean
  • geometric_mean: calculate the geometric mean
  • min: use the minimum value among the values in the set
  • max: use the maximum value among the values in the set
If no value is given to this attribute the default is to use arithmetic mean for all numerical value types. See ExtendedProperty.getAverageMethod().

Reference implementation

private Map<String, Object> extendedProperties;
public Object getExtended(String name)
{
   return extendedProperties == null ? null : extendedProperties.get(name);
}
public void setExtended(String name, Object value)
{
   if (extendedProperties == null) extendedProperties = new HashMap<String, Object>();
   extendedProperties.put(name, value);
}

Version:
2.0
Author:
Nicklas, Samuel
See Also:
ExtendedProperties, ExtendedProperty

Method Summary
 Object getExtended(String name)
          Get the value of an extended property.
 void setExtended(String name, Object value)
          Set the value of an extended property.
 
Methods inherited from interface net.sf.basedb.core.data.IdentifiableData
getId, getVersion
 

Method Detail

getExtended

Object getExtended(String name)
Get the value of an extended property.

Parameters:
name - The name of the property
Returns:
The value of the property or null if not found

setExtended

void setExtended(String name,
                 Object value)
Set the value of an extended property.

Parameters:
name - The name of the property
value - The new value for the property

2.17.2: 2011-06-17