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
. Initially the string 'null' is used.
| Method from org.jfree.report.filter.StringFilter Detail: |
public Object clone() throws CloneNotSupportedException {
final StringFilter f = (StringFilter) super.clone();
if (source != null)
{
f.source = (DataSource) source.clone();
}
return f;
}
|
public DataSource getDataSource() {
return source;
}
Returns the data source for this filter. |
public FormatSpecification getFormatString(ExpressionRuntime runtime,
Element element,
FormatSpecification formatSpecification) {
if (source instanceof RawDataSource)
{
final RawDataSource rds = (RawDataSource) source;
return rds.getFormatString(runtime, element, formatSpecification);
}
if (formatSpecification == null)
{
formatSpecification = new FormatSpecification();
}
formatSpecification.redefine(FormatSpecification.TYPE_UNDEFINED, null);
return formatSpecification;
}
|
public String getNullValue() {
return nullvalue;
}
Returns the string used to represent a null value. |
public Object getRawValue(ExpressionRuntime runtime,
Element element) {
if (source instanceof RawDataSource)
{
final RawDataSource rawDataSource = (RawDataSource) source;
return rawDataSource.getRawValue(runtime, element);
}
return source.getValue(runtime, element);
}
|
public Object getValue(ExpressionRuntime runtime,
Element element) {
final DataSource ds = getDataSource();
if (ds == null)
{
return getNullValue();
}
final Object o = ds.getValue(runtime, element);
if (o == null)
{
return getNullValue();
}
// String is final, so it is safe to do this ...
if (StringFilter.STRING_CLASSNAME.equals(o.getClass().getName()))
{
return o;
}
if (o instanceof char[])
{
return new String ((char[]) o);
}
if (o instanceof Clob)
{
return readClob((Clob) o);
}
return String.valueOf(o);
}
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). |
public void setDataSource(DataSource ds) {
if (ds == null)
{
throw new NullPointerException();
}
source = ds;
}
Sets the data source for this filter. |
public void setNullValue(String nullvalue) {
this.nullvalue = nullvalue;
}
Sets the string used to represent a null value. |