roxspring 2004/09/02 07:45:52 Modified: cli/src/java/org/apache/commons/cli2/validation DateValidator.java Log: The array of permitted formats is not mutable Revision Changes Path 1.3 +43 -4 jakarta-commons/cli/src/java/org/apache/commons/cli2/validation/DateValidator.java Index: DateValidator.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/validation/DateValidator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DateValidator.java 22 Apr 2004 23:00:14 -0000 1.2 +++ DateValidator.java 2 Sep 2004 14:45:51 -0000 1.3 @@ -29,7 +29,7 @@ public class DateValidator implements Validator { /** an array of permitted DateFormats */ - private final DateFormat[] formats; + private DateFormat[] formats; /** minimum Date allowed i.e: a valid date occurs later than this date */ private Date minimum; @@ -78,7 +78,7 @@ * a DateFormat which dates must conform to */ public DateValidator(final DateFormat format) { - this.formats = new DateFormat[] { format }; + setFormat(format); } /** @@ -88,8 +88,7 @@ * a List of DateFormats which dates must conform to */ public DateValidator(final List formats) { - this.formats = - (DateFormat[])formats.toArray(new DateFormat[formats.size()]); + setFormats(formats); } /** @@ -210,4 +209,44 @@ private boolean isDateEarlier(Date date) { return minimum != null && date.getTime() < minimum.getTime(); } + + /** + * Sets the date format permitted. + * + * @param format + * the format to use + */ + public void setFormat(final DateFormat format) { + formats = new DateFormat[]{format}; + } + + /** + * Sets the date formats permitted. + * + * @param formats + * the List of DateFormats to use + */ + public void setFormats(final List formats) { + setFormats((DateFormat[])formats.toArray(new DateFormat[formats.size()])); + } + + /** + * Sets the date formats permitted. + * + * @param formats + * the array of DateFormats to use + */ + public void setFormats(final DateFormat[] formats) { + this.formats = formats; + } + + /** + * Gets the date formats permitted. + * + * @return the permitted formats + */ + public DateFormat[] getFormats() { + return this.formats; + } + }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]