Coverage report

  %line %branch
nl.toolforge.karma.core.manifest.ManifestStructure
92% 
100% 

 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.module.ModuleDigester;
 22  
 
 23  
 import java.util.ArrayList;
 24  
 import java.util.Hashtable;
 25  
 import java.util.List;
 26  
 import java.util.Map;
 27  
 import java.util.regex.PatternSyntaxException;
 28  
 
 29  
 /**
 30  
  * Mapping of a manifest file and its included manifest files (any level deep possible). Note that the structure that
 31  
  * is build is merely the template for the real <code>Manifest</code>.
 32  
  *
 33  
  * @author D.A. Smedes
 34  
  * @version $Id: ManifestStructure.java,v 1.6 2004/11/10 23:53:09 asmedes Exp $
 35  
  */
 36  361
 public final class ManifestStructure {
 37  361
 
 38  494
   private String name = null;
 39  133
   private String version = null;
 40  494
   private String type = null;
 41  
 
 42  494
   private String description = null;
 43  361
 
 44  133
   private Map childs = null;
 45  494
   private List modules = null;
 46  361
 
 47  494
   public ManifestStructure() {
 48  494
     childs = new Hashtable();
 49  133
     modules = new ArrayList();
 50  133
   }
 51  228
 
 52  
   public Map getChilds() {
 53  84
     return childs;
 54  
   }
 55  114
 
 56  
   public ManifestStructure getChild(String childName) {
 57  42
     return (ManifestStructure) childs.get(childName);
 58  
   }
 59  152
 
 60  19
   public void addChild(ManifestStructure structure) throws ManifestException {
 61  56
     if (childs.containsKey(structure.getName())) {
 62  140
       throw new ManifestException(ManifestException.MANIFEST_NAME_RECURSION, class="keyword">new Object[] {structure.getName()});
 63  133
     }
 64  49
     childs.put(structure.getName(), structure);
 65  49
   }
 66  57
 
 67  
   public List getModules() {
 68  21
     return modules;
 69  
   }
 70  
 
 71  342
   public void addModule(ModuleDigester digester) throws ManifestException {
 72  19
 
 73  126
     if (modules.contains(digester)) {
 74  330
       throw new ManifestException(ManifestException.DUPLICATE_MODULE, class="keyword">new Object[] {digester.getName()});
 75  323
     }
 76  119
     modules.add(digester);
 77  119
   }
 78  475
 
 79  
   public String getName() {
 80  182
     return name;
 81  
   }
 82  
 
 83  361
   public void setName(String name)  {
 84  
 
 85  119
     if (name.trim().startsWith(".")) {
 86  361
       throw new IllegalArgumentException("A manifest name cannot start with a `.`.");
 87  361
     }
 88  119
     this.name = name;
 89  119
   }
 90  
 
 91  
   public String getVersion() {
 92  0
     return version;
 93  
   }
 94  
 
 95  209
   public void setVersion(String version) {
 96  
 
 97  77
     if (!version.matches("\\d{1}-\\d{1}")) {
 98  209
       throw new PatternSyntaxException("A manifests' version attribute should look like '0-0'.", "\\d{1}-\\d{1}", -1);
 99  209
     }
 100  77
     this.version = version;
 101  77
   }
 102  38
 
 103  
   public String getType() {
 104  14
     return type;
 105  
   }
 106  209
 
 107  209
   public void setType(String type) {
 108  77
     this.type = type;
 109  77
   }
 110  
 
 111  
   public String getDescription() {
 112  0
     return description;
 113  
   }
 114  209
 
 115  209
   public void setDescription(String description) {
 116  77
     this.description = description;
 117  77
   }
 118  
 
 119  114
   public void update(ManifestStructure child) {
 120  114
 
 121  156
     this.name = child.name;
 122  156
     this.type = child.type;
 123  156
     this.version = child.version;
 124  156
     this.description = child.description;
 125  156
     this.childs = child.childs;
 126  42
     this.modules = child.modules;
 127  42
   }
 128  
 }

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