diff src/org/tmatesoft/hg/util/Path.java @ 141:8248aae33f7d

Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 17 Feb 2011 04:08:34 +0100
parents 4a948ec83980
children 1a7a9a20e1f9
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/util/Path.java	Wed Feb 16 22:33:04 2011 +0100
+++ b/src/org/tmatesoft/hg/util/Path.java	Thu Feb 17 04:08:34 2011 +0100
@@ -80,6 +80,31 @@
 	 * Path filter.
 	 */
 	public interface Matcher {
-		public boolean accept(Path path);
+		boolean accept(Path path);
+	}
+
+	/**
+	 * Factory for paths
+	 */
+	public interface Source {
+		Path path(String p);
+	}
+
+	/**
+	 * Straightforward {@link Source} implementation that creates new Path instance for each supplied string
+	 */
+	public static class SimpleSource implements Source {
+		private final PathRewrite normalizer;
+
+		public SimpleSource(PathRewrite pathRewrite) {
+			if (pathRewrite == null) {
+				throw new IllegalArgumentException();
+			}
+			normalizer = pathRewrite;
+		}
+
+		public Path path(String p) {
+			return Path.create(normalizer.rewrite(p));
+		}
 	}
 }