protected void appendConfigProperties()

in empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java [392:447]


    protected void appendConfigProperties(Class<?> clazz, Object object, StringBuilder b, boolean appendClassInfo)
    {
        Field[] fields = clazz.getDeclaredFields();
        for (Field field : fields) {
            // ignore static fields
            int modifiers = field.getModifiers();
            if (Modifier.isStatic(modifiers) || Modifier.isFinal(modifiers))
                continue;
            // make accessible
            try
            {
                Object value = PropertyUtils.getProperty(object, field.getName());
                if (value!=null && !(value instanceof Map<?,?>))
                {
                    Class<?> vc = value.getClass();
                    boolean simple = (vc.isPrimitive() || vc.isEnum() 
                         || vc == String.class  || vc == Character.class || vc == Byte.class 
                         || vc == Integer.class || vc == Long.class  || vc == Short.class 
                         || vc == Double.class  || vc == Float.class || vc == Boolean.class
                         || vc == Class.class);
                    // Nested?
                    if (!simple)
                    {   // Nested Class
                        b.append(EOC);
                        b.append(field.getName());
                        b.append("[");
                        b.append(clazz.getName());
                        b.append("]=");
                        b.append(EOL);
                        appendConfigProperties(value.getClass(), value, b, false);
                        return;
                    }
                }
                // class info 
                if (appendClassInfo)
                {   appendClassInfo = false;
                    b.append("[Properties of ");
                    b.append(clazz.getName());
                    b.append("]");
                    b.append(EOL);
                }
                // property value
                b.append(field.getName());
                b.append("=");
                b.append(String.valueOf(value));
                b.append(EOL);
            }
            catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e)
            {
                Throwable cause = (e.getCause()!=null ? e.getCause() : e);
                log.warn("Field {} is ignored due to Exception {}", field.getName(), cause.toString());
            }
        }
        if (appendClassInfo==false)
            b.append(EOC);
    }