![JAR search and dependency download from the Maven repository](/logo.png)
ca.odell.glazedlists.swt.DefaultItemFormat Maven / Gradle / Ivy
/* Glazed Lists (c) 2003-2012 */
/* http://publicobject.com/glazedlists/ publicobject.com,*/
/* O'Dell Engineering Ltd.*/
package ca.odell.glazedlists.swt;
/**
* Default implementation of {@link ItemFormat} that converts an element by
* calling toString()
on it. If the element is null
,
* by default, the empty string is returned, but another default value can be
* specified.
*
* @see #DefaultItemFormat(String)
*
* @author Holger Brands
*/
public class DefaultItemFormat implements ItemFormat {
/** string value to be used for a null
element. */
private final String valueForNullElement;
/**
* Default constructor which uses the empty string as representation for
* null
elements.
*/
public DefaultItemFormat() {
this("");
}
/**
* Constructor which takes a default value for representing a
* null
element.
*
* @param valueForNullElement string value to be used for a null
element
*/
public DefaultItemFormat(String valueForNullElement) {
this.valueForNullElement = valueForNullElement;
}
/** @inheritDoc */
@Override
public String format(E element) {
return (element == null) ? valueForNullElement : element.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy