Class FeedParser

java.lang.Object
com.attribyte.parser.entry.FeedParser
All Implemented Interfaces:
Parser
Direct Known Subclasses:
AtomParser, RSSParser

public abstract class FeedParser extends Object implements Parser
  • Constructor Details

    • FeedParser

      public FeedParser()
  • Method Details

    • parse

      public ParseResult parse(String content, String sourceLink, ContentCleaner contentCleaner)
      Description copied from interface: Parser
      Parse content.
      Specified by:
      parse in interface Parser
      Parameters:
      content - The content as a string.
      sourceLink - The link for the content, if available.
      contentCleaner - The content cleaner.
      Returns:
      The result.
    • parseSource

      protected abstract void parseSource(org.jsoup.nodes.Document doc, Resource.Builder resource)
      Parse the feed source properties.
      Parameters:
      doc - The parsed document.
      resource - The resource to which source properties are added.
    • parseEntry

      protected abstract Entry.Builder parseEntry(org.jsoup.nodes.Element elem, ContentCleaner contentCleaner, String baseUri)
      Parse an entry.
      Parameters:
      elem - The entry element.
      contentCleaner - The content cleaner.
      baseUri - The base URI for relative references.
      Returns:
      The parsed entry (builder).
    • parseEntries

      protected abstract void parseEntries(org.jsoup.nodes.Document doc, ContentCleaner contentCleaner, Resource.Builder resource)
      Parse all entries and add to the resource.
      Parameters:
      doc - The parent document.
      contentCleaner - The content cleaner.
      resource - The resource.
    • image

      protected static Image.Builder image(String url, String protocol)
      Create an image builder for a URL.
      Parameters:
      url - The URL.
      protocol - For protocol-less links.
      Returns:
      The builder or null.
    • addImage

      protected static Entry.Builder addImage(Entry.Builder entry, Image.Builder builder)
      Adds an image to an entry and if entry has no primary image, sets primary image to this image.
      Parameters:
      entry - The entry (builder).
      builder - The image builder.
      Returns:
      The input entry builder.
    • addImage

      protected static Entry.Builder addImage(Entry.Builder entry, String url, String protocol)
      Adds an image to an entry if a valid URL and sets the primary image, if unset.
      Parameters:
      entry - The entry.
      url - The url.
      protocol - The protocol to use for protocol-less links.
      Returns:
      The input entry builder.