< prev index next >
src/java.desktop/share/classes/javax/swing/SpinnerDateModel.java
Print this page
@@ -28,55 +28,55 @@
import java.util.*;
import java.io.Serializable;
/**
- * A <code>SpinnerModel</code> for sequences of <code>Date</code>s.
+ * A {@code SpinnerModel} for sequences of {@code Date}s.
* The upper and lower bounds of the sequence are defined by properties called
- * <code>start</code> and <code>end</code> and the size
- * of the increase or decrease computed by the <code>nextValue</code>
- * and <code>previousValue</code> methods is defined by a property
- * called <code>calendarField</code>. The <code>start</code>
- * and <code>end</code> properties can be <code>null</code> to
+ * {@code start} and {@code end} and the size
+ * of the increase or decrease computed by the {@code nextValue}
+ * and {@code previousValue} methods is defined by a property
+ * called {@code calendarField}. The {@code start}
+ * and {@code end} properties can be {@code null} to
* indicate that the sequence has no lower or upper limit.
* <p>
- * The value of the <code>calendarField</code> property must be one of the
- * <code>java.util.Calendar</code> constants that specify a field
- * within a <code>Calendar</code>. The <code>getNextValue</code>
- * and <code>getPreviousValue</code>
+ * The value of the {@code calendarField} property must be one of the
+ * {@code java.util.Calendar} constants that specify a field
+ * within a {@code Calendar}. The {@code getNextValue}
+ * and {@code getPreviousValue}
* methods change the date forward or backwards by this amount.
- * For example, if <code>calendarField</code> is <code>Calendar.DAY_OF_WEEK</code>,
- * then <code>nextValue</code> produces a <code>Date</code> that's 24
- * hours after the current <code>value</code>, and <code>previousValue</code>
- * produces a <code>Date</code> that's 24 hours earlier.
+ * For example, if {@code calendarField} is {@code Calendar.DAY_OF_WEEK},
+ * then {@code nextValue} produces a {@code Date} that's 24
+ * hours after the current {@code value}, and {@code previousValue}
+ * produces a {@code Date} that's 24 hours earlier.
* <p>
- * The legal values for <code>calendarField</code> are:
+ * The legal values for {@code calendarField} are:
* <ul>
- * <li><code>Calendar.ERA</code>
- * <li><code>Calendar.YEAR</code>
- * <li><code>Calendar.MONTH</code>
- * <li><code>Calendar.WEEK_OF_YEAR</code>
- * <li><code>Calendar.WEEK_OF_MONTH</code>
- * <li><code>Calendar.DAY_OF_MONTH</code>
- * <li><code>Calendar.DAY_OF_YEAR</code>
- * <li><code>Calendar.DAY_OF_WEEK</code>
- * <li><code>Calendar.DAY_OF_WEEK_IN_MONTH</code>
- * <li><code>Calendar.AM_PM</code>
- * <li><code>Calendar.HOUR</code>
- * <li><code>Calendar.HOUR_OF_DAY</code>
- * <li><code>Calendar.MINUTE</code>
- * <li><code>Calendar.SECOND</code>
- * <li><code>Calendar.MILLISECOND</code>
+ * <li>{@code Calendar.ERA}
+ * <li>{@code Calendar.YEAR}
+ * <li>{@code Calendar.MONTH}
+ * <li>{@code Calendar.WEEK_OF_YEAR}
+ * <li>{@code Calendar.WEEK_OF_MONTH}
+ * <li>{@code Calendar.DAY_OF_MONTH}
+ * <li>{@code Calendar.DAY_OF_YEAR}
+ * <li>{@code Calendar.DAY_OF_WEEK}
+ * <li>{@code Calendar.DAY_OF_WEEK_IN_MONTH}
+ * <li>{@code Calendar.AM_PM}
+ * <li>{@code Calendar.HOUR}
+ * <li>{@code Calendar.HOUR_OF_DAY}
+ * <li>{@code Calendar.MINUTE}
+ * <li>{@code Calendar.SECOND}
+ * <li>{@code Calendar.MILLISECOND}
* </ul>
* However some UIs may set the calendarField before committing the edit
* to spin the field under the cursor. If you only want one field to
* spin you can subclass and ignore the setCalendarField calls.
* <p>
- * This model inherits a <code>ChangeListener</code>. The
- * <code>ChangeListeners</code> are notified whenever the models
- * <code>value</code>, <code>calendarField</code>,
- * <code>start</code>, or <code>end</code> properties changes.
+ * This model inherits a {@code ChangeListener}. The
+ * {@code ChangeListeners} are notified whenever the models
+ * {@code value}, {@code calendarField},
+ * {@code start}, or {@code end} properties changes.
*
* @see JSpinner
* @see SpinnerModel
* @see AbstractSpinnerModel
* @see SpinnerListModel
@@ -117,57 +117,57 @@
}
}
/**
- * Creates a <code>SpinnerDateModel</code> that represents a sequence of dates
- * between <code>start</code> and <code>end</code>. The
- * <code>nextValue</code> and <code>previousValue</code> methods
+ * Creates a {@code SpinnerDateModel} that represents a sequence of dates
+ * between {@code start} and {@code end}. The
+ * {@code nextValue} and {@code previousValue} methods
* compute elements of the sequence by advancing or reversing
- * the current date <code>value</code> by the
- * <code>calendarField</code> time unit. For a precise description
- * of what it means to increment or decrement a <code>Calendar</code>
- * <code>field</code>, see the <code>add</code> method in
- * <code>java.util.Calendar</code>.
+ * the current date {@code value} by the
+ * {@code calendarField} time unit. For a precise description
+ * of what it means to increment or decrement a {@code Calendar}
+ * {@code field}, see the {@code add} method in
+ * {@code java.util.Calendar}.
* <p>
- * The <code>start</code> and <code>end</code> parameters can be
- * <code>null</code> to indicate that the range doesn't have an
- * upper or lower bound. If <code>value</code> or
- * <code>calendarField</code> is <code>null</code>, or if both
- * <code>start</code> and <code>end</code> are specified and
- * <code>minimum > maximum</code> then an
- * <code>IllegalArgumentException</code> is thrown.
- * Similarly if <code>(minimum <= value <= maximum)</code> is false,
+ * The {@code start} and {@code end} parameters can be
+ * {@code null} to indicate that the range doesn't have an
+ * upper or lower bound. If {@code value} or
+ * {@code calendarField} is {@code null}, or if both
+ * {@code start} and {@code end} are specified and
+ * {@code minimum > maximum} then an
+ * {@code IllegalArgumentException} is thrown.
+ * Similarly if {@code (minimum <= value <= maximum)} is false,
* an IllegalArgumentException is thrown.
*
- * @param value the current (non <code>null</code>) value of the model
- * @param start the first date in the sequence or <code>null</code>
- * @param end the last date in the sequence or <code>null</code>
+ * @param value the current (non {@code null}) value of the model
+ * @param start the first date in the sequence or {@code null}
+ * @param end the last date in the sequence or {@code null}
* @param calendarField one of
* <ul>
- * <li><code>Calendar.ERA</code>
- * <li><code>Calendar.YEAR</code>
- * <li><code>Calendar.MONTH</code>
- * <li><code>Calendar.WEEK_OF_YEAR</code>
- * <li><code>Calendar.WEEK_OF_MONTH</code>
- * <li><code>Calendar.DAY_OF_MONTH</code>
- * <li><code>Calendar.DAY_OF_YEAR</code>
- * <li><code>Calendar.DAY_OF_WEEK</code>
- * <li><code>Calendar.DAY_OF_WEEK_IN_MONTH</code>
- * <li><code>Calendar.AM_PM</code>
- * <li><code>Calendar.HOUR</code>
- * <li><code>Calendar.HOUR_OF_DAY</code>
- * <li><code>Calendar.MINUTE</code>
- * <li><code>Calendar.SECOND</code>
- * <li><code>Calendar.MILLISECOND</code>
+ * <li>{@code Calendar.ERA}
+ * <li>{@code Calendar.YEAR}
+ * <li>{@code Calendar.MONTH}
+ * <li>{@code Calendar.WEEK_OF_YEAR}
+ * <li>{@code Calendar.WEEK_OF_MONTH}
+ * <li>{@code Calendar.DAY_OF_MONTH}
+ * <li>{@code Calendar.DAY_OF_YEAR}
+ * <li>{@code Calendar.DAY_OF_WEEK}
+ * <li>{@code Calendar.DAY_OF_WEEK_IN_MONTH}
+ * <li>{@code Calendar.AM_PM}
+ * <li>{@code Calendar.HOUR}
+ * <li>{@code Calendar.HOUR_OF_DAY}
+ * <li>{@code Calendar.MINUTE}
+ * <li>{@code Calendar.SECOND}
+ * <li>{@code Calendar.MILLISECOND}
* </ul>
*
- * @throws IllegalArgumentException if <code>value</code> or
- * <code>calendarField</code> are <code>null</code>,
- * if <code>calendarField</code> isn't valid,
+ * @throws IllegalArgumentException if {@code value} or
+ * {@code calendarField} are {@code null},
+ * if {@code calendarField} isn't valid,
* or if the following expression is
- * false: <code>(start <= value <= end)</code>.
+ * false: {@code (start <= value <= end)}.
*
* @see Calendar#add
* @see #setValue
* @see #setStart
* @see #setEnd
@@ -192,34 +192,34 @@
this.value.setTime(value);
}
/**
- * Constructs a <code>SpinnerDateModel</code> whose initial
- * <code>value</code> is the current date, <code>calendarField</code>
- * is equal to <code>Calendar.DAY_OF_MONTH</code>, and for which
- * there are no <code>start</code>/<code>end</code> limits.
+ * Constructs a {@code SpinnerDateModel} whose initial
+ * {@code value} is the current date, {@code calendarField}
+ * is equal to {@code Calendar.DAY_OF_MONTH}, and for which
+ * there are no {@code start}/{@code end} limits.
*/
public SpinnerDateModel() {
this(new Date(), null, null, Calendar.DAY_OF_MONTH);
}
/**
* Changes the lower limit for Dates in this sequence.
- * If <code>start</code> is <code>null</code>,
+ * If {@code start} is {@code null},
* then there is no lower limit. No bounds checking is done here:
* the new start value may invalidate the
- * <code>(start <= value <= end)</code>
+ * {@code (start <= value <= end)}
* invariant enforced by the constructors. This is to simplify updating
* the model. Naturally one should ensure that the invariant is true
- * before calling the <code>nextValue</code>, <code>previousValue</code>,
- * or <code>setValue</code> methods.
+ * before calling the {@code nextValue}, {@code previousValue},
+ * or {@code setValue} methods.
* <p>
- * Typically this property is a <code>Date</code> however it's possible to use
- * a <code>Comparable</code> with a <code>compareTo</code> method for Dates.
- * For example <code>start</code> might be an instance of a class like this:
+ * Typically this property is a {@code Date} however it's possible to use
+ * a {@code Comparable} with a {@code compareTo} method for Dates.
+ * For example {@code start} might be an instance of a class like this:
* <pre>
* MyStartDate implements Comparable {
* long t = 12345;
* public int compareTo(Date d) {
* return (t < d.getTime() ? -1 : (t == d.getTime() ? 0 : 1));
@@ -227,16 +227,16 @@
* public int compareTo(Object o) {
* return compareTo((Date)o);
* }
* }
* </pre>
- * Note that the above example will throw a <code>ClassCastException</code>
- * if the <code>Object</code> passed to <code>compareTo(Object)</code>
- * is not a <code>Date</code>.
+ * Note that the above example will throw a {@code ClassCastException}
+ * if the {@code Object} passed to {@code compareTo(Object)}
+ * is not a {@code Date}.
* <p>
- * This method fires a <code>ChangeEvent</code> if the
- * <code>start</code> has changed.
+ * This method fires a {@code ChangeEvent} if the
+ * {@code start} has changed.
*
* @param start defines the first date in the sequence
* @see #getStart
* @see #setEnd
* @see #addChangeListener
@@ -248,35 +248,35 @@
}
}
/**
- * Returns the first <code>Date</code> in the sequence.
+ * Returns the first {@code Date} in the sequence.
*
- * @return the value of the <code>start</code> property
+ * @return the value of the {@code start} property
* @see #setStart
*/
public Comparable<Date> getStart() {
return start;
}
/**
- * Changes the upper limit for <code>Date</code>s in this sequence.
- * If <code>start</code> is <code>null</code>, then there is no upper
+ * Changes the upper limit for {@code Date}s in this sequence.
+ * If {@code start} is {@code null}, then there is no upper
* limit. No bounds checking is done here: the new
- * start value may invalidate the <code>(start <= value <= end)</code>
+ * start value may invalidate the {@code (start <= value <= end)}
* invariant enforced by the constructors. This is to simplify updating
* the model. Naturally, one should ensure that the invariant is true
- * before calling the <code>nextValue</code>, <code>previousValue</code>,
- * or <code>setValue</code> methods.
+ * before calling the {@code nextValue}, {@code previousValue},
+ * or {@code setValue} methods.
* <p>
- * Typically this property is a <code>Date</code> however it's possible to use
- * <code>Comparable</code> with a <code>compareTo</code> method for
- * <code>Date</code>s. See <code>setStart</code> for an example.
+ * Typically this property is a {@code Date} however it's possible to use
+ * {@code Comparable} with a {@code compareTo} method for
+ * {@code Date}s. See {@code setStart} for an example.
* <p>
- * This method fires a <code>ChangeEvent</code> if the <code>end</code>
+ * This method fires a {@code ChangeEvent} if the {@code end}
* has changed.
*
* @param end defines the last date in the sequence
* @see #getEnd
* @see #setStart
@@ -289,55 +289,55 @@
}
}
/**
- * Returns the last <code>Date</code> in the sequence.
+ * Returns the last {@code Date} in the sequence.
*
- * @return the value of the <code>end</code> property
+ * @return the value of the {@code end} property
* @see #setEnd
*/
public Comparable<Date> getEnd() {
return end;
}
/**
* Changes the size of the date value change computed
- * by the <code>nextValue</code> and <code>previousValue</code> methods.
- * The <code>calendarField</code> parameter must be one of the
- * <code>Calendar</code> field constants like <code>Calendar.MONTH</code>
- * or <code>Calendar.MINUTE</code>.
- * The <code>nextValue</code> and <code>previousValue</code> methods
- * simply move the specified <code>Calendar</code> field forward or backward
- * by one unit with the <code>Calendar.add</code> method.
+ * by the {@code nextValue} and {@code previousValue} methods.
+ * The {@code calendarField} parameter must be one of the
+ * {@code Calendar} field constants like {@code Calendar.MONTH}
+ * or {@code Calendar.MINUTE}.
+ * The {@code nextValue} and {@code previousValue} methods
+ * simply move the specified {@code Calendar} field forward or backward
+ * by one unit with the {@code Calendar.add} method.
* You should use this method with care as some UIs may set the
* calendarField before committing the edit to spin the field under
* the cursor. If you only want one field to spin you can subclass
* and ignore the setCalendarField calls.
*
* @param calendarField one of
* <ul>
- * <li><code>Calendar.ERA</code>
- * <li><code>Calendar.YEAR</code>
- * <li><code>Calendar.MONTH</code>
- * <li><code>Calendar.WEEK_OF_YEAR</code>
- * <li><code>Calendar.WEEK_OF_MONTH</code>
- * <li><code>Calendar.DAY_OF_MONTH</code>
- * <li><code>Calendar.DAY_OF_YEAR</code>
- * <li><code>Calendar.DAY_OF_WEEK</code>
- * <li><code>Calendar.DAY_OF_WEEK_IN_MONTH</code>
- * <li><code>Calendar.AM_PM</code>
- * <li><code>Calendar.HOUR</code>
- * <li><code>Calendar.HOUR_OF_DAY</code>
- * <li><code>Calendar.MINUTE</code>
- * <li><code>Calendar.SECOND</code>
- * <li><code>Calendar.MILLISECOND</code>
+ * <li>{@code Calendar.ERA}
+ * <li>{@code Calendar.YEAR}
+ * <li>{@code Calendar.MONTH}
+ * <li>{@code Calendar.WEEK_OF_YEAR}
+ * <li>{@code Calendar.WEEK_OF_MONTH}
+ * <li>{@code Calendar.DAY_OF_MONTH}
+ * <li>{@code Calendar.DAY_OF_YEAR}
+ * <li>{@code Calendar.DAY_OF_WEEK}
+ * <li>{@code Calendar.DAY_OF_WEEK_IN_MONTH}
+ * <li>{@code Calendar.AM_PM}
+ * <li>{@code Calendar.HOUR}
+ * <li>{@code Calendar.HOUR_OF_DAY}
+ * <li>{@code Calendar.MINUTE}
+ * <li>{@code Calendar.SECOND}
+ * <li>{@code Calendar.MILLISECOND}
* </ul>
* <p>
- * This method fires a <code>ChangeEvent</code> if the
- * <code>calendarField</code> has changed.
+ * This method fires a {@code ChangeEvent} if the
+ * {@code calendarField} has changed.
*
* @see #getCalendarField
* @see #getNextValue
* @see #getPreviousValue
* @see Calendar#add
@@ -353,27 +353,27 @@
}
}
/**
- * Returns the <code>Calendar</code> field that is added to or subtracted from
- * by the <code>nextValue</code> and <code>previousValue</code> methods.
+ * Returns the {@code Calendar} field that is added to or subtracted from
+ * by the {@code nextValue} and {@code previousValue} methods.
*
- * @return the value of the <code>calendarField</code> property
+ * @return the value of the {@code calendarField} property
* @see #setCalendarField
*/
public int getCalendarField() {
return calendarField;
}
/**
- * Returns the next <code>Date</code> in the sequence, or <code>null</code> if
- * the next date is after <code>end</code>.
+ * Returns the next {@code Date} in the sequence, or {@code null} if
+ * the next date is after {@code end}.
*
- * @return the next <code>Date</code> in the sequence, or <code>null</code> if
- * the next date is after <code>end</code>.
+ * @return the next {@code Date} in the sequence, or {@code null} if
+ * the next date is after {@code end}.
*
* @see SpinnerModel#getNextValue
* @see #getPreviousValue
* @see #setCalendarField
*/
@@ -385,16 +385,16 @@
return ((end == null) || (end.compareTo(next) >= 0)) ? next : null;
}
/**
- * Returns the previous <code>Date</code> in the sequence, or <code>null</code>
- * if the previous date is before <code>start</code>.
+ * Returns the previous {@code Date} in the sequence, or {@code null}
+ * if the previous date is before {@code start}.
*
- * @return the previous <code>Date</code> in the sequence, or
- * <code>null</code> if the previous date
- * is before <code>start</code>
+ * @return the previous {@code Date} in the sequence, or
+ * {@code null} if the previous date
+ * is before {@code start}
*
* @see SpinnerModel#getPreviousValue
* @see #getNextValue
* @see #setCalendarField
*/
@@ -406,51 +406,51 @@
return ((start == null) || (start.compareTo(prev) <= 0)) ? prev : null;
}
/**
- * Returns the current element in this sequence of <code>Date</code>s.
- * This method is equivalent to <code>(Date)getValue</code>.
+ * Returns the current element in this sequence of {@code Date}s.
+ * This method is equivalent to {@code (Date)getValue}.
*
- * @return the <code>value</code> property
+ * @return the {@code value} property
* @see #setValue
*/
public Date getDate() {
return value.getTime();
}
/**
- * Returns the current element in this sequence of <code>Date</code>s.
+ * Returns the current element in this sequence of {@code Date}s.
*
- * @return the <code>value</code> property
+ * @return the {@code value} property
* @see #setValue
* @see #getDate
*/
public Object getValue() {
return value.getTime();
}
/**
- * Sets the current <code>Date</code> for this sequence.
- * If <code>value</code> is <code>null</code>,
- * an <code>IllegalArgumentException</code> is thrown. No bounds
+ * Sets the current {@code Date} for this sequence.
+ * If {@code value} is {@code null},
+ * an {@code IllegalArgumentException} is thrown. No bounds
* checking is done here:
- * the new value may invalidate the <code>(start <= value < end)</code>
+ * the new value may invalidate the {@code (start <= value < end)}
* invariant enforced by the constructors. Naturally, one should ensure
- * that the <code>(start <= value <= maximum)</code> invariant is true
- * before calling the <code>nextValue</code>, <code>previousValue</code>,
- * or <code>setValue</code> methods.
+ * that the {@code (start <= value <= maximum)} invariant is true
+ * before calling the {@code nextValue}, {@code previousValue},
+ * or {@code setValue} methods.
* <p>
- * This method fires a <code>ChangeEvent</code> if the
- * <code>value</code> has changed.
+ * This method fires a {@code ChangeEvent} if the
+ * {@code value} has changed.
*
- * @param value the current (non <code>null</code>)
- * <code>Date</code> for this sequence
- * @throws IllegalArgumentException if value is <code>null</code>
- * or not a <code>Date</code>
+ * @param value the current (non {@code null})
+ * {@code Date} for this sequence
+ * @throws IllegalArgumentException if value is {@code null}
+ * or not a {@code Date}
* @see #getDate
* @see #getValue
* @see #addChangeListener
*/
public void setValue(Object value) {
< prev index next >