TimeComparisonpublic class TimeComparison extends EnumeratedAttribute EnumeratedAttribute for time comparisons. Accepts values
"before", "after", "equal". |
Fields Summary |
---|
private static final String[] | VALUES | private static final org.apache.tools.ant.util.FileUtils | FILE_UTILS | public static final TimeComparison | BEFOREBefore Comparison. | public static final TimeComparison | AFTERAfter Comparison. | public static final TimeComparison | EQUALEqual Comparison. |
Constructors Summary |
---|
public TimeComparison()Default constructor.
| public TimeComparison(String value)Construct a new TimeComparison with the specified value.
setValue(value);
|
Methods Summary |
---|
public static int | compare(long t1, long t2)Compare two times.
return compare(t1, t2, FILE_UTILS.getFileTimestampGranularity());
| public static int | compare(long t1, long t2, long g)Compare two times.
long diff = t1 - t2;
long abs = Math.abs(diff);
return abs > Math.abs(g) ? (int) (diff / abs) : 0;
| public boolean | evaluate(long t1, long t2)Evaluate two times against this TimeComparison.
return evaluate(t1, t2, FILE_UTILS.getFileTimestampGranularity());
| public boolean | evaluate(long t1, long t2, long g)Evaluate two times against this TimeComparison.
int cmp = getIndex();
if (cmp == -1) {
throw new BuildException("TimeComparison value not set.");
}
if (cmp == 0) {
return t1 - g < t2;
}
if (cmp == 1) {
return t1 + g > t2;
}
return Math.abs(t1 - t2) <= g;
| public java.lang.String[] | getValues()Return the possible values.
return VALUES;
|
|