001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: * Paul Mahar
021: *
022: */
023: package org.enhydra.tool.archive;
024:
025: //
026: import org.enhydra.tool.common.PathHandle;
027:
028: //
029: import java.io.File;
030: import java.io.FileFilter;
031:
032: //
033: public class ClassFilter implements FileFilter {
034: // NFS
035: protected static final String TEMP_NFS = ".nfs"; // nores
036:
037: //
038: private final String MANIFEST = "MANIFEST.MF"; // nores
039:
040: // JBuilder/JDevelper
041: private final String GEN_SOURCE = "Generated Source"; // nores
042: private final String DEP_CACHE = "dependency cache"; // nores
043:
044: // Forte
045: private final String TYPE_JAVA = ".java"; // nores
046: private final String TYPE_JSP = ".jsp"; // nores
047:
048: //
049: private PathHandle root = null;
050:
051: //
052: public ClassFilter() {
053: }
054:
055: ;
056:
057: public ClassFilter(String r) {
058: setRoot(r);
059: }
060:
061: public void setRoot(String r) {
062: root = PathHandle.createPathHandle(r);
063: }
064:
065: public String getRoot() {
066: return root.getPath();
067: }
068:
069: public boolean accept(File file) {
070: boolean include = false;
071: PathHandle filePath = null;
072:
073: filePath = PathHandle.createPathHandle(file);
074: if (root.parentOf(filePath)) {
075: if (filePath.isDirectory()) {
076: include = true;
077: } else {
078: String relative = null;
079:
080: relative = file.getAbsolutePath().substring(
081: root.getPath().length() + 1);
082: if (relative.startsWith(GEN_SOURCE)) {
083:
084: // exclude JB/JDev Generated Source
085: } else if (relative.startsWith(DEP_CACHE)) {
086:
087: // exclude JBuilder dependancy cache
088: } else if (relative.toUpperCase().endsWith(MANIFEST)) {
089:
090: // exclude Manifest
091: } else if (relative.toLowerCase().endsWith(TYPE_JAVA)) {
092:
093: // exclude Java source
094: } else if (relative.toLowerCase().endsWith(TYPE_JSP)) {
095:
096: // exclude JSP
097: } else if (file.getName().toLowerCase().startsWith(
098: ClassFilter.TEMP_NFS)) {
099:
100: // exclude nfs temp files
101: } else {
102: include = true;
103: }
104: }
105: }
106: return include;
107: }
108:
109: }
|