Guest User

Untitled

a guest
May 26th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.14 KB | None | 0 0
  1. /*
  2.      * Elements
  3.      */
  4.     @Override
  5.     public void startElement(String uri, String localName, String qName,
  6.             Attributes attributes) throws SAXException {
  7.         super.startElement(uri, localName, qName, attributes);
  8.        
  9.         _dataField = new StringBuilder();
  10.        
  11.         if(qName.equalsIgnoreCase("item"))
  12.         {
  13.             Log.v(TAG, "Creating new item");
  14.             _currRSSItem = new RSSItem();
  15.         }
  16.         else if(qName.equalsIgnoreCase("title"))
  17.         {
  18.             Log.v(TAG, "reseting title");
  19.             _currTitle = "";
  20.         }
  21.         else if(qName.equalsIgnoreCase("description"))
  22.         {
  23.             Log.v(TAG, "reseting title");
  24.             _currDescription = "";
  25.         }
  26.         else if(qName.equalsIgnoreCase("pubdate"))
  27.         {
  28.             Log.v(TAG, "reseting pubdate");
  29.             _currPubdate = "";
  30.         }
  31.         else if(qName.equalsIgnoreCase("link"))
  32.         {
  33.             Log.v(TAG, "reseting link");
  34.             _currLink = "";
  35.         }
  36.     }
  37.    
  38.     @Override
  39.     public void characters(char[] ch, int start, int length)
  40.             throws SAXException {
  41.        
  42.         _dataField.append(ch, start, length);
  43.     }
  44.    
  45.     @Override
  46.     public void endElement(String uri, String localName, String qName)
  47.             throws SAXException {
  48.         super.endElement(uri, localName, qName);
  49.        
  50.         if(qName.equalsIgnoreCase("title"))
  51.         {
  52.             Log.v(TAG, "Setting title to " + _dataField.toString());
  53.             _currTitle = _dataField.toString();
  54.         }
  55.         else if(qName.equalsIgnoreCase("description"))
  56.         {
  57.             Log.v(TAG, "Setting desc to " + _dataField.toString());
  58.             _currDescription = _dataField.toString();;
  59.         }
  60.         else if(qName.equalsIgnoreCase("pubdate"))
  61.         {
  62.             Log.v(TAG, "Setting pubdate to " + _dataField.toString());
  63.             _currPubdate = _dataField.toString();
  64.         }
  65.         else if(qName.equalsIgnoreCase("link"))
  66.         {
  67.             Log.v(TAG, "Setting link to " + _dataField.toString());
  68.             _currLink = _dataField.toString();
  69.         }
  70.         else if(qName.equalsIgnoreCase("item"))
  71.         {
  72.             Log.v(TAG, "Item complete, creating and adding it to the itemlist");
  73.             _currRSSItem.setTitle(_currTitle);
  74.             _currRSSItem.setDescription(_currDescription);
  75.             _currRSSItem.setLink(_currLink);
  76.             _currRSSItem.setPubdate(_currPubdate);
  77.            
  78.             _RSSItemList.add(_currRSSItem);
  79.         }
  80.     }
  81.    
  82.     public ArrayList<RSSItem> getRSSItemList()
  83.     {
  84.         return _RSSItemList;
  85.     }
Add Comment
Please, Sign In to add comment