Source Code Cross Referenced for ExtensionFileFilter.java in  » Testing » jacareto » jacareto » toolkit » swing » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » jacareto » jacareto.toolkit.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Jacareto Copyright (c) 2002-2005
003:         * Applied Computer Science Research Group, Darmstadt University of
004:         * Technology, Institute of Mathematics & Computer Science,
005:         * Ludwigsburg University of Education, and Computer Based
006:         * Learning Research Group, Aachen University. All rights reserved.
007:         *
008:         * Jacareto is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public
010:         * License as published by the Free Software Foundation; either
011:         * version 2 of the License, or (at your option) any later version.
012:         *
013:         * Jacareto is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         * General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public
019:         * License along with Jacareto; if not, write to the Free
020:         * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021:         *
022:         */
023:
024:        package jacareto.toolkit.swing;
025:
026:        import jacareto.toolkit.io.FileUtilities;
027:
028:        import java.io.File;
029:
030:        import javax.swing.filechooser.FileFilter;
031:
032:        /**
033:         * A FileFilter which filters files regarding to their file extension.
034:         *
035:         * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
036:         * @version 0.9
037:         */
038:        public class ExtensionFileFilter extends FileFilter {
039:            /** The description of this FileFilter. */
040:            private String description;
041:
042:            /** The file extension. */
043:            private String extension;
044:
045:            /**
046:             * Creates an extension file filter with the default description. The default description is
047:             * &quot;.<i>Extension</i>&quot;.
048:             *
049:             * @param extension the file extension (<i>xml</i>, for example)
050:             */
051:            public ExtensionFileFilter(String extension) {
052:                this (extension, "*." + extension.toUpperCase());
053:            }
054:
055:            /**
056:             * Creates an extension file filter with the specified description.
057:             *
058:             * @param extension the file extension (<i>xml</i>, for example)
059:             * @param description The description for this filter
060:             */
061:            public ExtensionFileFilter(String extension, String description) {
062:                super ();
063:                setExtension(extension);
064:                setDescription(description);
065:            }
066:
067:            /**
068:             * Returns the description of this filter.
069:             *
070:             * @return The description
071:             *
072:             * @see #setDescription(String)
073:             */
074:            public String getDescription() {
075:                return description;
076:            }
077:
078:            /**
079:             * Sets the description of this filter. The default is &quot;.CSV&quot;
080:             *
081:             * @param description The new description
082:             *
083:             * @see #getDescription()
084:             */
085:            public void setDescription(String description) {
086:                this .description = description;
087:            }
088:
089:            /**
090:             * Sets the file extension of this filter.
091:             *
092:             * @param extension DOCUMENT ME!
093:             */
094:            public void setExtension(String extension) {
095:                this .extension = extension.toLowerCase();
096:            }
097:
098:            /**
099:             * Returns the file extension of this filter.
100:             *
101:             * @return DOCUMENT ME!
102:             */
103:            public String getExtension() {
104:                return extension;
105:            }
106:
107:            /**
108:             * Whether the given File is a XML file. Directories are accepted, too.
109:             *
110:             * @param file The file to be tested
111:             *
112:             * @return Returns true when the given File is accepted
113:             */
114:            public boolean accept(File file) {
115:                try {
116:                    if (file.isDirectory()) {
117:                        return true;
118:                    } else {
119:                        String extension = FileUtilities.getExtension(file);
120:
121:                        return extension.equals(this .extension);
122:                    }
123:                } catch (Exception e) {
124:                    // just for mysterious InterruptedExceptions
125:                    return false;
126:                }
127:            }
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.