Package java.beans

Examples of java.beans.PropertyEditor


            return false;
        }
    }

    private static Object convert(Object value, Class type) throws URISyntaxException {
        PropertyEditor editor = PropertyEditorManager.findEditor(type);
        if (editor != null) {
            editor.setAsText(value.toString());
            return editor.getValue();
        }
        if (type == URI.class) {
            return new URI(value.toString());
        }
        return null;
View Full Code Here


        }
        return null;
    }

    private static String convertToString(Object value, Class type) throws URISyntaxException {
        PropertyEditor editor = PropertyEditorManager.findEditor(type);
        if (editor != null) {
            editor.setValue(value);
            return editor.getAsText();
        }
        if (type == URI.class) {
            return ((URI)value).toString();
        }
        return null;
View Full Code Here

            // No conversion needed.
            if (toType == String.class) {
                return toType.cast(value);
            }

            PropertyEditor editor = PropertyEditorManager.findEditor(toType);
            if (editor != null) {
                editor.setAsText(value.toString());
                return toType.cast(editor.getValue());
            }

        } else if (toType == String.class) {

            PropertyEditor editor = PropertyEditorManager.findEditor(value.getClass());
            if (editor != null) {
                editor.setValue(value);
                return toType.cast(editor.getAsText());
            }

        }
        return null;
    }
View Full Code Here

        }

        public String getStringValue() {
//            Class<T> clazz = getClass().getTypeParameters();
            if (value == null) return null;
            PropertyEditor propertyEditor = PropertyEditors.getEditor(clazz);
            propertyEditor.setValue(value);
            return propertyEditor.getAsText();
        }
View Full Code Here

            propertyEditor.setValue(value);
            return propertyEditor.getAsText();
        }

        public void setStringValue(String stringValue) {
            PropertyEditor propertyEditor = PropertyEditors.getEditor(clazz);
            propertyEditor.setAsText(stringValue);
            this.value = (T) propertyEditor.getValue();
        }
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

            inputValue = _default;
        }

        try
        {
            PropertyEditor e = PropertyEditorManager.findEditor(propertyType);

            if (e == null)
                throw new ApplicationRuntimeException(
                    RulesMessages.noPropertyEditor(propertyType),
                    location,
                    null);

            e.setAsText(inputValue);

            return e.getValue();
        }
        catch (Exception ex)
        {
            throw new ApplicationRuntimeException(
                RulesMessages.smartTranslatorError(inputValue, propertyType, ex),
View Full Code Here

            String propertyString = property.getStringValue().trim();
            for (int j = 0; j < propertyDescriptors.length; j++) {
                PropertyDescriptor propertyDescriptor = propertyDescriptors[j];
                if (propertyName.equals(propertyDescriptor.getName())) {
                    String type = propertyDescriptor.getPropertyType().getName();
                    PropertyEditor propertyEditor = null;
                    try {
                        propertyEditor = PropertyEditors.findEditor(type, cl);
                    } catch (ClassNotFoundException e) {
                        throw new DeploymentException("Could not load editor for type " + type, e);
                    }
                    if (propertyEditor == null) {
                        throw new DeploymentException("Unable to find PropertyEditor for " + type);
                    }
                    propertyEditor.setAsText(propertyString);
                    Object value = propertyEditor.getValue();
                    Method m = propertyDescriptor.getWriteMethod();
                    try {
                        m.invoke(instance, new Object[] {value});
                    } catch (Exception e) {
                        throw new DeploymentException("Could not set property value for property named " + propertyName, e);
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

            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

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.