From 8a33b13e10dbf9ea3e620cd495a195db7a501ed3 Mon Sep 17 00:00:00 2001 From: ribeaudc <ribeaudc> Date: Mon, 26 May 2008 06:44:45 +0000 Subject: [PATCH] remove: - 'NamePrefixFileFilter' - use one of the Apache commons implementations. SVN: 6301 --- .../utilities/NamePrefixFileFilter.java | 51 --------------- .../utilities/NamePrefixFileFilterTest.java | 62 ------------------- 2 files changed, 113 deletions(-) delete mode 100644 common/source/java/ch/systemsx/cisd/common/utilities/NamePrefixFileFilter.java delete mode 100644 common/sourceTest/java/ch/systemsx/cisd/common/utilities/NamePrefixFileFilterTest.java diff --git a/common/source/java/ch/systemsx/cisd/common/utilities/NamePrefixFileFilter.java b/common/source/java/ch/systemsx/cisd/common/utilities/NamePrefixFileFilter.java deleted file mode 100644 index 6df806d2476..00000000000 --- a/common/source/java/ch/systemsx/cisd/common/utilities/NamePrefixFileFilter.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2007 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.common.utilities; - -import java.io.File; -import java.io.FileFilter; - -/** - * A {@link FileFilter} that checks whether the name part of the <var>pathname</var> starts (or - * does not start) with the <var>prefix</var> specified. - * - * @author Bernd Rinn - */ -public class NamePrefixFileFilter implements FileFilter -{ - - private final String prefix; - - private boolean shouldStartWithPrefix; - - public NamePrefixFileFilter(String prefix, boolean shouldStartWithPrefix) - { - assert prefix != null; - - this.prefix = prefix; - this.shouldStartWithPrefix = shouldStartWithPrefix; - } - - public boolean accept(File pathname) - { - assert pathname != null; - - final boolean startsWithPrefix = pathname.getName().startsWith(prefix); - return startsWithPrefix == shouldStartWithPrefix; - } - -} diff --git a/common/sourceTest/java/ch/systemsx/cisd/common/utilities/NamePrefixFileFilterTest.java b/common/sourceTest/java/ch/systemsx/cisd/common/utilities/NamePrefixFileFilterTest.java deleted file mode 100644 index 690c687c477..00000000000 --- a/common/sourceTest/java/ch/systemsx/cisd/common/utilities/NamePrefixFileFilterTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2007 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.common.utilities; - -import java.io.File; -import java.io.FileFilter; - -import org.testng.annotations.Test; - -/** - * Test cases for {@link NamePrefixFileFilter}. - * - * @author Bernd Rinn - */ -public class NamePrefixFileFilterTest -{ - - private static final String PREFIX = "PReFiX"; - - @Test - public void testNamePrefixShouldOccurAndFound() - { - final FileFilter filter = new NamePrefixFileFilter(PREFIX, true); - assert filter.accept(new File(PREFIX + "andSomePostFix.txt").getAbsoluteFile()); - } - - @Test - public void testNamePrefixShouldOccurButNotFound() - { - final FileFilter filter = new NamePrefixFileFilter(PREFIX, true); - assert filter.accept(new File("somefilewithouttheprefix.dat").getAbsoluteFile()) == false; - } - - @Test - public void testNamePrefixShouldNotOccurAndNotFound() - { - final FileFilter filter = new NamePrefixFileFilter(PREFIX, false); - assert filter.accept(new File("somefilewithouttheprefix.dat").getAbsoluteFile()); - } - - @Test - public void testNamePrefixShouldNotOccurButFound() - { - final FileFilter filter = new NamePrefixFileFilter(PREFIX, false); - assert filter.accept(new File(PREFIX + "andSomePostFix.txt").getAbsoluteFile()) == false; - } - -} -- GitLab