package caida.otter; import java.awt.*; import java.io.FilenameFilter; import java.io.File; /***************************************************************************** * File: NameFilter.java Name: NameFilter * Goal: To create a filter that accepts only files that end with .odf. * * Written: Bradley Huffaker (01/13/98) * For: Cooperative Association for Internet Data Analysis ****************************************************************************** ****************************************************************************** * By accessing this software, NAMEFILTER, you are duly informed of * and agree to be bound by the conditions described below in * this notice: * * This software product, NAMEFILTER, is developed by Bradley Huffaker, and * copyrighted(C) 1998 by the University of California, San Diego (UCSD), * with all rights reserved. UCSD administers the NSF grant to CAIDA, * number NCR-9711092, under which this code was developed. * * NAMEFILTER is a free software. You can redistribute it and/or modify it * under the terms of the GNU Public License v.2 as * published by UCSD and is incorporated by reference herein. NAMEFILTER is * distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS, OF MERCHANTABILITY * OR FITNESS FOR A PARTICULAR PURPOSE or that the use of it will not * infringe on any third party's intellectual property rights. * * You should have received a copy of the CAIDA General Public * License v.1 along with the NAMEFILTER program. If for any reason you * have not received a copy, please write to * * University of California, San Diego * SDSC/CAIDA * 9500 Gilman Dr., MS-0505 * La Jolla, CA 92093 - 0505 USA * * Or contact INFO@CAIDA.ORG *****************************************************************************/ public class NameFilter implements FilenameFilter { public boolean accept(File dir, String name) { char[] array = name.toCharArray(); int index=array.length-1; if (index < 0 || array[index--] != 'l') return false; if (index < 0 || array[index--] != 'v') return false; if (index < 0 || array[index--] != 'f') return false; if (index < 0 || array[index--] != '.') return false; return true; } }