Example usage for org.springframework.beans.propertyeditors StringArrayPropertyEditor StringArrayPropertyEditor

List of usage examples for org.springframework.beans.propertyeditors StringArrayPropertyEditor StringArrayPropertyEditor

Introduction

In this page you can find the example usage for org.springframework.beans.propertyeditors StringArrayPropertyEditor StringArrayPropertyEditor.

Prototype

public StringArrayPropertyEditor(String separator) 

Source Link

Document

Create a new StringArrayPropertyEditor with the given separator.

Usage

From source file:net.sf.juffrou.reflect.spring.BeanWrapperTests.java

@Test
public void testStringArrayPropertyWithCustomStringDelimiter() throws Exception {
    PropsTester pt = new PropsTester();
    BeanWrapper bw = new JuffrouSpringBeanWrapper(pt);
    bw.registerCustomEditor(String[].class, "stringArray", new StringArrayPropertyEditor("-"));
    bw.setPropertyValue("stringArray", "a1-b2");
    assertTrue("stringArray length = 2", pt.stringArray.length == 2);
    assertTrue("correct values", pt.stringArray[0].equals("a1") && pt.stringArray[1].equals("b2"));
}

From source file:org.springframework.beans.AbstractPropertyAccessorTests.java

@Test
public void setStringArrayPropertyWithCustomStringDelimiter() throws Exception {
    PropsTester target = new PropsTester();
    AbstractPropertyAccessor accessor = createAccessor(target);
    accessor.registerCustomEditor(String[].class, "stringArray", new StringArrayPropertyEditor("-"));
    accessor.setPropertyValue("stringArray", "a1-b2");
    assertTrue("stringArray length = 2", target.stringArray.length == 2);
    assertTrue("correct values", target.stringArray[0].equals("a1") && target.stringArray[1].equals("b2"));
}

From source file:org.springframework.beans.BeanWrapperTests.java

@Test
public void testStringArrayPropertyWithCustomStringDelimiter() throws Exception {
    PropsTester pt = new PropsTester();
    BeanWrapper bw = new BeanWrapperImpl(pt);
    bw.registerCustomEditor(String[].class, "stringArray", new StringArrayPropertyEditor("-"));
    bw.setPropertyValue("stringArray", "a1-b2");
    assertTrue("stringArray length = 2", pt.stringArray.length == 2);
    assertTrue("correct values", pt.stringArray[0].equals("a1") && pt.stringArray[1].equals("b2"));
}