
com.extjs.gxt.ui.client.widget.table.NumberCellRenderer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gxt Show documentation
Show all versions of gxt Show documentation
Rich Internet Application Framework for GWT
/*
* Ext GWT - Ext for GWT
* Copyright(c) 2007, 2008, Ext JS, LLC.
* [email protected]
*
* http://extjs.com/license
*/
package com.extjs.gxt.ui.client.widget.table;
import com.extjs.gxt.ui.client.widget.Component;
import com.google.gwt.i18n.client.NumberFormat;
/**
* A CellRenderer
implementaiton for numbers.
*
* @see NumberFormat
*/
public class NumberCellRenderer implements CellRenderer {
private NumberFormat format;
/**
* Creates a new number cell renderer.
*
* @param pattern the pattern used by {@link NumberFormat}
*/
public NumberCellRenderer(String pattern) {
this.format = NumberFormat.getFormat(pattern);
}
/**
* Creates a new number cell renderer.
*
* @param format the number format
*/
public NumberCellRenderer(NumberFormat format) {
this.format = format;
}
public String render(T item, String property, Object value) {
if (value instanceof Double) {
return format.format(((Double) value).doubleValue());
} else if (value instanceof Float) {
return format.format(((Float) value).floatValue());
} else if (value instanceof Long) {
return format.format(((Long) value).longValue());
} else if (value instanceof Integer) {
return format.format(((Integer) value).intValue());
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy