Package java.beans

Examples of java.beans.PropertyEditor


            "  <dep:hidden-classes/>\n" +
            "  <dep:non-overridable-classes/>\n" +
            "</dep:environment>";

    public void xtestPropertyEditor() throws Exception {
        PropertyEditor editor = new EnvironmentBuilder();
        editor.setAsText(ENV_1);
        Environment environment = (Environment) editor.getValue();
        editor.setValue(environment);
        String text = editor.getAsText();
        assertEquals(text, ENV_1);
    }
View Full Code Here


        assertEquals(text, ENV_1);
    }

    public void testPropertyEditorRegistration() throws Exception {
        ServiceConfigBuilder.getGBeanInfo();
        PropertyEditor propertyEditor = PropertyEditorManager.findEditor(Environment.class);
        assertTrue(propertyEditor instanceof EnvironmentBuilder);
    }
View Full Code Here

        if (value == null) {
            return null;
        }

        try {
            PropertyEditor editor = PropertyEditors.findEditor(attribute.getType(), classLoader);
            if (editor == null) {
                log.debug("Unable to parse attribute of type " + attribute.getType() + "; no editor found");
                return null;
            }
            editor.setAsText(value);
            log.debug("Setting value for " + configurationName + "/" + gbeanName + "/" + attribute.getName() + " to value " + value);
            return editor.getValue();
        } catch (ClassNotFoundException e) {
            log.error("Unable to load attribute type " + attribute.getType());
            return null;
        }
    }
View Full Code Here

    public static String getAsText(Object value, String type) throws InvalidAttributeException {
        try {
            String attributeStringValue = null;
            if (value != null) {
                PropertyEditor editor = PropertyEditors.findEditor(type, GBeanOverride.class.getClassLoader());
                if (editor == null) {
                    throw new InvalidAttributeException("Unable to format attribute of type " + type + "; no editor found");
                }
                editor.setValue(value);
                attributeStringValue = editor.getAsText();
            }
            return attributeStringValue;
        } catch (ClassNotFoundException e) {
            //todo: use the Configuration's ClassLoader to load the attribute, if this ever becomes an issue
            throw new InvalidAttributeException("Unable to store attribute type " + type);
View Full Code Here

            // FIXME we should throw something better
            throw new ConfigurationLoadException(e.getCause());
        }

        // do we have a property editor for it?
        PropertyEditor editor = PropertyEditorManager.findEditor(type);
        if (editor != null) {
            try {
                editor.setAsText(text);
                return new SingletonObjectFactory(editor.getValue());
            } catch (IllegalArgumentException e) {
                // FIXME we should throw something better
                throw new ConfigurationLoadException(e);

            }
View Full Code Here

    private Object convertValueForAssignment(Object target, String value)
    {
        if (value == null || _propertyType.isInstance(value))
            return value;

        PropertyEditor e = PropertyEditorManager.findEditor(_propertyType);

        if (e == null)
        {
            Object convertedValue = instantiateViaStringConstructor(target, value);

            if (convertedValue != null)
                return convertedValue;

            throw new ApplicationRuntimeException(UtilMessages.noPropertyEditor(
                    _propertyName,
                    target.getClass()));
        }

        try
        {
            e.setAsText(value);

            return e.getValue();
        }
        catch (Exception ex)
        {
            throw new ApplicationRuntimeException(UtilMessages.unableToConvert(
                    value,
View Full Code Here

            if (Number.class.isAssignableFrom(clazz) || Date.class.isAssignableFrom(clazz)) {
                return null;
            }
        }

        PropertyEditor editor = PropertyEditors.getEditor(clazz);
        editor.setAsText(value);
        return editor.getValue();
    }
View Full Code Here

            "  <dep:hidden-classes/>\n" +
            "  <dep:non-overridable-classes/>\n" +
            "</dep:environment>";

    public void xtestPropertyEditor() throws Exception {
        PropertyEditor editor = new EnvironmentBuilder();
        editor.setAsText(ENV_1);
        Environment environment = (Environment) editor.getValue();
        editor.setValue(environment);
        String text = editor.getAsText();
        assertEquals(text, ENV_1);
    }
View Full Code Here

        assertEquals(text, ENV_1);
    }

    public void testPropertyEditorRegistration() throws Exception {
        ServiceConfigBuilder.getGBeanInfo();
        PropertyEditor propertyEditor = PropertyEditorManager.findEditor(Environment.class);
        assertTrue(propertyEditor instanceof EnvironmentBuilder);
    }
View Full Code Here

                    throw new DeploymentException("Unknown attribute " + name + " on " + gbean.getAbstractName());
                }
                type = attribute.getType();
            }

            PropertyEditor editor = PropertyEditors.findEditor(type, classLoader);
            if (editor == null) {
                throw new DeploymentException("Unable to find PropertyEditor for " + type);
            }
            editor.setAsText(text);
            Object value = editor.getValue();
            gbean.setAttribute(name, value);
        } catch (DeploymentException e) {
            throw e;
        } catch (ClassNotFoundException e) {
            throw new DeploymentException("Unable to find PropertyEditor for " + type, e);
View Full Code Here

TOP

Related Classes of java.beans.PropertyEditor

Copyright © 2018 www.massapicom. 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.