Ejemplo n.º 1
0
    private ResourcesDef readResourcesDefinition(Element resourcesElement) {
      String name = resourcesElement.getAttribute("name");
      Assert.ifEmpty(name, "can`t read resources bundle without name");

      ResourcesDef resDef = new ResourcesDef(name);

      String depends = resourcesElement.getAttribute("depends");
      if (isNoneEmpty(depends)) {
        resDef.setDepends(
            Arrays.stream(StringUtils.split(depends, ","))
                .map(StringUtils::trim)
                .collect(Collectors.toList()));
      }

      readResources(resourcesElement, resDef);

      return resDef;
    }
Ejemplo n.º 2
0
    private void readResources(Element resourcesElement, ResourcesDef resDef) {
      XmlUtils.iterateSubElements(
          resourcesElement,
          element -> {
            XmlManifestResourceElement resourceElement = new XmlManifestResourceElement(element);

            Optional<ResourceReader> optional =
                resourcesReaders
                    .stream()
                    .filter(reader -> reader.accept(resourceElement))
                    .findFirst();

            try {
              if (optional.isPresent())
                resDef.addResource(optional.get().read(resourceElement, fileScope));
            } catch (Exception e) {
              throw new JumbleException("Fail to load resource: " + element.getTagName(), e);
            }
          });
    }