/** * Format the Number as String, using the specified NumberFormat. */ @Override public String getAsText() { Object value = getValue(); if (value == null) { return ""; } if (this.numberFormat != null) { // Use NumberFormat for rendering value. return this.numberFormat.format(value); } else { // Use toString method for rendering value. return value.toString(); } }
/** * Format the Number as String, using the specified NumberFormat. */ @Override public String getAsText() { Object value = getValue(); if (value == null) { return ""; } if (this.numberFormat != null) { // Use NumberFormat for rendering value. return this.numberFormat.format(value); } else { // Use toString method for rendering value. return value.toString(); } }
@Test public void testCustomNumberEditorWithHex() { CustomNumberEditor editor = new CustomNumberEditor(Integer.class, false); editor.setAsText("0x" + Integer.toHexString(64)); assertEquals(new Integer(64), editor.getValue()); }
@Test public void testCustomNumberEditor() { CustomNumberEditor editor = new CustomNumberEditor(Integer.class, false); editor.setAsText("5"); assertEquals(new Integer(5), editor.getValue()); assertEquals("5", editor.getAsText()); editor.setValue(null); assertEquals(null, editor.getValue()); assertEquals("", editor.getAsText()); }
@Test public void testCustomNumberEditorWithEmptyAsNull() { CustomNumberEditor editor = new CustomNumberEditor(Integer.class, true); editor.setAsText("5"); assertEquals(new Integer(5), editor.getValue()); assertEquals("5", editor.getAsText()); editor.setAsText(""); assertEquals(null, editor.getValue()); assertEquals("", editor.getAsText()); editor.setValue(null); assertEquals(null, editor.getValue()); assertEquals("", editor.getAsText()); }
/** * Format the Number as String, using the specified NumberFormat. */ @Override public String getAsText() { Object value = getValue(); if (value == null) { return ""; } if (this.numberFormat != null) { // Use NumberFormat for rendering value. return this.numberFormat.format(value); } else { // Use toString method for rendering value. return value.toString(); } }
/** * Format the Number as String, using the specified NumberFormat. */ public String getAsText() { Object value = getValue(); if (value == null) { return ""; } if (this.numberFormat != null) { // Use NumberFormat for rendering value. return this.numberFormat.format(value); } else { // Use toString method for rendering value. return value.toString(); } }
/** * Format the Number as String, using the specified NumberFormat. */ @Override public String getAsText() { Object value = getValue(); if (value == null) { return ""; } if (this.numberFormat != null) { // Use NumberFormat for rendering value. return this.numberFormat.format(value); } else { // Use toString method for rendering value. return value.toString(); } }
public Object getValue() { Object o = super.getValue(); if (o instanceof Element) { Element el = (Element)o; QName type = new QName(el.getNamespaceURI(), el.getLocalName()); TypeSchema ts = new TypeSchemaHelper(true).get(type.getNamespaceURI()); if (null == ts) { throw new ConfigurationException(new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type)); } try { return ts.unmarshal(type, el); } catch (JAXBException ex) { Message msg = new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type); throw new ConfigurationException(msg, ex); } } return o; } }