Class ChannelPullHandler


  • public class ChannelPullHandler
    extends java.lang.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
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void main​(java.lang.String[] args)  
      java.util.Map parse​(java.io.Reader in)
      This method will parse the input reader and return a Map.
      private java.util.List parseFirst​(int type)
      This method will recursively parse the document, returning a List build of Key-Value pairs.
      private void parseSecond​(java.util.List values)
      This method will loop over the found values and set the values for a channel, and set the values for each item.
      private void workOnChannel​(java.util.List list)
      This method will set the attributes for a channel.
      private void workOnItem​(java.util.List list)
      This method will set the item attributes.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • items

        private java.util.List items
      • channel

        private java.util.Map channel
      • channelIdentifiers

        private java.lang.String[] channelIdentifiers
      • itemIdentifiers

        private java.lang.String[] itemIdentifiers
      • channelSynonymes

        private java.lang.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 java.lang.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
    • Method Detail

      • parseFirst

        private java.util.List parseFirst​(int type)
                                   throws java.io.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:
        java.io.IOException
        XmlPullParserException
      • parseSecond

        private void parseSecond​(java.util.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​(java.util.List list)
        This method will set the item attributes.
        Parameters:
        list -
      • workOnChannel

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

        public java.util.Map parse​(java.io.Reader in)
                            throws XmlPullParserException,
                                   java.io.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
        java.io.IOException