Examples of CustomNumberEditor


Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

     */
    @InitBinder
    protected void initBinder(HttpServletRequest request,
                              ServletRequestDataBinder binder) {
        binder.registerCustomEditor(Integer.class, null,
                                    new CustomNumberEditor(Integer.class, null, true));
        binder.registerCustomEditor(Long.class, null,
                                    new CustomNumberEditor(Long.class, null, true));
        binder.registerCustomEditor(byte[].class,
                                    new ByteArrayMultipartFileEditor());
        SimpleDateFormat dateFormat =
            new SimpleDateFormat(getText("date.format", request.getLocale()));
        dateFormat.setLenient(false);
View Full Code Here

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

public class CustomWebBindingInitializer implements WebBindingInitializer {

    public void initBinder(final WebDataBinder binder, final WebRequest request) {
        final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
        binder.registerCustomEditor(Short.class, new CustomNumberEditor(Short.class, true));
        binder.registerCustomEditor(Integer.class, new CustomNumberEditor(Integer.class, true));
        binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, true));
        binder.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, true));
        binder.registerCustomEditor(Double.class, new CustomNumberEditor(Double.class, true));
        binder.registerCustomEditor(BigDecimal.class, new CustomNumberEditor(BigDecimal.class, true));
        binder.registerCustomEditor(BigInteger.class, new CustomNumberEditor(BigInteger.class, true));
    }
View Full Code Here

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

  protected void initBinder(HttpServletRequest request,
      ServletRequestDataBinder binder) throws Exception {
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(false));
    binder.registerCustomEditor(Date.class, null, new CustomDateEditor(
        new SimpleDateFormat("MM/dd/yyyy"), false));
    binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class,
        true));
    binder.registerCustomEditor(Boolean.class, new CustomBooleanEditor(true));
  }
View Full Code Here

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

  @Override
  protected void initBinder(HttpServletRequest request,
      ServletRequestDataBinder binder) throws Exception {
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(false));
    binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class,
        true));
  }
View Full Code Here

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

      bw.setPropertyValue("array", input);
    }
    sw.stop();
    assertTrue("Took too long", sw.getLastTaskTimeMillis() < 100);

    bw.registerCustomEditor(int.class, "array.somePath", new CustomNumberEditor(Integer.class, false));
    sw.start("array3");
    for (int i = 0; i < 1000; i++) {
      bw.setPropertyValue("array", input);
    }
    sw.stop();
    assertTrue("Took too long", sw.getLastTaskTimeMillis() < 100);

    bw.registerCustomEditor(int.class, "array[0].somePath", new CustomNumberEditor(Integer.class, false));
    sw.start("array3");
    for (int i = 0; i < 1000; i++) {
      bw.setPropertyValue("array", input);
    }
    sw.stop();
    assertTrue("Took too long", sw.getLastTaskTimeMillis() < 100);

    bw.registerCustomEditor(int.class, new CustomNumberEditor(Integer.class, false));
    sw.start("array4");
    for (int i = 0; i < 100; i++) {
      bw.setPropertyValue("array", input);
    }
    sw.stop();
View Full Code Here

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

  protected void initBinder(HttpServletRequest request,
      ServletRequestDataBinder binder) throws Exception {
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(false));
    binder.registerCustomEditor(Date.class, null, new CustomDateEditor(
        new SimpleDateFormat("MM/dd/yyyy"), false));
    binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class,
        true));
    binder.registerCustomEditor(Integer.class,
        new CustomNumberEditor(Integer.class, true));
    binder.registerCustomEditor(Boolean.class, new CustomBooleanEditor(true));
  }
View Full Code Here

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

  }

  public void testCustomEditor() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
    lbf.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("myFloat", "1,1");
    lbf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class, pvs));
    TestBean testBean = (TestBean) lbf.getBean("testBean");
    assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
View Full Code Here

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

  }

  public void testCustomEditorWithBeanReference() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
    lbf.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("myFloat", new RuntimeBeanReference("myFloat"));
    lbf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class, pvs));
    lbf.registerSingleton("myFloat", "1,1");
    TestBean testBean = (TestBean) lbf.getBean("testBean");
View Full Code Here

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

    // pattern using the type of editor returned rather than the Object type to
    // avoid recreating the logic that derives an Editor type for a given Object type
    if (editor instanceof CustomCalendarEditor) {
      formatter = new CustomCalendarEditor(pattern, getLocale());
    } else if (editor instanceof CustomNumberEditor) {
      formatter = new CustomNumberEditor(object.getClass(), getDecimalFormat(pattern), true);
    } else if (editor instanceof EnhancedBooleanEditor) {
      formatter = new EnhancedBooleanEditor(pattern, ((EnhancedBooleanEditor) editor).isAllowEmpty());
    }

    return formatter;
View Full Code Here

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

    this.defaultEditors.put(boolean.class, new CustomBooleanEditor(false));
    this.defaultEditors.put(Boolean.class, new CustomBooleanEditor(true));

    // The JDK does not contain default editors for number wrapper types!
    // Override JDK primitive number editors with our own CustomNumberEditor.
    this.defaultEditors.put(byte.class, new CustomNumberEditor(Byte.class, false));
    this.defaultEditors.put(Byte.class, new CustomNumberEditor(Byte.class, true));
    this.defaultEditors.put(short.class, new CustomNumberEditor(Short.class, false));
    this.defaultEditors.put(Short.class, new CustomNumberEditor(Short.class, true));
    this.defaultEditors.put(int.class, new CustomNumberEditor(Integer.class, false));
    this.defaultEditors.put(Integer.class, new CustomNumberEditor(Integer.class, true));
    this.defaultEditors.put(long.class, new CustomNumberEditor(Long.class, false));
    this.defaultEditors.put(Long.class, new CustomNumberEditor(Long.class, true));
    this.defaultEditors.put(float.class, new CustomNumberEditor(Float.class, false));
    this.defaultEditors.put(Float.class, new CustomNumberEditor(Float.class, true));
    this.defaultEditors.put(double.class, new CustomNumberEditor(Double.class, false));
    this.defaultEditors.put(Double.class, new CustomNumberEditor(Double.class, true));
    this.defaultEditors.put(BigDecimal.class, new CustomNumberEditor(BigDecimal.class, true));
    this.defaultEditors.put(BigInteger.class, new CustomNumberEditor(BigInteger.class, true));

    // Only register config value editors if explicitly requested.
    if (this.configValueEditorsActive) {
      StringArrayPropertyEditor sae = new StringArrayPropertyEditor();
      this.defaultEditors.put(String[].class, sae);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.