Examples of PropertyConverter


Examples of org.jgroups.conf.PropertyConverter

                if(field.isAnnotationPresent(Property.class)) {
                    Object value=Configurator.getField(field, prot);
                    if(value != null) {
                        annotation=field.getAnnotation(Property.class);
                        Class<?> conv_class=annotation.converter();
                        PropertyConverter conv=null;
                        try {
                            conv=(PropertyConverter)conv_class.newInstance();
                        }
                        catch(Exception e) {
                        }
                        String tmp=conv != null? conv.toString(value) : value.toString();
                        retval.put(field.getName(), tmp);
                    }
                }
            }

            // copy all setters marked with @Property
            Method[] methods=clazz.getDeclaredMethods();
            for(Method method: methods) {
                String methodName=method.getName();
                if(method.isAnnotationPresent(Property.class) && Configurator.isSetPropertyMethod(method)) {
                    annotation=method.getAnnotation(Property.class);
                    List<String> possible_names=new LinkedList<String>();
                    if(annotation.name() != null)
                        possible_names.add(annotation.name());
                    possible_names.add(methodName.substring(3));
                    possible_names.add(Util.methodNameToAttributeName(methodName));
                    Field field=findField(prot, possible_names);
                    if(field != null) {
                        Object value=Configurator.getField(field, prot);
                        if(value != null) {
                            Class<?> conv_class=annotation.converter();
                            PropertyConverter conv=null;
                            try {
                                conv=(PropertyConverter)conv_class.newInstance();
                            }
                            catch(Exception e) {
                            }
                            String tmp=conv != null? conv.toString(value) : value.toString();
                            retval.put(field.getName(), tmp);
                        }
                    }
                }
            }
View Full Code Here

