Coverage Report - org.jtheque.films.services.impl.utils.web.WebGetterFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
WebGetterFactory
0 %
0/9
0 %
0/4
2
 
 1  
 package org.jtheque.films.services.impl.utils.web;
 2  
 
 3  
 /*
 4  
  * This file is part of JTheque.
 5  
  *
 6  
  * JTheque is free software: you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation, either version 3 of the License.
 9  
  *
 10  
  * JTheque is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  
  * GNU General Public License for more details.
 14  
  *
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 
 19  
 import org.jtheque.films.utils.Constants.Site;
 20  
 
 21  
 /**
 22  
  * Factory of <code>WebGetter</code>.
 23  
  *
 24  
  * @author Baptiste Wicht
 25  
  */
 26  
 final class WebGetterFactory {
 27  
     private final WebGetter[] getters;
 28  
 
 29  
     /**
 30  
      * Construct a new <code>WebGetterFactory</code> and initialize all the getters.
 31  
      */
 32  
     WebGetterFactory() {
 33  0
         super();
 34  
 
 35  0
         getters = new WebGetter[]{
 36  
                 new GenericWebGetter("allocine.xml", Site.ALLOCINE),
 37  
                 new GenericWebGetter("cinemovies.xml", Site.CINEMOVIES),
 38  
                 new GenericWebGetter("dvdfr.xml", Site.DVDFR),
 39  
                 new GenericWebGetter("moviescovers.xml", Site.MOVIESCOVERS)
 40  
         };
 41  0
     }
 42  
 
 43  
     /**
 44  
      * Return the getter for the specified getter.
 45  
      *
 46  
      * @param site The site on which we want search.
 47  
      * @return The good web getter if we found it or <code>null</code> if we doesn't found.
 48  
      */
 49  
     public WebGetter getWebGetter(Site site) {
 50  0
         WebGetter webGetter = null;
 51  
 
 52  0
         for (WebGetter getter : getters) {
 53  0
             if (getter.canGetOn(site)) {
 54  0
                 webGetter = getter;
 55  
 
 56  0
                 break;
 57  
             }
 58  
         }
 59  
 
 60  0
         return webGetter;
 61  
     }
 62  
 }