Source Code : Property Editor Bean

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Property Editor Bean

/*
Pro Spring
By Rob Harrop
Jan Machacek
ISBN: 1-59059-461-4
Publisher: Apress
*/



///////////////////////////////////////////////////////////////////////////////////////
//File: builtin.xml
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    <bean id="builtInSample" class="PropertyEditorBean">
        <property name="class">
            <value>java.lang.String</value>
        </property>
        <property name="file">
            <value>c:/test.txt</value>
        </property>
        <property name="locale">
            <value> en-GB </value>
        </property>
        <property name="url">
            <value>http://www.springframework.org</value>
        </property>
        <property name="properties">
            <value> 
                name=foo 
                age=19 
            </value>
        </property>
        <property name="strings">
            <value>rob,jan,rod,jurgen,alef</value>
        </property>
        <property name="bytes">
            <value>Hello World</value>
        </property>
    </bean>
</beans>


///////////////////////////////////////////////////////////////////////////////////////
import java.io.File;
import java.net.URL;
import java.util.Locale;
import java.util.Properties;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;

public class PropertyEditorBean {

    private Class cls;

    private File file;

    private URL url;

    private Locale locale;

    private Properties properties;

    private String[] strings;

    private byte[] bytes;

    public void setClass(Class cls) {
        System.out.println("Setting class: " + cls.getName());
        this.cls = cls;
    }

    public void setFile(File file) {
        System.out.println("Setting file: " + file.getName());
        this.file = file;
    }

    public void setLocale(Locale locale) {
        System.out.println("Setting locale: " + locale.getDisplayName());
        this.locale = locale;
    }

    public void setProperties(Properties properties) {
        System.out.println("Loaded " + properties.size() + " properties");
        this.properties = properties;
    }

    public void setStrings(String[] strings) {
        System.out.println("Loaded " + strings.length + " Strings");
        this.strings = strings;
    }

    public void setUrl(URL url) {
        System.out.println("Setting URL: " + url.toExternalForm());
        this.url = url;
    }

    public void setBytes(byte[] bytes) {
        System.out.println("Adding " + bytes.length + " bytes");
        this.bytes = bytes;
    }

    public static void main(String[] args) {
        BeanFactory factory = new XmlBeanFactory(new FileSystemResource(
                "build/builtin.xml"));
        PropertyEditorBean bean = (PropertyEditorBean) factory
                .getBean("builtInSample");
    }
}

           
       

Thank with us