Mercurial > jhg
comparison src/org/tmatesoft/hg/util/PathRewrite.java @ 142:37a34044e6bd
More reasonable use of path normalizer and path.source
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> | 
|---|---|
| date | Thu, 17 Feb 2011 05:06:07 +0100 | 
| parents | 8248aae33f7d | 
| children | a415fe296a50 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 141:8248aae33f7d | 142:37a34044e6bd | 
|---|---|
| 18 | 18 | 
| 19 import java.util.LinkedList; | 19 import java.util.LinkedList; | 
| 20 import java.util.List; | 20 import java.util.List; | 
| 21 | 21 | 
| 22 /** | 22 /** | 
| 23 * | 23 * File names often need transformations, like Windows-style path to Unix or human-readable data file name to storage location. | 
| 24 * | |
| 24 * @author Artem Tikhomirov | 25 * @author Artem Tikhomirov | 
| 25 * @author TMate Software Ltd. | 26 * @author TMate Software Ltd. | 
| 26 */ | 27 */ | 
| 27 public interface PathRewrite { | 28 public interface PathRewrite { | 
| 28 | 29 | 
| 38 public class Composite implements PathRewrite { | 39 public class Composite implements PathRewrite { | 
| 39 private List<PathRewrite> chain; | 40 private List<PathRewrite> chain; | 
| 40 | 41 | 
| 41 public Composite(PathRewrite... e) { | 42 public Composite(PathRewrite... e) { | 
| 42 LinkedList<PathRewrite> r = new LinkedList<PathRewrite>(); | 43 LinkedList<PathRewrite> r = new LinkedList<PathRewrite>(); | 
| 43 for (int i = (e == null ? -1 : e.length); i >=0; i--) { | 44 for (int i = 0; e != null && i < e.length; i++) { | 
| 44 r.addFirst(e[i]); | 45 r.addLast(e[i]); | 
| 45 } | 46 } | 
| 46 chain = r; | 47 chain = r; | 
| 47 } | 48 } | 
| 48 public Composite chain(PathRewrite e) { | 49 public Composite chain(PathRewrite e) { | 
| 49 chain.add(e); | 50 chain.add(e); | 
