Exemplo n.º 1
0
  private Entry parseEntry(Element eEntry) {
    Entry entry = new Entry();

    Element e = eEntry.getChild("title", getAtomNamespace());
    if (e != null) {
      entry.setTitleEx(parseContent(e));
    }

    List<Element> eList = eEntry.getChildren("link", getAtomNamespace());
    entry.setAlternateLinks(parseAlternateLinks(eList));
    entry.setOtherLinks(parseOtherLinks(eList));

    e = eEntry.getChild("author", getAtomNamespace());
    if (e != null) {
      List<Person> authors = new ArrayList<Person>();
      authors.add(parsePerson(e));
      entry.setAuthors(authors);
    }

    eList = eEntry.getChildren("contributor", getAtomNamespace());
    if (eList.size() > 0) {
      entry.setContributors(parsePersons(eList));
    }

    e = eEntry.getChild("id", getAtomNamespace());
    if (e != null) {
      entry.setId(e.getText());
    }

    e = eEntry.getChild("modified", getAtomNamespace());
    if (e != null) {
      entry.setModified(DateParser.parseDate(e.getText()));
    }

    e = eEntry.getChild("issued", getAtomNamespace());
    if (e != null) {
      entry.setIssued(DateParser.parseDate(e.getText()));
    }

    e = eEntry.getChild("created", getAtomNamespace());
    if (e != null) {
      entry.setCreated(DateParser.parseDate(e.getText()));
    }

    e = eEntry.getChild("summary", getAtomNamespace());
    if (e != null) {
      entry.setSummary(parseContent(e));
    }

    eList = eEntry.getChildren("content", getAtomNamespace());
    if (eList.size() > 0) {
      List<Content> content = new ArrayList<Content>();
      for (int i = 0; i < eList.size(); i++) {
        content.add(parseContent(eList.get(i)));
      }
      entry.setContents(content);
    }

    entry.setModules(parseItemModules(eEntry));

    List<Element> foreignMarkup = extractForeignMarkup(eEntry, entry, getAtomNamespace());
    if (foreignMarkup.size() > 0) {
      entry.setForeignMarkup(foreignMarkup);
    }
    return entry;
  }
Exemplo n.º 2
0
  protected Entry parseEntry(
      final Feed feed, final Element eEntry, final String baseURI, final Locale locale) {
    final Entry entry = new Entry();

    final String xmlBase = eEntry.getAttributeValue("base", Namespace.XML_NAMESPACE);
    if (xmlBase != null) {
      entry.setXmlBase(xmlBase);
    }

    Element e = eEntry.getChild("title", getAtomNamespace());
    if (e != null) {
      final Content c = new Content();
      c.setValue(parseTextConstructToString(e));
      c.setType(getAttributeValue(e, "type"));
      entry.setTitleEx(c);
    }

    List<Element> eList = eEntry.getChildren("link", getAtomNamespace());
    entry.setAlternateLinks(parseAlternateLinks(feed, entry, baseURI, eList));
    entry.setOtherLinks(parseOtherLinks(feed, entry, baseURI, eList));

    eList = eEntry.getChildren("author", getAtomNamespace());
    if (eList.size() > 0) {
      entry.setAuthors(parsePersons(baseURI, eList, locale));
    }

    eList = eEntry.getChildren("contributor", getAtomNamespace());
    if (eList.size() > 0) {
      entry.setContributors(parsePersons(baseURI, eList, locale));
    }

    e = eEntry.getChild("id", getAtomNamespace());
    if (e != null) {
      entry.setId(e.getText());
    }

    e = eEntry.getChild("updated", getAtomNamespace());
    if (e != null) {
      entry.setUpdated(DateParser.parseDate(e.getText(), locale));
    }

    e = eEntry.getChild("published", getAtomNamespace());
    if (e != null) {
      entry.setPublished(DateParser.parseDate(e.getText(), locale));
    }

    e = eEntry.getChild("summary", getAtomNamespace());
    if (e != null) {
      entry.setSummary(parseContent(e));
    }

    e = eEntry.getChild("content", getAtomNamespace());
    if (e != null) {
      final List<Content> contents = new ArrayList<Content>();
      contents.add(parseContent(e));
      entry.setContents(contents);
    }

    e = eEntry.getChild("rights", getAtomNamespace());
    if (e != null) {
      entry.setRights(e.getText());
    }

    final List<Element> cList = eEntry.getChildren("category", getAtomNamespace());
    entry.setCategories(parseCategories(baseURI, cList));

    // TODO: SHOULD handle Atom entry source element
    e = eEntry.getChild("source", getAtomNamespace());
    if (e != null) {
      entry.setSource(parseFeedMetadata(baseURI, e, locale));
    }

    entry.setModules(parseItemModules(eEntry, locale));

    final List<Element> foreignMarkup = extractForeignMarkup(eEntry, entry, getAtomNamespace());
    if (foreignMarkup.size() > 0) {
      entry.setForeignMarkup(foreignMarkup);
    }
    return entry;
  }