/**
   * Register a new resource which should correspond to a resource tag in the .ui.xml file.
   *
   * @param localName The type of the resource ('with', 'style', 'image' or 'data')
   * @param attributes Map of attributes parsed from the tag
   * @param parentTag The parent tag if any
   * @param owner The {@link UiBinder} owner widget, which calls the {@link
   *     UiBinder#createAndBindUi(Object)} method to initialize itself.
   * @return The UiBinderTag which wraps the Resource instance.
   * @throws GwtTestUiBinderException If the localName is not managed or if the alias is already
   *     binded to another Resource object
   */
  UiTag<?> registerResource(
      String localName, Map<String, Object> attributes, UiTag<?> parentTag, Object owner)
      throws GwtTestUiBinderException {

    String alias = getResourceAlias(localName, attributes);

    if (resources.containsKey(alias)) {
      throw new GwtTestUiBinderException(
          "Two inner resources '"
              + alias
              + " are declared in "
              + owner.getClass().getSimpleName()
              + ".ui.xml. You should add a 'field' attribute to one of them");
    }

    Class<?> type = getResourceType(alias, localName, attributes);

    if ("with".equals(localName)) {
      // special resource <ui:with> : the resource can be annotated with
      // @UiConstructor, @UiFactory or @UiField(provided=true)
      Object resource = UiBinderInstanciator.getInstance(type, attributes, owner);
      resources.put(alias, resource);
      return new UiWithTag(resource);
    }

    ResourcePrototypeProxyBuilder builder =
        ResourcePrototypeProxyBuilder.createBuilder(type, owner.getClass());
    // common properties
    builder.name(alias);

    if ("style".equals(localName)) {
      // <ui:style>
      return new UiStyleTag(builder, alias, parentTag, owner, resources);

    } else if ("image".equals(localName)) {
      // <ui:image>
      return new UiBinderImage(builder, alias, parentTag, owner, resources, attributes);

    } else if ("data".equals(localName)) {
      // <ui:data>
      return new UiDataTag(builder, alias, parentTag, owner, resources, attributes);

    } else {
      throw new GwtTestUiBinderException(
          "resource <" + localName + "> element is not yet implemented by gwt-test-utils");
    }
  }
    UiDataTag(
        ResourcePrototypeProxyBuilder builder,
        String alias,
        UiTag<?> parentTag,
        Object owner,
        Map<String, Object> resources,
        Map<String, Object> attributes) {
      super(builder, alias, parentTag, owner, resources);

      // handle "src" attribute
      String src = (String) attributes.get("src");
      builder.resourceURL(computeImageURL(owner, src));
    }
 @Override
 protected Object buildObject(ResourcePrototypeProxyBuilder builder) {
   return builder.build();
 }
 @Override
 protected Object buildObject(ResourcePrototypeProxyBuilder builder) {
   return builder.text(text.toString()).build();
 }