Class ChannelPullHandler

java.lang.Object
ChannelPullHandler

public class ChannelPullHandler extends Object
This class will parse a rss or rdf document and build a Map consisting of - attributes of a channel - and a one attribute "items" which is a list with items, where each item consists of a Map with attributes.
NOTE: this class does not use namespaces and instead is based on heuristics
  • Field Details

    • items

      private List items
    • xmlPullParser

      private XmlPullParser xmlPullParser
    • channel

      private Map channel
    • channelIdentifiers

      private String[] channelIdentifiers
    • itemIdentifiers

      private String[] itemIdentifiers
    • channelSynonymes

      private String[][] channelSynonymes
      The channelSynonymes consists of an array of identifiers. The first element of the array is the name that you want filled. The others names are synonymes that might be filled. These are all synonymes for channel attributes, for instance, you need the title attribute. If this isnt found initially, this class will look for an rss:title attribute. If found, it will copy the value of rss:title to title. These values could be moved out into a properties kind of file, e.g. url=link,dc:indentifier,rss:link
    • itemSynonymes

      private String[][] itemSynonymes
      The channelSynonymes consists of an array of identifiers. The first element of the array is the name that you want filled. The others names are synonymes that might be filled. These are all synonymes for item attributes
  • Constructor Details

  • Method Details

    • parseFirst

      private List parseFirst(int type) throws IOException, XmlPullParserException
      This method will recursively parse the document, returning a List build of Key-Value pairs. A value can be a List again, indicating a nested element inside an element.
      Parameters:
      type -
      Returns:
      Throws:
      IOException
      XmlPullParserException
    • parseSecond

      private void parseSecond(List values)
      This method will loop over the found values and set the values for a channel, and set the values for each item. If other elements need to be supported, this is where you should check for these (e.g. images).
      Parameters:
      values -
    • workOnItem

      private void workOnItem(List list)
      This method will set the item attributes.
      Parameters:
      list -
    • workOnChannel

      private void workOnChannel(List list)
      This method will set the attributes for a channel.
      Parameters:
      list -
    • parse

      public Map parse(Reader in) throws XmlPullParserException, IOException
      This method will parse the input reader and return a Map. This map consists of : - the attributes of a channel - and a List with items, where each item is a Map again.
      Parameters:
      in -
      Returns:
      Throws:
      XmlPullParserException
      IOException
    • main

      public static void main(String[] args) throws XmlPullParserException, IOException
      Throws:
      XmlPullParserException
      IOException