/** Sets the value of the attribute */
  public void setValue(Object bean, QName name, Object value) throws ConfigException {
    try {
      if (value instanceof XmlBeanConfig<?>) {
        XmlBeanConfig<?> config = (XmlBeanConfig<?>) value;

        value = config.toObject();
      } else if (value instanceof AnnotationConfig) {
        AnnotationConfig config = (AnnotationConfig) value;

        value = config.replace();
      }

      if (_setMethod != null && value != null) {
        if (!_setMethod.getParameterTypes()[0].isAssignableFrom(value.getClass()))
          throw new ConfigException(
              L.l(
                  "'{0}.{1}' is not assignable from {2}",
                  _setMethod.getDeclaringClass().getSimpleName(), _setMethod.getName(), value));

        _setMethod.invoke(bean, value);
      }
    } catch (Exception e) {
      throw ConfigException.create(e);
    }
  }
  /** Creates the child bean. */
  @Override
  public Object create(Object parent, QName qName) throws ConfigException {
    Class<?> cl = TypeFactory.loadClass(qName);

    if (cl == null) {
      ConfigType<?> type = TypeFactory.getFactory().getEnvironmentType(qName);

      if (type != null) return type.create(parent, qName);

      throw new ConfigException(
          L.l(
              "'{0}.{1}' is an unknown class for element '{2}'",
              qName.getNamespaceURI(), qName.getLocalName(), qName));
    }

    if (Annotation.class.isAssignableFrom(cl)) {
      return new AnnotationConfig(cl);
    } else {
      XmlBeanConfig<?> config = new XmlBeanConfig(qName, cl, parent);
      config.setInlineBean(true);

      // config.setScope("singleton");

      return config;
    }
  }
  /** Sets the value of the attribute as text */
  @Override
  public void setText(Object bean, QName name, String value) throws ConfigException {
    Object objValue = create(bean, name);

    if (objValue instanceof XmlBeanConfig<?>) {
      XmlBeanConfig<?> config = (XmlBeanConfig<?>) objValue;

      if (!value.trim().equals("")) {
        config.addArg(new TextArgProgram(value));
      }

      config.init();
    }

    setValue(bean, name, objValue);
  }