net.sf.springlayout.web.controller.propertyeditor
Class CalendarPropertyEditor

java.lang.Object
  extended by java.beans.PropertyEditorSupport
      extended by net.sf.springlayout.web.controller.propertyeditor.CalendarPropertyEditor
All Implemented Interfaces:
java.beans.PropertyEditor

public class CalendarPropertyEditor
extends java.beans.PropertyEditorSupport

A generic PropertyEditor for the referenceDataManager uses Invocation to invoke the method supplied.

Author:
monier

Constructor Summary
CalendarPropertyEditor(java.text.DateFormat dateFormat, boolean allowEmpty)
          Create a new CustomDateEditor instance, using the given DateFormat for parsing and rendering.
CalendarPropertyEditor(java.text.DateFormat dateFormat, boolean allowEmpty, int exactDateLength)
          Create a new CustomDateEditor instance, using the given DateFormat for parsing and rendering.
 
Method Summary
 java.lang.String getAsText()
          Format the Date as String, using the specified DateFormat.
 void setAsText(java.lang.String text)
          Parse the Calendar from the given text, using the specified DateFormat.
 
Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getCustomEditor, getJavaInitializationString, getSource, getTags, getValue, isPaintable, paintValue, removePropertyChangeListener, setSource, setValue, supportsCustomEditor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CalendarPropertyEditor

public CalendarPropertyEditor(java.text.DateFormat dateFormat,
                              boolean allowEmpty)
Create a new CustomDateEditor instance, using the given DateFormat for parsing and rendering.

The "allowEmpty" parameter states if an empty String should be allowed for parsing, i.e. get interpreted as null value. Otherwise, an IllegalArgumentException gets thrown in that case.

Parameters:
dateFormat - DateFormat to use for parsing and rendering
allowEmpty - if empty strings should be allowed

CalendarPropertyEditor

public CalendarPropertyEditor(java.text.DateFormat dateFormat,
                              boolean allowEmpty,
                              int exactDateLength)
Create a new CustomDateEditor instance, using the given DateFormat for parsing and rendering.

The "allowEmpty" parameter states if an empty String should be allowed for parsing, i.e. get interpreted as null value. Otherwise, an IllegalArgumentException gets thrown in that case.

The "exactDateLength" parameter states that IllegalArgumentException gets thrown if the String does not exactly match the length specified. This is useful because SimpleDateFormat does not enforce strict parsing of the year part, not even with setLenient(false). Without an "exactDateLength" specified, the "01/01/05" would get parsed to "01/01/0005".

Parameters:
dateFormat - DateFormat to use for parsing and rendering
allowEmpty - if empty strings should be allowed
exactDateLength - the exact expected length of the date String
Method Detail

setAsText

public void setAsText(java.lang.String text)
               throws java.lang.IllegalArgumentException
Parse the Calendar from the given text, using the specified DateFormat.

Specified by:
setAsText in interface java.beans.PropertyEditor
Overrides:
setAsText in class java.beans.PropertyEditorSupport
Throws:
java.lang.IllegalArgumentException

getAsText

public java.lang.String getAsText()
Format the Date as String, using the specified DateFormat.

Specified by:
getAsText in interface java.beans.PropertyEditor
Overrides:
getAsText in class java.beans.PropertyEditorSupport


Copyright © 2005-2007 Spring Layout Team. All Rights Reserved.