private FilterDirective[] buildFilterDirectives(Element element) throws Exception {
   if (null == element) {
     return new FilterDirective[0];
   } else {
     Element[] children = ElementHelper.getChildren(element);
     FilterDirective[] filters = new FilterDirective[children.length];
     for (int i = 0; i < children.length; i++) {
       Element child = children[i];
       String token = ElementHelper.getAttribute(child, "token");
       if ("filter".equals(child.getTagName())) {
         String value = ElementHelper.getAttribute(child, "value");
         filters[i] = new SimpleFilterDirective(token, value);
       } else if ("feature".equals(child.getTagName())) {
         String id = ElementHelper.getAttribute(child, "id").toUpperCase();
         Feature feature = Feature.valueOf(id);
         String ref = ElementHelper.getAttribute(child, "ref");
         String type = ElementHelper.getAttribute(child, "type");
         boolean alias = ElementHelper.getBooleanAttribute(child, "alias");
         filters[i] = new FeatureFilterDirective(token, ref, feature, type, alias);
       } else {
         final String error =
             "Element name not recognized [" + child.getTagName() + "] (expecting 'filter').";
         throw new DecodingException(error, null, element);
       }
     }
     return filters;
   }
 }
 private ProductionPolicy getProductionPolicy(Element element) {
   boolean flag = ElementHelper.getBooleanAttribute(element, "test", false);
   if (flag) {
     return ProductionPolicy.TEST;
   } else {
     return ProductionPolicy.DELIVERABLE;
   }
 }
 /**
  * Return the export attribute of the supplied element.
  *
  * @param element the DOM element
  * @return the export value
  */
 protected boolean getExportPolicy(Element element) {
   return ElementHelper.getBooleanAttribute(element, "export", true);
 }
 /**
  * Return the alias attribute of the supplied element.
  *
  * @param element the DOM element
  * @return the alias production flag value
  */
 protected boolean getAliasPolicy(Element element) {
   return ElementHelper.getBooleanAttribute(element, "alias", false);
 }
  private ResourceDirective buildResourceDirective(File base, Element element, String path)
      throws Exception {
    Classifier classifier = null;
    final String tag = element.getTagName();
    if (RESOURCE_ELEMENT_NAME.equals(tag)
        || PROJECT_ELEMENT_NAME.equals(tag)
        || MODULE_ELEMENT_NAME.equals(tag)) {
      final String name = ElementHelper.getAttribute(element, "name");
      final String version = ElementHelper.getAttribute(element, "version");
      String basedir = ElementHelper.getAttribute(element, "basedir");
      if (path != null) {
        if (basedir == null) {
          basedir = path;
        } else {
          basedir = path + "/" + basedir;
        }
      }

      if (PROJECT_ELEMENT_NAME.equals(tag)) {
        classifier = Classifier.LOCAL;
        if (null == basedir) {
          basedir = ".";
        }
      } else if (MODULE_ELEMENT_NAME.equals(tag)) {
        if (null != basedir) {
          classifier = Classifier.LOCAL;
        } else {
          classifier = Classifier.EXTERNAL;
        }
      } else {
        classifier = Classifier.EXTERNAL;
      }

      final boolean export = ElementHelper.getBooleanAttribute(element, "export", true);

      final InfoDirective info = buildInfoDirective(ElementHelper.getChild(element, "info"));

      final TypeDirective[] data = buildTypeDirectives(ElementHelper.getChild(element, "types"));

      final DependencyDirective[] dependencies =
          buildDependencyDirectives(ElementHelper.getChild(element, "dependencies"));

      final FilterDirective[] filters =
          buildFilterDirectives(ElementHelper.getChild(element, "filters"));

      final Properties properties = buildProperties(ElementHelper.getChild(element, "properties"));

      if (MODULE_ELEMENT_NAME.equals(tag)) {
        File anchor = getAnchorDirectory(base, basedir);
        ArrayList<ResourceDirective> list = new ArrayList<ResourceDirective>();
        Element[] children = ElementHelper.getChildren(element);
        for (int i = 0; i < children.length; i++) {
          Element child = children[i];
          final String t = child.getTagName();

          if (RESOURCE_ELEMENT_NAME.equals(t)
              || PROJECT_ELEMENT_NAME.equals(t)
              || MODULE_ELEMENT_NAME.equals(t)) {
            ResourceDirective directive = buildResourceDirectiveFromElement(anchor, child, null);
            list.add(directive);
          }
        }

        ResourceDirective[] resources = list.toArray(new ResourceDirective[0]);
        return ModuleDirective.createModuleDirective(
            name,
            version,
            classifier,
            basedir,
            info,
            data,
            dependencies,
            properties,
            filters,
            resources,
            export);
      } else {
        return ResourceDirective.createResourceDirective(
            name,
            version,
            classifier,
            basedir,
            info,
            data,
            dependencies,
            properties,
            filters,
            export);
      }
    } else {
      final String error = "Invalid element name [" + tag + "].";
      throw new DecodingException(error, null, element);
    }
  }