
com.github.croesch.contents.date.DateContent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of crhcomponents Show documentation
Show all versions of crhcomponents Show documentation
Provides some useful components for small Java projects.
package com.github.croesch.contents.date;
import java.util.Date;
import java.util.Locale;
import javax.swing.text.JTextComponent;
import com.github.croesch.contents.CContent;
/**
* Superclass for all date documents in this library.
*
* @author croesch
* @since Date: Jul 4, 2011
*/
public abstract class DateContent extends CContent {
/** generated */
private static final long serialVersionUID = 6501226934436567798L;
/** the mode for entering date values */
public enum MODE {
/**
* Lazy mode:
*
* - no manipulation of user input
* - least validation of user input
* - most compliance with normal text fields
* - least automatic input of text field
*
* Normal comfortability but best understandability, least validity.
*/
LAZY,
/**
* Strict mode:
*
* - no manipulation of user input
* - highest validation of user input
* - Not a normal text field but not fully automatically.
* - some automatic input of text field
*
* Least comfortability, normal understandability, but best validity.
*/
// STRICT,
/**
* Auto mode:
*
* - most manipulation of user input
* - good validation of user input
* - Most of automation, might be confusing.
* - automatic input of text field
*
* Aim is good comfortability and validity, but least and understandability.
*/
/* AUTO */;
}
/**
* Creates a new instance of this {@link DateContent}. Will instantiate the specific subclass and return it.
*
* @since Date: Jul 6, 2011
* @param mode the edit mode for the {@link DateContent} to create
* @param tf the text field that is the owner of the {@link DateContent}
* @param loc the {@link Locale} to fetch the date format from.
* @return an instance of {@link DateContent} that is able to edit a date of the given locale in the given mode.
*/
public static final DateContent createDateContent(final MODE mode, final JTextComponent tf, final Locale loc) {
return new DateLazyContent(tf, loc);
}
/**
* Returns the {@link String} representation of the current value of the date field. Is ensured to be not
* null
and almost every time a fully date.
*
* @since Date: Jul 4, 2011
* @return {@link String} representation of the date currently stored in the content
*/
public abstract String getDateContent();
/**
* Set the current value of the date field to the given {@link Date}. Will remove the text in the field.
*
* @since Date: Jul 5, 2011
* @param d the {@link Date} to fetch the new values from.
*/
public abstract void setDate(Date d);
/**
* Returns the {@link Date} that is represented by the current value of the date field.
*
* @since Date: Jul 5, 2011
* @return {@link Date} that is equal to the values currently present in the date field.
*/
public abstract Date getDate();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy