Coverage Report - no.sesat.search.view.output.syndication.modules.SearchResultModuleParser
 
Classes in this File Line Coverage Branch Coverage Complexity
SearchResultModuleParser
0%
0/18
0%
0/8
2
 
 1  
 /* Copyright (2007) Schibsted Søk AS
 2  
  * This file is part of SESAT.
 3  
  *
 4  
  *   SESAT is free software: you can redistribute it and/or modify
 5  
  *   it under the terms of the GNU Affero General Public License as published by
 6  
  *   the Free Software Foundation, either version 3 of the License, or
 7  
  *   (at your option) any later version.
 8  
  *
 9  
  *   SESAT is distributed in the hope that it will be useful,
 10  
  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  
  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12  
  *   GNU Affero General Public License for more details.
 13  
  *
 14  
  *   You should have received a copy of the GNU Affero General Public License
 15  
  *   along with SESAT.  If not, see <http://www.gnu.org/licenses/>.
 16  
  */
 17  
 /*
 18  
  * SearchResultModuleParser.java
 19  
  *
 20  
  */
 21  
 
 22  
 package no.sesat.search.view.output.syndication.modules;
 23  
 
 24  
 import com.sun.syndication.feed.module.Module;
 25  
 import com.sun.syndication.io.ModuleParser;
 26  
 import org.jdom.Element;
 27  
 
 28  
 /**
 29  
  * A parser for the rome module defining the sesam syndication feed format.
 30  
  */
 31  
 public class SearchResultModuleParser implements ModuleParser {
 32  
 
 33  
     /**
 34  
      * Creates a new instance of this class.
 35  
      */
 36  0
     public SearchResultModuleParser() {
 37  0
     }
 38  
 
 39  
     /**
 40  
      * {@inheritDoc}
 41  
      */
 42  
     public String getNamespaceUri() {
 43  0
         return SearchResultModule.URI;
 44  
     }
 45  
 
 46  
     /**
 47  
      * {@inheritDoc}
 48  
      */
 49  
     public Module parse(final Element root) {
 50  
 
 51  0
         final SearchResultModule m = new SearchResultModuleImpl();
 52  
 
 53  0
         boolean touched = false;
 54  
 
 55  0
         final Element e = root.getChild(SearchResultModule.ELEM_NUMBER_OF_HITS, SearchResultModuleImpl.NS);
 56  
 
 57  0
         if (e != null) {
 58  0
             touched = true;
 59  0
             m.setNumberOfHits(e.getText());
 60  
         }
 61  
 
 62  0
         final Element ageElem = root.getChild(SearchResultModule.ELEM_ARTICLE_AGE, SearchResultModuleImpl.NS);
 63  
 
 64  0
         if (ageElem != null) {
 65  0
             touched = true;
 66  0
             m.setArticleAge(e.getText());
 67  
         }
 68  
 
 69  0
         final Element sourceElem = root.getChild(SearchResultModule.ELEM_NEWS_SOURCE, SearchResultModuleImpl.NS);
 70  
 
 71  0
         if (sourceElem != null) {
 72  0
             touched = true;
 73  0
             m.setNewsSource(e.getText());
 74  
         }
 75  
 
 76  0
         return touched == true ? m : null;
 77  
     }
 78  
 }