Examples of CustomNumberEditor


Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

  @Test
  public void testGenericMapWithCollectionValue() {
    GenericBean<?> gb = new GenericBean<Object>();
    BeanWrapper bw = new BeanWrapperImpl(gb);
    bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false));
    Map<String, Collection> input = new HashMap<String, Collection>();
    HashSet<Integer> value1 = new HashSet<Integer>();
    value1.add(new Integer(1));
    input.put("1", value1);
    ArrayList<Boolean> value2 = new ArrayList<Boolean>();
View Full Code Here

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

  @Test
  public void testGenericMapElementWithCollectionValue() {
    GenericBean<?> gb = new GenericBean<Object>();
    gb.setCollectionMap(new HashMap<Number, Collection<? extends Object>>());
    BeanWrapper bw = new BeanWrapperImpl(gb);
    bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false));
    HashSet<Integer> value1 = new HashSet<Integer>();
    value1.add(new Integer(1));
    bw.setPropertyValue("collectionMap[1]", value1);
    assertTrue(gb.getCollectionMap().get(new Integer(1)) instanceof HashSet);
  }
View Full Code Here

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

  public void testGenericMapWithCollectionValueConstructor() throws MalformedURLException {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    bf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
      @Override
      public void registerCustomEditors(PropertyEditorRegistry registry) {
        registry.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false));
      }
    });
    RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);

    Map<String, AbstractCollection<?>> input = new HashMap<String, AbstractCollection<?>>();
View Full Code Here

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

  public void testGenericMapWithCollectionValueFactoryMethod() throws MalformedURLException {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    bf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
      @Override
      public void registerCustomEditors(PropertyEditorRegistry registry) {
        registry.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false));
      }
    });
    RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
    rbd.setFactoryMethodName("createInstance");
View Full Code Here

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

  }

  public void testBindingWithCustomEditorOnObjectField() {
    BeanWithObjectProperty tb = new BeanWithObjectProperty();
    DataBinder binder = new DataBinder(tb);
    binder.registerCustomEditor(Integer.class, "object", new CustomNumberEditor(Integer.class, true));
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("object", "1");
    binder.bind(pvs);
    assertEquals(new Integer(1), tb.getObject());
  }
View Full Code Here

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
      @Override
      public void registerCustomEditors(PropertyEditorRegistry registry) {
        NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
        registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
      }
    });
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("myFloat", "1,1");
    RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
View Full Code Here

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
      @Override
      public void registerCustomEditors(PropertyEditorRegistry registry) {
        NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
        registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
      }
    });
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("myFloat", new RuntimeBeanReference("myFloat"));
    RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
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

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

     */
    protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) {

        NumberFormat nf = NumberFormat.getNumberInstance(request.getLocale());
        nf.setMaximumFractionDigits(7);
        binder.registerCustomEditor(Integer.class, null, new CustomNumberEditor(Integer.class, null, true));
        binder.registerCustomEditor(Integer.class, null, new CustomNumberEditor(Integer.class, null, true));
        binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
        SimpleDateFormat dateFormat = new SimpleDateFormat(getText("date.format", request.getLocale()));
        dateFormat.setLenient(false);
        binder.registerCustomEditor(Date.class, null, new CustomDateEditor(dateFormat, true));
        nf.setMinimumFractionDigits(0);
        binder.registerCustomEditor(Double.class, new CustomNumberEditor(Double.class, null, true));
        binder.registerCustomEditor(Double.TYPE, new CustomNumberEditor(Double.class, null, true));
    }
View Full Code Here

Examples of org.springframework.beans.propertyeditors.CustomNumberEditor

    assertEquals("7", gb.getLongMap().get(new Long("6")));
  }

  public void testGenericMapWithCollectionValueConstructor() throws MalformedURLException {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    bf.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false));
    RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);

    Map input = new HashMap();
    HashSet value1 = new HashSet();
    value1.add(new Integer(1));
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.