| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||||
| SMSFilter |
|
| 3.0;3 |
| 1 | /* |
|
| 2 | * SMSFilter.java |
|
| 3 | * |
|
| 4 | * This file is part of JavaGear. |
|
| 5 | * |
|
| 6 | * JavaGear is free software; you can redistribute it and/or modify |
|
| 7 | * it under the terms of the GNU General Public License as published by |
|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
|
| 9 | * (at your option) any later version. |
|
| 10 | * |
|
| 11 | * JavaGear is distributed in the hope that it will be useful, |
|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 14 | * GNU General Public License for more details. |
|
| 15 | * |
|
| 16 | * You should have received a copy of the GNU General Public License |
|
| 17 | * along with JavaGear; if not, write to the Free Software |
|
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
| 19 | */ |
|
| 20 | ||
| 21 | package uk.co.javagear; |
|
| 22 | ||
| 23 | import java.io.File; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * JavaGear File Filters (Code from "Core Java Volume #1"). |
|
| 27 | * |
|
| 28 | * @author Copyright (C) 2002 Chris White |
|
| 29 | * @version 17th March 2002 |
|
| 30 | * @see "JavaGear Final Project Report" |
|
| 31 | */ |
|
| 32 | 0 | public class SMSFilter extends RomFilter { |
| 33 | ||
| 34 | /** |
|
| 35 | * Returns <code>true</code> if the file given is accepted and <code>false</code> otherwise. |
|
| 36 | * This filter accepts all directories and files with extension <code>sms</code>. |
|
| 37 | * |
|
| 38 | * @param f the instance of <code>File</code> to accept or reject. |
|
| 39 | * @return <code>true</code> if the file given is accepted and <code>false</code> otherwise. |
|
| 40 | */ |
|
| 41 | public boolean accept(File f) { |
|
| 42 | // Allow directories |
|
| 43 | 0 | if (f.isDirectory()) { |
| 44 | 0 | return true; |
| 45 | } |
|
| 46 | ||
| 47 | 0 | String extension = getExtension(f); |
| 48 | ||
| 49 | 0 | if (extension.equals(Setup.System.SMS.getRomFileExtension())) { |
| 50 | 0 | return true; |
| 51 | } |
|
| 52 | ||
| 53 | // If not a directory or sms file... |
|
| 54 | 0 | return false; |
| 55 | } |
|
| 56 | ||
| 57 | /** |
|
| 58 | * Returns a description of this filter, <code>"Sega Master System ROMs (*.sms)"</code>. |
|
| 59 | * |
|
| 60 | * @return a description of this filter, <code>"Sega Master System ROMs (*.sms)"</code>. |
|
| 61 | */ |
|
| 62 | public String getDescription() { |
|
| 63 | 0 | return Setup.System.SMS.getName() + " ROMs (*." |
| 64 | + Setup.System.SMS.getRomFileExtension().toUpperCase() + ")"; |
|
| 65 | } |
|
| 66 | ||
| 67 | } |