1 18 package org.apache.tools.ant.types.resources.comparators; 19 20 import org.apache.tools.ant.BuildException; 21 import org.apache.tools.ant.types.Resource; 22 23 28 public class Reverse extends ResourceComparator { 29 private static final String ONE_NESTED 30 = "You must not nest more than one ResourceComparator for reversal."; 31 32 private ResourceComparator nested; 33 34 37 public Reverse() { 38 } 39 40 44 public Reverse(ResourceComparator c) { 45 add(c); 46 } 47 48 52 public void add(ResourceComparator c) { 53 if (nested != null) { 54 throw new BuildException(ONE_NESTED); 55 } 56 nested = c; 57 } 58 59 66 protected int resourceCompare(Resource foo, Resource bar) { 67 return -1 * (nested == null 68 ? foo.compareTo(bar) : nested.compare(foo, bar)); 69 } 70 71 } 72 | Popular Tags |