[JGIT PATCH 17/22] Added the class TreeFilePattern.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Florian Koeberle <florianskarten@xxxxxx>
---
 .../jgit/lib/fileiteration/TreeFilePattern.java    |   77 ++++++++++++++++++++
 1 files changed, 77 insertions(+), 0 deletions(-)
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/fileiteration/TreeFilePattern.java

diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/fileiteration/TreeFilePattern.java b/org.spearce.jgit/src/org/spearce/jgit/lib/fileiteration/TreeFilePattern.java
new file mode 100644
index 0000000..371c632
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/fileiteration/TreeFilePattern.java
@@ -0,0 +1,77 @@
+/*
+ *  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;
+
+import java.util.List;
+
+/**
+ * Represents a pattern like "documents/*.txt" which matches all *.txt files in
+ * the tree documents.
+ * 
+ * @author Florian Köberle
+ * 
+ */
+class TreeFilePattern implements FilePattern {
+
+	private final List<String> path;
+
+	private final int offset;
+
+	private final GlobalFilePattern globalFilePattern;
+
+	public boolean canMatchAtThisDirectoryLevel() {
+		return false;
+	}
+
+	TreeFilePattern(List<String> path, GlobalFilePattern globalFilePattern) {
+		this.path = path;
+		this.offset = 0;
+		this.globalFilePattern = globalFilePattern;
+	}
+
+	private TreeFilePattern(List<String> path, int offset,
+			GlobalFilePattern globalFilePattern) {
+		this.path = path;
+		this.offset = offset;
+		this.globalFilePattern = globalFilePattern;
+	}
+
+	public FilePattern getPatternForSubDirectory(String directoryName) {
+		try {
+			if (!path.get(offset).equals(directoryName)) {
+				return FilePattern.MATCH_NEVER;
+			}
+		} catch (IndexOutOfBoundsException e) {
+			throw new IllegalStateException(
+					"The offset of this class doesn't refer to a valid position in path");
+		}
+		if (offset == path.size() - 1) {
+			return globalFilePattern;
+		} else {
+			return new TreeFilePattern(path, offset + 1, globalFilePattern);
+		}
+	}
+
+	public boolean isSameForSubDirectories() {
+		return false;
+	}
+
+	public boolean match(String fileName, boolean fileIsDirectory) {
+		return false;
+	}
+
+}
-- 
1.5.2.5

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux