com.jrefinery.report.filter
Class StringFilter

java.lang.Object
  |
  +--com.jrefinery.report.filter.StringFilter
All Implemented Interfaces:
java.lang.Cloneable, DataFilter, DataSource, DataTarget, java.io.Serializable

public class StringFilter
extends java.lang.Object
implements DataFilter, java.io.Serializable

A filter that returns the value from a data source as a String. The value is converted to an String using String.valueOf () which uses Object.toString() to convert the object into the string.

You can specify a default string to return when the value from the data source is null. Initially the string 'null' is used.

Author:
Thomas Morgner
See Also:
Serialized Form

Constructor Summary
StringFilter()
          Default constructor.
 
Method Summary
 java.lang.Object clone()
          Clones the filter.
 DataSource getDataSource()
          Returns the data source for this filter.
 java.lang.String getNullValue()
          Returns the string used to represent a null value.
 java.lang.Object getValue()
          Returns the value obtained from the data source.
 void setDataSource(DataSource ds)
          Sets the data source for this filter.
 void setNullValue(java.lang.String nullvalue)
          Sets the string used to represent a null value.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringFilter

public StringFilter()
Default constructor.

Method Detail

setNullValue

public void setNullValue(java.lang.String nullvalue)
Sets the string used to represent a null value.

Parameters:
nullvalue - the null value.

getNullValue

public java.lang.String getNullValue()
Returns the string used to represent a null value.

Returns:
the string.

getValue

public java.lang.Object getValue()
Returns the value obtained from the data source.

The filter ensures that the returned value is a String, even though the return type is Object (as required by the DataSource interface).

Specified by:
getValue in interface DataSource
Returns:
the string.

getDataSource

public DataSource getDataSource()
Returns the data source for this filter.

Specified by:
getDataSource in interface DataTarget
Returns:
the data source.

setDataSource

public void setDataSource(DataSource ds)
Sets the data source for this filter.

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

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones the filter.

Specified by:
clone in interface DataSource
Overrides:
clone in class java.lang.Object
Returns:
a clone.
Throws:
java.lang.CloneNotSupportedException - this should never happen.