001 /*
002 * Cobertura - http://cobertura.sourceforge.net/
003 *
004 * Copyright (C) 2005 Grzegorz Lukasik
005 * Copyright (C) 2006 John Lewis
006 * Copyright (C) 2006 Mark Doliner
007 *
008 * Note: This file is dual licensed under the GPL and the Apache
009 * Source License (so that it can be used from both the main
010 * Cobertura classes and the ant tasks).
011 *
012 * Cobertura is free software; you can redistribute it and/or modify
013 * it under the terms of the GNU General Public License as published
014 * by the Free Software Foundation; either version 2 of the License,
015 * or (at your option) any later version.
016 *
017 * Cobertura is distributed in the hope that it will be useful, but
018 * WITHOUT ANY WARRANTY; without even the implied warranty of
019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
020 * General Public License for more details.
021 *
022 * You should have received a copy of the GNU General Public License
023 * along with Cobertura; if not, write to the Free Software
024 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
025 * USA
026 */
027
028 package net.sourceforge.cobertura.util;
029
030 /**
031 * Utility methods for working with archives.
032 *
033 * @author John Lewis
034 */
035 public abstract class ArchiveUtil
036 {
037
038 /**
039 * Return true if the given name ends with .jar, .zip,
040 * .war, .ear, or .sar (case insensitive).
041 *
042 * @param name The file name.
043 * @return true if the name is an archive.
044 */
045 public static boolean isArchive(String name)
046 {
047 name = name.toLowerCase();
048 return name.endsWith(".jar") || name.endsWith(".zip") || name.endsWith(".war")
049 || name.endsWith(".ear") || name.endsWith(".sar");
050 }
051
052 /**
053 * Check to see if the given file name is a signature file
054 * (meta-inf/*.rsa or meta-inf/*.sf).
055 *
056 * @param name The file name. Commonly a ZipEntry name.
057 * @return true if the name is a signature file.
058 */
059 public static boolean isSignatureFile(String name)
060 {
061 name = name.toLowerCase();
062 return (name.startsWith("meta-inf/") && (name.endsWith(".rsa") || name.endsWith(".sf")));
063 }
064
065 }