1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package org.openoffice.idesupport.filter;
25 
26 public class BinaryOnlyFilter implements FileFilter {
27     private static final String[] EXTENSIONS = {".class", ".jar", ".bsh"};
28     private static final String DESCRIPTION = "Executable Files Only";
29     private static final BinaryOnlyFilter filter = new BinaryOnlyFilter();
30 
BinaryOnlyFilter()31     private BinaryOnlyFilter() {
32     }
33 
getInstance()34     public static BinaryOnlyFilter getInstance() {
35         return filter;
36     }
validate(String name)37     public boolean validate(String name) {
38         for (int i = 0; i < EXTENSIONS.length; i++)
39             if (name.endsWith(EXTENSIONS[i]))
40                 return true;
41         return false;
42     }
43 
toString()44     public String toString() {
45         /* StringBuffer buf = new StringBuffer(DESCRIPTION + ": ");
46 
47         for (int i = 0; i < EXTENSIONS.length - 1; i++)
48             buf.append("<" + EXTENSIONS[i] + "> ");
49         buf.append("<" + EXTENSIONS[EXTENSIONS.length - 1] + ">");
50 
51         return buf.toString(); */
52         return DESCRIPTION;
53     }
54 }
55