1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 /* 19 * $Id$ 20 */ 21 package org.apache.qetest.xsl; 22 23 import java.io.File; 24 import java.util.Hashtable; 25 26 /** 27 * Simple file filter; returns *.xsl non-dir files that start with the directory name. 28 * Has crude support for an excludes list of filename bases. 29 * @author shane_curcuru@lotus.com 30 * @version $Id$ 31 */ 32 public class GoldFileRules extends ConformanceFileRules 33 { 34 35 /** Initialize for defaults (not using inclusion list) no-op. */ GoldFileRules()36 public GoldFileRules(){} 37 38 /** 39 * Initialize with a case-sensitive Hash of file names to exclude. 40 * 41 * NEEDSDOC @param excludesHash 42 */ GoldFileRules(Hashtable excludesHash)43 public GoldFileRules(Hashtable excludesHash) 44 { 45 super(excludesHash); 46 } 47 48 /** 49 * Initialize with a case-insensitive semicolon-delimited String of file names to exclude. 50 * 51 * NEEDSDOC @param excludesStr 52 */ GoldFileRules(String excludesStr)53 public GoldFileRules(String excludesStr) 54 { 55 super(excludesStr); 56 } 57 58 /** 59 * Tests if a specified file should be included in a file list. 60 * <p>Returns true only for *.xsl files whose names start with 61 * the name of the directory, case-insensitive (uses .toLowerCase()). 62 * <b>Except:</b> if any filenames contain an item in excludeFiles.</p> 63 * @param dir the directory in which the file was found. 64 * @param name the name of the file. 65 * @return <code>true</code> if the name should be included in the file list; <code>false</code> otherwise. 66 * @since JDK1.0 67 */ accept(File dir, String name)68 public boolean accept(File dir, String name) 69 { 70 71 // Shortcuts for bogus filenames and dirs 72 if (name == null || dir == null) 73 return false; 74 75 // Exclude any files that match an exclude rule 76 if ((excludeFiles != null) && (excludeFiles.containsKey(name))) 77 return false; 78 79 File file = new File(dir, name); 80 81 return (!file.isDirectory()) && name.toLowerCase().endsWith(".out") 82 && name.toLowerCase().startsWith(dir.getName().toLowerCase()); 83 } 84 } 85