Example usage for com.google.gwt.text.shared Parser Parser

List of usage examples for com.google.gwt.text.shared Parser Parser

Introduction

In this page you can find the example usage for com.google.gwt.text.shared Parser Parser.

Prototype

Parser

Source Link

Usage

From source file:com.tasktop.c2c.server.common.web.client.widgets.BigDecimalBox.java

License:Open Source License

/**
 * @param element/*from   w  w w. j a v  a2s  .  c  o  m*/
 * @param renderer
 * @param parser
 */
public BigDecimalBox() {
    super(Document.get().createTextInputElement(), new AbstractRenderer<BigDecimal>() {

        @Override
        public String render(BigDecimal object) {
            if (object == null) {
                return "";
            }
            return NumberFormat.getDecimalFormat().format(object);
        }

    }, new Parser<BigDecimal>() {

        @Override
        public BigDecimal parse(CharSequence text) throws ParseException {
            try {
                return new BigDecimal(text.toString());
            } catch (NumberFormatException e) {
                return null;
            }
        }
    });
}