@Test public void testOpDefault() throws FilterRuleNotAppliableException, ParseException { FileAgeFileFilterRule filterRule = new FileAgeFileFilterRule(new AgeValue(1, AgeValue.Unit.SECONDS), -1); assertFalse(filterRule.match(createTestNode("01/01/2005 10:00:00"))); }
@Override public boolean match(File file) throws FilterRuleNotAppliableException { long lastModified = file.getLastModified(); if (-1 == lastModified) { throw new FilterRuleNotAppliableException("The file or directory doesn't have any modification date"); } long now = SystemDate.getInstance().currentTimeMillis(); long delta = (long) (Math.floor(now / 1000.0) - Math.floor(lastModified / 1000.0)); switch (op) { case OP_IS: return delta == age.getSeconds(); case OP_ISNT: return delta != age.getSeconds(); case OP_IS_GREATER_THAN: return delta > age.getSeconds(); case OP_IS_LESS_THAN: return delta < age.getSeconds(); default: return false; } }
FileAgeFileFilterRule implements FileFilterRule { @Override public boolean match(File file) throws FilterRuleNotAppliableException { long lastModified = file.getLastModified(); if (-1 == lastModified) { throw new FilterRuleNotAppliableException("The file or directory doesn't have any modification date"); } long now = SystemDate.getInstance().currentTimeMillis(); long delta = (long) (Math.floor(now / 1000.0) - Math.floor(lastModified / 1000.0)); switch (op) { case OP_IS: return delta == age.getSeconds(); case OP_ISNT: return delta != age.getSeconds(); case OP_IS_GREATER_THAN: return delta > age.getSeconds(); case OP_IS_LESS_THAN: return delta < age.getSeconds(); default: return false; } } }
FileAgeFileFilterRule implements FileFilterRule { @Override public boolean match(File file) throws FilterRuleNotAppliableException { long lastModified = file.getLastModified(); if (-1 == lastModified) { throw new FilterRuleNotAppliableException("The file or directory doesn't have any modification date"); } long now = SystemDate.getInstance().currentTimeMillis(); long delta = (long) (Math.floor(now / 1000.0) - Math.floor(lastModified / 1000.0)); switch (op) { case OP_IS: return delta == age.getSeconds(); case OP_ISNT: return delta != age.getSeconds(); case OP_IS_GREATER_THAN: return delta > age.getSeconds(); case OP_IS_LESS_THAN: return delta < age.getSeconds(); default: return false; } } FileAgeFileFilterRule(AgeValue age, int operator); }
FileAgeFileFilterRule implements FileFilterRule { @Override public boolean match(File file) throws FilterRuleNotAppliableException { long lastModified = file.getLastModified(); if (-1 == lastModified) { throw new FilterRuleNotAppliableException("The file or directory doesn't have any modification date"); } long now = SystemDate.getInstance().currentTimeMillis(); long delta = (long) (Math.floor(now / 1000.0) - Math.floor(lastModified / 1000.0)); switch (op) { case OP_IS: return delta == age.getSeconds(); case OP_ISNT: return delta != age.getSeconds(); case OP_IS_GREATER_THAN: return delta > age.getSeconds(); case OP_IS_LESS_THAN: return delta < age.getSeconds(); default: return false; } } FileAgeFileFilterRule(AgeValue age, int operator); @Override String getRuleType(); static String[] getAllOperators(); @Override int getOperator(); @Override String getOperatorName(); @Override OperandValue getValue(); @Override boolean match(File file); @Override String toString(); }
FileAgeFileFilterRule implements FileFilterRule { @Override public boolean match(File file) throws FilterRuleNotAppliableException { long lastModified = file.getLastModified(); if (-1 == lastModified) { throw new FilterRuleNotAppliableException("The file or directory doesn't have any modification date"); } long now = SystemDate.getInstance().currentTimeMillis(); long delta = (long) (Math.floor(now / 1000.0) - Math.floor(lastModified / 1000.0)); switch (op) { case OP_IS: return delta == age.getSeconds(); case OP_ISNT: return delta != age.getSeconds(); case OP_IS_GREATER_THAN: return delta > age.getSeconds(); case OP_IS_LESS_THAN: return delta < age.getSeconds(); default: return false; } } FileAgeFileFilterRule(AgeValue age, int operator); @Override String getRuleType(); static String[] getAllOperators(); @Override int getOperator(); @Override String getOperatorName(); @Override OperandValue getValue(); @Override boolean match(File file); @Override String toString(); static final String TYPE_NAME; static final int OP_IS; static final int OP_ISNT; static final int OP_IS_GREATER_THAN; static final int OP_IS_LESS_THAN; }