| 1 | /* |
|---|
| 2 | * This program is free software; you can redistribute it and/or modify |
|---|
| 3 | * it under the terms of the GNU General Public License as published by |
|---|
| 4 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 5 | * (at your option) any later version. |
|---|
| 6 | * |
|---|
| 7 | * This program is distributed in the hope that it will be useful, |
|---|
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 10 | * GNU General Public License for more details. |
|---|
| 11 | * |
|---|
| 12 | * You should have received a copy of the GNU General Public License |
|---|
| 13 | * along with this program; if not, write to the Free Software |
|---|
| 14 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 15 | */ |
|---|
| 16 | |
|---|
| 17 | /* |
|---|
| 18 | * Copyright (C) 2004 |
|---|
| 19 | * & Matthias Schubert (schubert@dbs.ifi.lmu.de) |
|---|
| 20 | * & Zhanna Melnikova-Albrecht (melnikov@cip.ifi.lmu.de) |
|---|
| 21 | * & Rainer Holzmann (holzmann@cip.ifi.lmu.de) |
|---|
| 22 | */ |
|---|
| 23 | |
|---|
| 24 | package weka.clusterers.forOPTICSAndDBScan.OPTICS_GUI; |
|---|
| 25 | |
|---|
| 26 | import weka.core.RevisionHandler; |
|---|
| 27 | import weka.core.RevisionUtils; |
|---|
| 28 | |
|---|
| 29 | import java.io.File; |
|---|
| 30 | |
|---|
| 31 | import javax.swing.filechooser.FileFilter; |
|---|
| 32 | |
|---|
| 33 | /** |
|---|
| 34 | * <p> |
|---|
| 35 | * SERFileFilter.java <br/> |
|---|
| 36 | * Authors: Rainer Holzmann, Zhanna Melnikova-Albrecht <br/> |
|---|
| 37 | * Date: Sep 15, 2004 <br/> |
|---|
| 38 | * Time: 6:54:56 PM <br/> |
|---|
| 39 | * $ Revision 1.4 $ <br/> |
|---|
| 40 | * </p> |
|---|
| 41 | * |
|---|
| 42 | * @author Zhanna Melnikova-Albrecht (melnikov@cip.ifi.lmu.de) |
|---|
| 43 | * @author Rainer Holzmann (holzmann@cip.ifi.lmu.de) |
|---|
| 44 | * @version $Revision: 1.3 $ |
|---|
| 45 | */ |
|---|
| 46 | public class SERFileFilter |
|---|
| 47 | extends FileFilter |
|---|
| 48 | implements RevisionHandler { |
|---|
| 49 | |
|---|
| 50 | /** |
|---|
| 51 | * Holds the extension of the FileFilter |
|---|
| 52 | */ |
|---|
| 53 | private String extension; |
|---|
| 54 | |
|---|
| 55 | /** |
|---|
| 56 | * Holds the description for this File-Type |
|---|
| 57 | */ |
|---|
| 58 | private String description; |
|---|
| 59 | |
|---|
| 60 | // ***************************************************************************************************************** |
|---|
| 61 | // constructors |
|---|
| 62 | // ***************************************************************************************************************** |
|---|
| 63 | |
|---|
| 64 | public SERFileFilter(String extension, String description) { |
|---|
| 65 | this.extension = extension; |
|---|
| 66 | this.description = description; |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | // ***************************************************************************************************************** |
|---|
| 70 | // methods |
|---|
| 71 | // ***************************************************************************************************************** |
|---|
| 72 | |
|---|
| 73 | /** |
|---|
| 74 | * Whether the given file is accepted by this filter. |
|---|
| 75 | */ |
|---|
| 76 | public boolean accept(File f) { |
|---|
| 77 | if (f != null) { |
|---|
| 78 | if (f.isDirectory()) { |
|---|
| 79 | return true; |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | String filename = f.getName(); |
|---|
| 83 | int i = filename.lastIndexOf('.'); |
|---|
| 84 | if (i > 0 && i < filename.length() - 1) { |
|---|
| 85 | extension = filename.substring(i + 1).toLowerCase(); |
|---|
| 86 | } |
|---|
| 87 | if (extension.equals("ser")) return true; |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | return false; |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | /** |
|---|
| 94 | * The description of this filter. |
|---|
| 95 | * @see javax.swing.filechooser.FileView#getName |
|---|
| 96 | */ |
|---|
| 97 | public String getDescription() { |
|---|
| 98 | return description; |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | /** |
|---|
| 102 | * Returns the revision string. |
|---|
| 103 | * |
|---|
| 104 | * @return the revision |
|---|
| 105 | */ |
|---|
| 106 | public String getRevision() { |
|---|
| 107 | return RevisionUtils.extract("$Revision: 1.3 $"); |
|---|
| 108 | } |
|---|
| 109 | } |
|---|