Mercurial > jhg
comparison src/org/tmatesoft/hg/util/PathRewrite.java @ 292:a415fe296a50
Refactor PathRewrite to accept any char sequence, not only string
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 14 Sep 2011 02:16:19 +0200 |
parents | 37a34044e6bd |
children |
comparison
equal
deleted
inserted
replaced
291:1483e57541ef | 292:a415fe296a50 |
---|---|
25 * @author Artem Tikhomirov | 25 * @author Artem Tikhomirov |
26 * @author TMate Software Ltd. | 26 * @author TMate Software Ltd. |
27 */ | 27 */ |
28 public interface PathRewrite { | 28 public interface PathRewrite { |
29 | 29 |
30 // XXX think over CharSequence use instead of String | 30 public CharSequence rewrite(CharSequence path); |
31 public String rewrite(String path); | |
32 | 31 |
33 public static class Empty implements PathRewrite { | 32 public static class Empty implements PathRewrite { |
34 public String rewrite(String path) { | 33 public CharSequence rewrite(CharSequence path) { |
35 return path; | 34 return path; |
36 } | 35 } |
37 } | 36 } |
38 | 37 |
39 public class Composite implements PathRewrite { | 38 public class Composite implements PathRewrite { |
49 public Composite chain(PathRewrite e) { | 48 public Composite chain(PathRewrite e) { |
50 chain.add(e); | 49 chain.add(e); |
51 return this; | 50 return this; |
52 } | 51 } |
53 | 52 |
54 public String rewrite(String path) { | 53 public CharSequence rewrite(CharSequence path) { |
55 for (PathRewrite pr : chain) { | 54 for (PathRewrite pr : chain) { |
56 path = pr.rewrite(path); | 55 path = pr.rewrite(path); |
57 } | 56 } |
58 return path; | 57 return path; |
59 } | 58 } |