Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/RelativePathRewrite.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 | 8248aae33f7d |
children |
comparison
equal
deleted
inserted
replaced
291:1483e57541ef | 292:a415fe296a50 |
---|---|
35 | 35 |
36 public RelativePathRewrite(String rootPath) { | 36 public RelativePathRewrite(String rootPath) { |
37 this.rootPath = rootPath; | 37 this.rootPath = rootPath; |
38 } | 38 } |
39 | 39 |
40 public String rewrite(String path) { | 40 public CharSequence rewrite(CharSequence p) { |
41 String path = p == null ? null : p.toString(); | |
41 if (path != null && path.startsWith(rootPath)) { | 42 if (path != null && path.startsWith(rootPath)) { |
42 if (path.length() == rootPath.length()) { | 43 if (path.length() == rootPath.length()) { |
43 return ""; | 44 return ""; |
44 } | 45 } |
45 return path.substring(rootPath.length() + 1); | 46 return path.substring(rootPath.length() + 1); |