Coverage report

  %line %branch
nl.toolforge.karma.core.manifest.ModuleFactory
68% 
95% 

 1  
 /*
 2  
 Karma core - Core of the Karma application
 3  
 Copyright (C) 2004  Toolforge <www.toolforge.nl>
 4  
 
 5  
 This library is free software; you can redistribute it and/or
 6  
 modify it under the terms of the GNU Lesser General Public
 7  
 License as published by the Free Software Foundation; either
 8  
 version 2.1 of the License, or (at your option) any later version.
 9  
 
 10  
 This library 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 GNU
 13  
 Lesser General Public License for more details.
 14  
 
 15  
 You should have received a copy of the GNU Lesser General Public
 16  
 License along with this library; if not, write to the Free Software
 17  
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18  
 */
 19  
 package nl.toolforge.karma.core.manifest;
 20  
 
 21  
 import nl.toolforge.karma.core.KarmaRuntimeException;
 22  
 import nl.toolforge.karma.core.Version;
 23  
 import nl.toolforge.karma.core.boot.WorkingContext;
 24  
 import nl.toolforge.karma.core.location.Location;
 25  
 import nl.toolforge.karma.core.location.LocationException;
 26  
 import nl.toolforge.karma.core.module.JavaEnterpriseApplicationModule;
 27  
 import nl.toolforge.karma.core.module.JavaWebApplicationModule;
 28  
 import nl.toolforge.karma.core.module.UntypedModule;
 29  
 
 30  
 /**
 31  
  * <p>Factory class to create modules based on a {@link ModuleDigester}.</p>
 32  
  *
 33  
  * @author D.A. Smedes
 34  
  * @version $Id: ModuleFactory.java,v 1.13 2004/11/02 23:57:06 asmedes Exp $
 35  
  */
 36  
 public final class ModuleFactory {
 37  
 
 38  57
   private WorkingContext workingContext = null;
 39  
 
 40  57
   public ModuleFactory(WorkingContext workingContext) {
 41  57
     this.workingContext = workingContext;
 42  57
   }
 43  
 
 44  
   public Module create(ModuleDigester digester, Module.Type moduleType) throws LocationException {
 45  
 
 46  95
     if (digester == null) {
 47  0
       throw new IllegalArgumentException("Descriptor cannot be null.");
 48  
     }
 49  95
     if (moduleType == null) {
 50  0
       throw new IllegalArgumentException("Module type cannot be null.");
 51  
     }
 52  
 
 53  95
     Location location = workingContext.getLocationLoader().get(digester.getLocation());
 54  
 
 55  95
     Version version = null;
 56  95
     if (digester.getVersion() != null) {
 57  76
       version = new Version(digester.getVersion());
 58  
     }
 59  
 
 60  95
     if (moduleType.equals(Module.JAVA_SOURCE_MODULE)) {
 61  0
       return new SourceModule(digester.getName(), location, version);
 62  95
     } else if (moduleType.equals(Module.JAVA_ENTERPRISE_APPLICATION)) {
 63  0
       return new JavaEnterpriseApplicationModule(digester.getName(), location, version);
 64  95
     } else if (moduleType.equals(Module.JAVA_WEB_APPLICATION)) {
 65  0
       return new JavaWebApplicationModule(digester.getName(), location, version);
 66  95
     } else if (moduleType.equals(Module.LIBRARY_MODULE)) {
 67  0
       return new LibModule(digester.getName(), location, version);
 68  95
     } else if (moduleType.equals(Module.OTHER_MODULE)) {
 69  0
       return new OtherModule(digester.getName(), location, version);
 70  95
     } else if (moduleType.equals(Module.UNKNOWN)) {
 71  95
       return new UntypedModule(digester.getName(), location, version);
 72  
     }
 73  
 
 74  0
     throw new KarmaRuntimeException("Type mismatch. Could not create module.");
 75  
   }
 76  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.