Coverage Report - net.sourceforge.cobertura.util.ArchiveUtil
 
Classes in this File Line Coverage Branch Coverage Complexity
ArchiveUtil
80%
4/5
69%
11/16
1
 
 1  
 /*
 2  
  * Cobertura - http://cobertura.sourceforge.net/
 3  
  *
 4  
  * Copyright (C) 2005 Grzegorz Lukasik
 5  
  * Copyright (C) 2006 John Lewis
 6  
  * Copyright (C) 2006 Mark Doliner
 7  
  *
 8  
  * Note: This file is dual licensed under the GPL and the Apache
 9  
  * Source License (so that it can be used from both the main
 10  
  * Cobertura classes and the ant tasks).
 11  
  *
 12  
  * Cobertura is free software; you can redistribute it and/or modify
 13  
  * it under the terms of the GNU General Public License as published
 14  
  * by the Free Software Foundation; either version 2 of the License,
 15  
  * or (at your option) any later version.
 16  
  *
 17  
  * Cobertura is distributed in the hope that it will be useful, but
 18  
  * WITHOUT ANY WARRANTY; without even the implied warranty of
 19  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 20  
  * General Public License for more details.
 21  
  *
 22  
  * You should have received a copy of the GNU General Public License
 23  
  * along with Cobertura; if not, write to the Free Software
 24  
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 25  
  * USA
 26  
  */
 27  
 
 28  
 package net.sourceforge.cobertura.util;
 29  
 
 30  
 /**
 31  
  * Utility methods for working with archives.
 32  
  * 
 33  
  * @author John Lewis
 34  
  */
 35  0
 public abstract class ArchiveUtil
 36  
 {
 37  
 
 38  
         /**
 39  
          * Return true if the given name ends with .jar, .zip,
 40  
          * .war, .ear, or .sar (case insensitive).
 41  
          * 
 42  
          * @param name The file name.
 43  
          * @return true if the name is an archive.
 44  
          */
 45  
         public static boolean isArchive(String name)
 46  
         {
 47  34
                 name = name.toLowerCase();
 48  34
                 return name.endsWith(".jar") || name.endsWith(".zip") || name.endsWith(".war")
 49  
                                 || name.endsWith(".ear") || name.endsWith(".sar");
 50  
         }
 51  
 
 52  
         /**
 53  
          * Check to see if the given file name is a signature file
 54  
          * (meta-inf/*.rsa or meta-inf/*.sf).
 55  
          * 
 56  
          * @param name The file name.  Commonly a ZipEntry name.
 57  
          * @return true if the name is a signature file.
 58  
          */
 59  
         public static boolean isSignatureFile(String name)
 60  
         {
 61  20
                 name = name.toLowerCase();
 62  20
                 return (name.startsWith("meta-inf/") && (name.endsWith(".rsa") || name.endsWith(".sf")));
 63  
         }
 64  
 
 65  
 }