[JGIT PATCH 08/22] Added the iterface Rules.
Signed-off-by: Florian Koeberle <florianskarten@web.de>
---
.../org/spearce/jgit/lib/fileiteration/Rules.java | 101 ++++++++++++++++++++
1 files changed, 101 insertions(+), 0 deletions(-)
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/fileiteration/Rules.java
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/fileiteration/Rules.java b/org.spearce.jgit/src/org/spearce/jgit/lib/fileiteration/Rules.java
new file mode 100644
index 0000000..1334a22
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/fileiteration/Rules.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2008 Florian Köberle
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ */
+package org.spearce.jgit.lib.fileiteration;
+
+/**
+ * A {@link Rules} instances defines ignore or do not ignore rules for files in
+ * a directory. It can't directly be used to match files in sub directories, but
+ * provides a method {@link #getRulesForSubDirectory}.
+ *
+ * @author Florian Köberle
+ *
+ */
+public interface Rules {
+
+ /**
+ * Provides the instance of {@link IgnoreAllRules}.
+ */
+ public static final Rules IGNORE_ALL = new IgnoreAllRules();
+
+ /**
+ * Provides the instance of {@link IgnoreNothingRules}.
+ */
+ public static final Rules IGNORE_NOTHING = new IgnoreNothingRules();
+
+ /**
+ * @param fileName
+ * the name of the file or directory.
+ * @param fileIsDirectory
+ * should be true if the file is a directory.
+ * @return true if the file or directory should be ignored.
+ */
+ public abstract boolean toIgnore(String fileName, boolean fileIsDirectory);
+
+ /**
+ * @param directoryName
+ * the sub directory for which you want an {@link Rules}
+ * instance.
+ * @return an {@link Rules} instance, which can be used to check files in
+ * the specified sub directory.
+ */
+ public abstract Rules getRulesForSubDirectory(String directoryName);
+
+ /**
+ * This implementation ignores everything.
+ */
+ public static final class IgnoreAllRules implements Rules {
+ private IgnoreAllRules() {
+ // declared to make the constructor private
+ }
+
+ public Rules getRulesForSubDirectory(String directoryName) {
+ return this;
+ }
+
+ public boolean toIgnore(String fileName, boolean fileIsDirectory) {
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "ignore all rules";
+ }
+ }
+
+ /**
+ * This implementation ignores nothing.
+ */
+ public static final class IgnoreNothingRules implements Rules {
+ private IgnoreNothingRules() {
+ // declared to make the constructor private
+ }
+
+ public Rules getRulesForSubDirectory(String directoryName) {
+ return this;
+ }
+
+ public boolean toIgnore(String fileName, boolean fileIsDirectory) {
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return "ignore nothing rules";
+ }
+ }
+
+}
\ No newline at end of file
--
1.5.2.5