Coverage details for net.sourceforge.demetrix.util.SimpleFileFilter

LineHitsSource
1 /*******************************************************************************
2  * Demetrix process modelling system
3  *
4  * Copyright (c) 2003, 2004 Dimitri A. Pissarenko
5  *
6  * This file is part of Demetrix.
7  *
8  * Demetrix is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * Demetrix is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Demetrix; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *
22  * For further information you may
23  *
24  * - send an e-mail in Russian, German or English to dimitri.pissarenko@gmx.net
25  * - look at http://sourceforge.net/projects/demetrix/
26  * - look at http://demetrix.sourceforge.net/
27  * - look at http://members.inode.at/d.pissarenko/
28  *
29  *****************************************************************************/
30 package net.sourceforge.demetrix.util;
31 import java.io.File;
32 import javax.swing.filechooser.FileFilter;
33 public class SimpleFileFilter extends FileFilter {
347    private boolean acceptDirectoriesOnly = false;
357    private boolean acceptFilesOnly = false;
367    private String description = "";
377    private String extension = "";
38     public SimpleFileFilter() {
393        super();
403    }
41     public SimpleFileFilter(String desc, String ext) {
424        super();
434        this.description = desc;
444        this.extension = ext;
454    }
46     public boolean accept(File file) {
47160        boolean extensionCorrect = false;
48160        if (file
49             .getAbsolutePath()
50             .toUpperCase()
51             .endsWith(extension.toUpperCase())) {
522            extensionCorrect = true;
53         }
54160        if (!acceptDirectoriesOnly && !acceptFilesOnly && extensionCorrect) {
550            return true;
56160        } else if (acceptFilesOnly && file.isFile() && extensionCorrect)
57         {
581            return true;
59         }
60159        else if (acceptDirectoriesOnly && file.isDirectory())
61         {
621            return true;
63         }
64         else
65         {
66158            return false;
67         }
68         
69     }
70     public void setAcceptDirectoriesOnly(boolean ado) {
7112        this.acceptDirectoriesOnly = ado;
7212    }
73     public String getDescription() {
7457        return this.description;
75     }
76     public String getExtension() {
7750        return extension;
78     }
79     public boolean isAcceptDirectoriesOnly() {
804        return this.acceptDirectoriesOnly;
81     }
82     public void setDescription(String description) {
835        this.description = description;
845    }
85     public void setExtension(String ext) {
866        this.extension = ext;
876    }
88     /* (non-Javadoc)
89      * @see java.lang.Object#equals(java.lang.Object)
90      */
91     public boolean equals(Object otherObject) {
9230        SimpleFileFilter otherFilter = null;
9330        if (otherObject == null) {
941            return false;
95         }
9629        if (otherObject instanceof SimpleFileFilter) {
9725            otherFilter = (SimpleFileFilter) otherObject;
9825            if (ObjectComparator
99                 .areEqual(this.getDescription(), otherFilter.getDescription())
100                 && ObjectComparator.areEqual(
101                     this.getExtension(),
102                     otherFilter.getExtension())
103                 && (this.acceptDirectoriesOnly
104                     == otherFilter.acceptDirectoriesOnly)) {
10519                return true;
106             } else {
1076                return false;
108             }
109         } else {
1104            return false;
111         }
112     }
113     /**
114      * @return
115      */
116     public boolean isAcceptFilesOnly() {
1172        return acceptFilesOnly;
118     }
119     /**
120      * @param b
121      */
122     public void setAcceptFilesOnly(boolean b) {
1237        acceptFilesOnly = b;
1247    }
125 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.