Пример #1
0
  /**
   * Parse an element tree and return the module found in it.
   *
   * <p>
   *
   * @param dcRoot the root element containing the module elements.
   * @return the module parsed from the element tree, <i>null</i> if none.
   */
  public Module parse(Element dcRoot) {
    boolean foundSomething = false;
    DCModule dcm = new DCModuleImpl();

    List eList = dcRoot.getChildren("title", getDCNamespace());
    if (eList.size() > 0) {
      foundSomething = true;
      dcm.setTitles(parseElementList(eList));
    }
    eList = dcRoot.getChildren("creator", getDCNamespace());
    if (eList.size() > 0) {
      foundSomething = true;
      dcm.setCreators(parseElementList(eList));
    }
    eList = dcRoot.getChildren("subject", getDCNamespace());
    if (eList.size() > 0) {
      foundSomething = true;
      dcm.setSubjects(parseSubjects(eList));
    }
    eList = dcRoot.getChildren("description", getDCNamespace());
    if (eList.size() > 0) {
      foundSomething = true;
      dcm.setDescriptions(parseElementList(eList));
    }
    eList = dcRoot.getChildren("publisher", getDCNamespace());
    if (eList.size() > 0) {
      foundSomething = true;
      dcm.setPublishers(parseElementList(eList));
    }
    eList = dcRoot.getChildren("contributor", getDCNamespace());
    if (eList.size() > 0) {
      foundSomething = true;
      dcm.setContributors(parseElementList(eList));
    }
    eList = dcRoot.getChildren("date", getDCNamespace());
    if (eList.size() > 0) {
      foundSomething = true;
      dcm.setDates(parseElementListDate(eList));
    }
    eList = dcRoot.getChildren("type", getDCNamespace());
    if (eList.size() > 0) {
      foundSomething = true;
      dcm.setTypes(parseElementList(eList));
    }
    eList = dcRoot.getChildren("format", getDCNamespace());
    if (eList.size() > 0) {
      foundSomething = true;
      dcm.setFormats(parseElementList(eList));
    }
    eList = dcRoot.getChildren("identifier", getDCNamespace());
    if (eList.size() > 0) {
      foundSomething = true;
      dcm.setIdentifiers(parseElementList(eList));
    }
    eList = dcRoot.getChildren("source", getDCNamespace());
    if (eList.size() > 0) {
      foundSomething = true;
      dcm.setSources(parseElementList(eList));
    }
    eList = dcRoot.getChildren("language", getDCNamespace());
    if (eList.size() > 0) {
      foundSomething = true;
      dcm.setLanguages(parseElementList(eList));
    }
    eList = dcRoot.getChildren("relation", getDCNamespace());
    if (eList.size() > 0) {
      foundSomething = true;
      dcm.setRelations(parseElementList(eList));
    }
    eList = dcRoot.getChildren("coverage", getDCNamespace());
    if (eList.size() > 0) {
      foundSomething = true;
      dcm.setCoverages(parseElementList(eList));
    }
    eList = dcRoot.getChildren("rights", getDCNamespace());
    if (eList.size() > 0) {
      foundSomething = true;
      dcm.setRightsList(parseElementList(eList));
    }

    return (foundSomething) ? dcm : null;
  }