Examples of org.jgroups.conf.PropertyConverter

                Property annotation=method.getAnnotation(Property.class);
                String propertyName=annotation.name().length() > 0? annotation.name() : methodName.substring(3);
                propertyName=renameFromJavaCodingConvention(propertyName);
                String prop=props.getProperty(propertyName);
                if(prop != null) {
                    PropertyConverter propertyConverter=(PropertyConverter)annotation.converter().newInstance();
                    if(propertyConverter == null) {
                        String name=obj instanceof Protocol? ((Protocol)obj).getName() : obj.getClass().getName();
                        throw new Exception("Could not find property converter for field " + propertyName
                                + " in " + name);
                    }
                    Object converted=null;
                    try {
                        converted=propertyConverter.convert(method.getParameterTypes()[0], props, prop);
                        method.invoke(obj, converted);
                    }
                    catch(Exception e) {
                        String name=obj instanceof Protocol? ((Protocol)obj).getName() : obj.getClass().getName();
                        throw new Exception("Could not assign property " + propertyName + " in "
View Full Code Here

Examples of org.jgroups.conf.PropertyConverter

                            log.warn(annotation.deprecatedMessage());
                        }
                    }
                    String propertyValue=props.getProperty(propertyName);
                    if(propertyValue != null || !annotation.converter().equals(PropertyConverters.Default.class)){
                        PropertyConverter propertyConverter=(PropertyConverter)annotation.converter().newInstance();
                        if(propertyConverter == null) {
                            String name=obj instanceof Protocol? ((Protocol)obj).getName() : obj.getClass().getName();
                            throw new Exception("Could not find property converter for field " + propertyName
                                    + " in " + name);
                        }
                        Object converted=null;
                        try {
                            converted=propertyConverter.convert(field.getType(), props, propertyValue);
                            if(converted != null)
                                setField(field, obj, converted);
                        }
                        catch(Exception e) {
                            String name=obj instanceof Protocol? ((Protocol)obj).getName() : obj.getClass().getName();
View Full Code Here

Examples of org.jgroups.conf.PropertyConverter

                if(field.isAnnotationPresent(Property.class)) {
                    Object value=Configurator.getField(field, prot);
                    if(value != null) {
                        annotation=field.getAnnotation(Property.class);
                        Class<?> conv_class=annotation.converter();
                        PropertyConverter conv=null;
                        try {
                            conv=(PropertyConverter)conv_class.newInstance();
                        }
                        catch(Exception e) {
                        }
                        String tmp=conv != null? conv.toString(value) : value.toString();
                        retval.put(field.getName(), tmp);
                    }
                }
            }

            // copy all setters marked with @Property
            Method[] methods=clazz.getDeclaredMethods();
            for(Method method: methods) {
                String methodName=method.getName();
                if(method.isAnnotationPresent(Property.class) && Configurator.isSetPropertyMethod(method)) {
                    annotation=method.getAnnotation(Property.class);
                    List<String> possible_names=new LinkedList<String>();
                    if(annotation.name() != null)
                        possible_names.add(annotation.name());
                    possible_names.add(methodName.substring(3));
                    possible_names.add(Util.methodNameToAttributeName(methodName));
                    Field field=findField(prot, possible_names);
                    if(field != null) {
                        Object value=Configurator.getField(field, prot);
                        if(value != null) {
                            Class<?> conv_class=annotation.converter();
                            PropertyConverter conv=null;
                            try {
                                conv=(PropertyConverter)conv_class.newInstance();
                            }
                            catch(Exception e) {
                            }
                            String tmp=conv != null? conv.toString(value) : value.toString();
                            retval.put(field.getName(), tmp);
                        }
                    }
                }
            }
View Full Code Here

Examples of org.jgroups.conf.PropertyConverter

                if(field.isAnnotationPresent(Property.class)) {
                    Object value=Configurator.getField(field, prot);
                    if(value != null) {
                        annotation=field.getAnnotation(Property.class);
                        Class<?> conv_class=annotation.converter();
                        PropertyConverter conv=null;
                        try {
                            conv=(PropertyConverter)conv_class.newInstance();
                        }
                        catch(Exception e) {
                        }
                        String tmp=conv != null? conv.toString(value) : value.toString();
                        retval.put(field.getName(), tmp);
                    }
                }
            }

            // copy all setters marked with @Property
            Method[] methods=clazz.getDeclaredMethods();
            for(Method method: methods) {
                String methodName=method.getName();
                if(method.isAnnotationPresent(Property.class) && Configurator.isSetPropertyMethod(method)) {
                    annotation=method.getAnnotation(Property.class);
                    List<String> possible_names=new LinkedList<String>();
                    if(annotation.name() != null)
                        possible_names.add(annotation.name());
                    possible_names.add(methodName.substring(3));
                    possible_names.add(Configurator.renameFromJavaCodingConvention(methodName.substring(3)));
                    Field field=findField(prot, possible_names);
                    if(field != null) {
                        Object value=Configurator.getField(field, prot);
                        if(value != null) {
                            Class<?> conv_class=annotation.converter();
                            PropertyConverter conv=null;
                            try {
                                conv=(PropertyConverter)conv_class.newInstance();
                            }
                            catch(Exception e) {
                            }
                            String tmp=conv != null? conv.toString(value) : value.toString();
                            retval.put(field.getName(), tmp);
                        }
                    }
                }
            }
View Full Code Here

Examples of org.mule.api.expression.PropertyConverter

    {
        String prop = parsePlaceholderValues(property);
        Collection c = muleContext.getRegistry().lookupObjects(PropertyConverter.class);
        for (Iterator iterator = c.iterator(); iterator.hasNext();)
        {
            PropertyConverter converter = (PropertyConverter) iterator.next();
            if (converter.getType().equals(type))
            {
                return converter.convert(prop, muleContext);
            }
        }
        throw new IllegalArgumentException(AnnotationsMessages.noPropertyConverterForType(type).getMessage());
    }
View Full Code Here

Examples of org.mule.api.expression.PropertyConverter

    {
        String prop = parsePlaceholderValues(property);
        Collection c = muleContext.getRegistry().lookupObjects(PropertyConverter.class);
        for (Iterator iterator = c.iterator(); iterator.hasNext();)
        {
            PropertyConverter converter = (PropertyConverter) iterator.next();
            if (converter.getType().equals(type))
            {
                return converter.convert(prop, muleContext);
            }
        }
        throw new IllegalArgumentException(AnnotationsMessages.noPropertyConverterForType(type).getMessage());
    }
View Full Code Here

Examples of org.springframework.data.neo4j.fieldaccess.PropertyConverter

    protected Object convertIfNecessary(Neo4jTemplate template, Object value, Neo4jPersistentProperty property) {
        if (property.isIndexedNumerically()) return new ValueContext(value).indexNumeric();
        if (property.isNeo4jPropertyType() && property.isNeo4jPropertyValue(value)) return value;

        PropertyConverter converter = new PropertyConverter(template.getConversionService(), property);
        return converter.serializeIfNotBuiltIn(value);
    }
View Full Code Here

Examples of org.springframework.data.neo4j.fieldaccess.PropertyConverter

        Assert.notNull(partInfo.getType());
        this.partInfo = partInfo;
        this.type = this.partInfo.getType();
        Neo4jPersistentProperty property = partInfo.getLeafProperty();
        if (!property.isNeo4jPropertyType()) {
            propertyConverter = new PropertyConverter(template.getConversionService(), property);
        }
    }
View Full Code Here

Examples of org.springframework.data.neo4j.fieldaccess.PropertyConverter

    }

    private Object getSerializedUniqueValue(Object entity, Neo4jPersistentProperty uniqueProperty) {
        final Object value = uniqueProperty.getValueFromEntity(entity, MappingPolicy.MAP_FIELD_DIRECT_POLICY);
        if (uniqueProperty.isSerializablePropertyField(conversionService))
            return new PropertyConverter(conversionService,uniqueProperty).serializeIfNotBuiltIn(value);
        return value;
    }
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.