org.xwiki.rendering.internal.macro.chart.source
Class AbstractDataSource

java.lang.Object
  extended by org.xwiki.rendering.internal.macro.chart.source.AbstractDataSource
All Implemented Interfaces:
DataSource
Direct Known Subclasses:
AbstractTableBlockDataSource

public abstract class AbstractDataSource
extends Object
implements DataSource

A data source is able to provide a data set for chart generation. This super class provides basic parameter validation.

Since:
4.2M1

Field Summary
static String DATASET_PARAM
          The name of the dataset parameter.
static String PLOT_TYPE_PARAM
          The name of the plot type parameter.
 
Fields inherited from interface org.xwiki.rendering.internal.macro.chart.source.DataSource
PARAMS_PARAM, SOURCE_PARAM
 
Constructor Summary
AbstractDataSource()
           
 
Method Summary
 ChartModel getChartModel()
          DataSource.buildDataset(java.lang.String, java.util.Map, org.xwiki.rendering.transformation.MacroTransformationContext) must be called before this method.
 DatasetType getDatasetType()
           
protected  LocaleConfiguration getLocaleConfiguration()
           
protected  void invalidParameterValue(String parameterName, String value)
          Indicate that an invalid parameter value was found.
protected  void setAxes()
          Set the axes from the axis configuration.
protected  void setChartModel(SimpleChartModel chartModel)
          Set the chart model.
protected  void setDataset(Dataset dataset)
           
 void setDatasetType(DatasetType datasetType)
           
protected abstract  boolean setParameter(String key, String value)
          Let an implementation set a parameter.
protected  void validateDatasetType()
          Validate the dataset parameter.
protected abstract  void validateParameters()
          Let an implementation validate the value of the previously set parameters, and set default values.
protected  void validateParameters(Map<String,String> parameters)
          Validate and set parameters for the data source.
protected  void validatePlotType()
          Validate the plot type parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xwiki.rendering.internal.macro.chart.source.DataSource
buildDataset
 

Field Detail

DATASET_PARAM

public static final String DATASET_PARAM
The name of the dataset parameter.

See Also:
Constant Field Values

PLOT_TYPE_PARAM

public static final String PLOT_TYPE_PARAM
The name of the plot type parameter.

See Also:
Constant Field Values
Constructor Detail

AbstractDataSource

public AbstractDataSource()
Method Detail

validateParameters

protected void validateParameters(Map<String,String> parameters)
                           throws MacroExecutionException
Validate and set parameters for the data source.

Parameters:
parameters - The parameters.
Throws:
MacroExecutionException - if the parameters are invalid for this data source.

setParameter

protected abstract boolean setParameter(String key,
                                        String value)
                                 throws MacroExecutionException
Let an implementation set a parameter. This method should set the value of the parameter, if the parameter is supported by the data source.

Parameters:
key - The key of the parameter.
value - The value of the parameter.
Returns:
true if the parameter was claimed.
Throws:
MacroExecutionException - if the parameter is invalid in some way.

validateParameters

protected abstract void validateParameters()
                                    throws MacroExecutionException
Let an implementation validate the value of the previously set parameters, and set default values.

Throws:
MacroExecutionException - if the previously set value is invalid.

validateDatasetType

protected void validateDatasetType()
                            throws MacroExecutionException
Validate the dataset parameter. If no dataset was given as a parameter, set a default value.

Throws:
MacroExecutionException - if the previously set value is invalid.

validatePlotType

protected void validatePlotType()
                         throws MacroExecutionException
Validate the plot type parameter.

Throws:
MacroExecutionException - if the previously set value is invalid.

setAxes

protected void setAxes()
                throws MacroExecutionException
Set the axes from the axis configuration.

Throws:
MacroExecutionException - if the axes are incorrectly specified.

getDatasetType

public DatasetType getDatasetType()
Returns:
the configured dataset type.

setDatasetType

public void setDatasetType(DatasetType datasetType)
Parameters:
datasetType - the dataset type to configure.

getChartModel

public ChartModel getChartModel()
Description copied from interface: DataSource
DataSource.buildDataset(java.lang.String, java.util.Map, org.xwiki.rendering.transformation.MacroTransformationContext) must be called before this method.

Specified by:
getChartModel in interface DataSource
Returns:
the ChartModel for the dataset.

setChartModel

protected void setChartModel(SimpleChartModel chartModel)
Set the chart model.

Parameters:
chartModel - The chart model.

setDataset

protected void setDataset(Dataset dataset)
Parameters:
dataset - the dataset.

invalidParameterValue

protected void invalidParameterValue(String parameterName,
                                     String value)
                              throws MacroExecutionException
Indicate that an invalid parameter value was found.

Parameters:
parameterName - The name of the parameter.
value - The value.
Throws:
MacroExecutionException - always.

getLocaleConfiguration

protected LocaleConfiguration getLocaleConfiguration()
Returns:
The locale configuration.