org.pentaho.reporting.engine.classic.core.filter
Class ResourceFileFilter

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.filter.ResourceFileFilter
All Implemented Interfaces:
Serializable, Cloneable, DataFilter, DataSource, DataTarget

public class ResourceFileFilter
extends Object
implements DataFilter

Lookup a key from a datasource using a ResourceBundle.

Filters a given datasource and uses the datasource value as key for a ResourceBundle.

Author:
Thomas Morgner
See Also:
Serialized Form

Constructor Summary
ResourceFileFilter()
          Creates a new ResourceFileFilter.
 
Method Summary
 Object clone()
          Clones this DataSource.
 DataSource getDataSource()
          Returns the assigned DataSource for this Target.
 String getResourceIdentifier()
          Returns the name of the used resource bundle.
 Object getValue(ExpressionRuntime runtime, Element element)
          Returns the current value for the data source.
 void setDataSource(DataSource ds)
          Assigns a DataSource for this Target.
 void setResourceIdentifier(String resourceIdentifier)
          Defines the name of the used resource bundle.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceFileFilter

public ResourceFileFilter()
Creates a new ResourceFileFilter.

Method Detail

getResourceIdentifier

public String getResourceIdentifier()
Returns the name of the used resource bundle.

Returns:
the name of the resourcebundle
See Also:
ResourceBundleFactory.getResourceBundle(String)

setResourceIdentifier

public void setResourceIdentifier(String resourceIdentifier)
Defines the name of the used resource bundle. If undefined, all calls to DataSource.getValue(ExpressionRuntime, Element) will result in null values.

Parameters:
resourceIdentifier - the resource bundle name

getValue

public Object getValue(ExpressionRuntime runtime,
                       Element element)
Returns the current value for the data source. The method will return null, if no datasource or no resource bundle is defined or if the datasource's value is null.

The value read from the dataSource is looked up in the given resourcebundle using the ResourceBundle.getObject() method. If the lookup fails, null is returned.

Specified by:
getValue in interface DataSource
Parameters:
runtime - the expression runtime that is used to evaluate formulas and expressions when computing the value of this filter.
element -
Returns:
the value or null, if the value could not be looked up.

clone

public Object clone()
             throws CloneNotSupportedException
Clones this DataSource.

Specified by:
clone in interface DataSource
Specified by:
clone in interface DataTarget
Overrides:
clone in class Object
Returns:
the clone.
Throws:
CloneNotSupportedException - this should never happen.

getDataSource

public DataSource getDataSource()
Returns the assigned DataSource for this Target.

Specified by:
getDataSource in interface DataTarget
Returns:
The datasource.

setDataSource

public void setDataSource(DataSource ds)
Assigns a DataSource for this Target.

Specified by:
setDataSource in interface DataTarget
Parameters:
ds - The data source.