@Test public void testFromString() { NumberClass nc = new NumberClass(); BaseClass bc = new BaseClass(); bc.setName("Some.Class"); nc.setObject(bc); assertNull(nc.fromString("asd")); assertNull(nc.fromString("1111111111111111111111111111111111")); BaseProperty p; p = nc.fromString(null); assertNotNull(p); assertNull(p.getValue()); p = nc.fromString(""); assertNotNull(p); assertNull(p.getValue()); p = nc.fromString("4"); assertNotNull(p); assertEquals(4, Integer.parseInt(p.getValue().toString())); }
@Override public BaseProperty fromString(String value) { BaseProperty property = newProperty(); String ntype = getNumberType(); Number nvalue = null; try { if (ntype.equals("integer")) { if ((value != null) && (!value.equals(""))) { nvalue = Integer.valueOf(value); } } else if (ntype.equals("float")) { if ((value != null) && (!value.equals(""))) { nvalue = Float.valueOf(value); } } else if (ntype.equals("double")) { if ((value != null) && (!value.equals(""))) { nvalue = Double.valueOf(value); } } else { if ((value != null) && (!value.equals(""))) { nvalue = Long.valueOf(value); } } } catch (NumberFormatException e) { LOG.warn("Invalid number entered for property " + getName() + " of class " + getObject().getName() + ": " + value); return null; } property.setValue(nvalue); return property; }
NumberClass extends PropertyClass { @Override public BaseProperty fromString(String value) { BaseProperty property = newProperty(); String ntype = getNumberType(); Number nvalue = null; try { if (ntype.equals("integer")) { if ((value != null) && (!value.equals(""))) { nvalue = Integer.valueOf(value); } } else if (ntype.equals("float")) { if ((value != null) && (!value.equals(""))) { nvalue = Float.valueOf(value); } } else if (ntype.equals("double")) { if ((value != null) && (!value.equals(""))) { nvalue = Double.valueOf(value); } } else { if ((value != null) && (!value.equals(""))) { nvalue = Long.valueOf(value); } } } catch (NumberFormatException e) { LOG.warn("Invalid number entered for property " + getName() + " of class " + getObject().getName() + ": " + value); return null; } property.setValue(nvalue); return property; } }
NumberClass extends PropertyClass { @Override public BaseProperty fromString(String value) { BaseProperty property = newProperty(); String ntype = getNumberType(); Number nvalue = null; try { if (ntype.equals("integer")) { if ((value != null) && (!value.equals(""))) { nvalue = Integer.valueOf(value); } } else if (ntype.equals("float")) { if ((value != null) && (!value.equals(""))) { nvalue = Float.valueOf(value); } } else if (ntype.equals("double")) { if ((value != null) && (!value.equals(""))) { nvalue = Double.valueOf(value); } } else { if ((value != null) && (!value.equals(""))) { nvalue = Long.valueOf(value); } } } catch (NumberFormatException e) { LOG.warn("Invalid number entered for property " + getName() + " of class " + getObject().getName() + ": " + value); return null; } property.setValue(nvalue); return property; } NumberClass(PropertyMetaClass wclass);  NumberClass(); }
NumberClass extends PropertyClass { @Override public BaseProperty fromString(String value) { BaseProperty property = newProperty(); String ntype = getNumberType(); Number nvalue = null; try { if (ntype.equals("integer")) { if ((value != null) && (!value.equals(""))) { nvalue = Integer.valueOf(value); } } else if (ntype.equals("float")) { if ((value != null) && (!value.equals(""))) { nvalue = Float.valueOf(value); } } else if (ntype.equals("double")) { if ((value != null) && (!value.equals(""))) { nvalue = Double.valueOf(value); } } else { if ((value != null) && (!value.equals(""))) { nvalue = Long.valueOf(value); } } } catch (NumberFormatException e) { LOG.warn("Invalid number entered for property " + getName() + " of class " + getObject().getName() + ": " + value); return null; } property.setValue(nvalue); return property; } NumberClass(PropertyMetaClass wclass);  NumberClass(); int getSize(); void setSize(int size); String getNumberType(); void setNumberType(String ntype); @Override BaseProperty newProperty(); @Override BaseProperty fromString(String value); @Override void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context); }
NumberClass extends PropertyClass { @Override public BaseProperty fromString(String value) { BaseProperty property = newProperty(); String ntype = getNumberType(); Number nvalue = null; try { if (ntype.equals("integer")) { if ((value != null) && (!value.equals(""))) { nvalue = Integer.valueOf(value); } } else if (ntype.equals("float")) { if ((value != null) && (!value.equals(""))) { nvalue = Float.valueOf(value); } } else if (ntype.equals("double")) { if ((value != null) && (!value.equals(""))) { nvalue = Double.valueOf(value); } } else { if ((value != null) && (!value.equals(""))) { nvalue = Long.valueOf(value); } } } catch (NumberFormatException e) { LOG.warn("Invalid number entered for property " + getName() + " of class " + getObject().getName() + ": " + value); return null; } property.setValue(nvalue); return property; } NumberClass(PropertyMetaClass wclass);  NumberClass(); int getSize(); void setSize(int size); String getNumberType(); void setNumberType(String ntype); @Override BaseProperty newProperty(); @Override BaseProperty fromString(String value); @Override void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context);  }