1 13 package org.jahia.views.engines.datepicker; 14 15 16 public class DateValidator implements DateValidatorInterface { 17 18 public static final int NO_COMP = -1; 19 public static final int COMP_BIGGER = 1; 20 public static final int COMP_SMALLER = 2; 21 public static final int COMP_EQUAL = 3; 22 public static final int COMP_BIGGER_EQUAL = 4; 23 public static final int COMP_SMALLER_EQUAL = 5; 24 25 private long startDate; 26 private int comparator; 27 28 public DateValidator(long startDate, int comparator){ 29 this.startDate = startDate; 30 this.comparator = comparator; 31 } 32 33 public int getComparator(){ 34 return this.comparator; 35 } 36 37 public long getStartDate(){ 38 return this.startDate; 39 } 40 41 public void setStartDate(long date){ 42 this.startDate = date; 43 } 44 45 public boolean isValid(long date){ 46 switch (comparator) { 47 case COMP_BIGGER: 48 return (date > startDate); 49 case COMP_SMALLER: 50 return (date < startDate); 51 case COMP_EQUAL: 52 return (date == startDate); 53 case COMP_BIGGER_EQUAL: 54 return (date >= startDate); 55 case COMP_SMALLER_EQUAL: 56 return (date <= startDate); 57 } 58 return true; 59 } 60 } | Popular Tags |