Ontimize 5.2072EN

com.ontimize.gui.field.document
Class HourDateDocument

java.lang.Object
  extended byjavax.swing.text.AbstractDocument
      extended byjavax.swing.text.PlainDocument
          extended bycom.ontimize.gui.field.document.DateDocument
              extended bycom.ontimize.gui.field.document.HourDateDocument
All Implemented Interfaces:
javax.swing.text.Document, Internationalization, java.io.Serializable

public class HourDateDocument
extends DateDocument

Document for managing hour and dates in same field. It is useful for table editors that map columns with timestamp values.

Since:
5.2059EN
Author:
Imatia Innovation SL
See Also:
{@link DateCellEditor}, Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.ontimize.gui.field.document.DateDocument
DateDocument.DateFormatCache, DateDocument.DateFormatCacheKey
 
Nested classes inherited from class javax.swing.text.AbstractDocument
javax.swing.text.AbstractDocument.AbstractElement, javax.swing.text.AbstractDocument.AttributeContext, javax.swing.text.AbstractDocument.BranchElement, javax.swing.text.AbstractDocument.Content, javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AbstractDocument.ElementEdit, javax.swing.text.AbstractDocument.LeafElement
 
Field Summary
static char charDateHourSeparator
           
protected  java.util.Date currentDocumentDate
          Date that stores the document for each moment.
protected static java.text.SimpleDateFormat dfHourDate
          Instance of date formatter
static java.lang.String HH_mm
          Default pattern for hours HH:mm
protected  boolean hourFirst
          Hour will be showed at first.
protected  boolean onlyHour
          It assigns a pattern to the document without date, only with hour.
protected  java.lang.String patternHour
          String with hour pattern
protected  java.lang.String patternHourDate
          String with hour and date patterns separated by charDateHourSeparator.
protected  java.lang.String sDateHourSeparator
           
 
Fields inherited from class com.ontimize.gui.field.document.DateDocument
currentDate, currentTimestamp, dateFormat, datePattern, DEBUG, defaultLocale, dfConstructor, insertedDate, locale
 
Fields inherited from class javax.swing.text.PlainDocument
lineLimitAttribute, tabSizeAttribute
 
Fields inherited from class javax.swing.text.AbstractDocument
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName
 
Fields inherited from interface com.ontimize.gui.i18n.Internationalization
DEBUG_LANGUAGE
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Constructor Summary
HourDateDocument()
          Constructor that creates a date document with hour and date, when hour is showed at first.
HourDateDocument(boolean onlyHour, boolean hourFirst)
           
 
Method Summary
protected  void buildHourDatePattern()
          Concatenates both patterns.
protected  void buildHourPattern()
          Builds hour pattern.
protected  void buildPattern()
          Builds pattern for date and hour.
 java.lang.String getText(int offset, int length)
           
 java.sql.Timestamp getTimestampValue()
           
 void insertString(int offset, java.lang.String sValue, javax.swing.text.AttributeSet attributes)
          Date pattern is known:
- Non numeric characters are allowed.
 boolean isValid()
          Pattern is valid when parsing returns a correct date.
 boolean isValidHour(java.lang.String sHour)
          Checks whether hour is valid.
 void setPattern(java.lang.String patternHourDate)
          Applies specified pattern to date formatter.
 void setValue(java.util.Date value)
           
 
Methods inherited from class com.ontimize.gui.field.document.DateDocument
format, getDate, getDatePattern, getFormat, getTextsToTranslate, getTimestampValue, insertStringWithoutCheck, isValid, setComponentLocale, setDatePattern, setResourceBundle
 
Methods inherited from class javax.swing.text.PlainDocument
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertUpdate, removeUpdate
 
Methods inherited from class javax.swing.text.AbstractDocument
addDocumentListener, addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeDocumentListener, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HH_mm

public static final java.lang.String HH_mm
Default pattern for hours HH:mm

See Also:
Constant Field Values

charDateHourSeparator

public static final char charDateHourSeparator
See Also:
Constant Field Values

sDateHourSeparator

protected java.lang.String sDateHourSeparator

patternHour

protected java.lang.String patternHour
String with hour pattern


patternHourDate

protected java.lang.String patternHourDate
String with hour and date patterns separated by charDateHourSeparator. Order of these patterns will be assigned according to variable hourFirst. By default, hour is showed at first.


currentDocumentDate

protected java.util.Date currentDocumentDate
Date that stores the document for each moment.


dfHourDate

protected static java.text.SimpleDateFormat dfHourDate
Instance of date formatter


onlyHour

protected boolean onlyHour
It assigns a pattern to the document without date, only with hour.


hourFirst

protected boolean hourFirst
Hour will be showed at first.

Constructor Detail

HourDateDocument

public HourDateDocument()
Constructor that creates a date document with hour and date, when hour is showed at first.


HourDateDocument

public HourDateDocument(boolean onlyHour,
                        boolean hourFirst)
Method Detail

insertString

public void insertString(int offset,
                         java.lang.String sValue,
                         javax.swing.text.AttributeSet attributes)
                  throws javax.swing.text.BadLocationException
Description copied from class: DateDocument
Date pattern is known:
- Non numeric characters are allowed.
- Year field has 4 characters (9999 maximum).
- Month and day fields have 2 characters. The maximum value for day is 31 and for month 12. An the minimum value for both is 1.
- When a value is introduced in field, this one is checked and text will be showed in red color until that the value is a correct date. Moreover, field value is also checked when field losts focus or ENTER key is pressed.
- Separator for dates is /. So a valid format date could be: 12/12/2008

Specified by:
insertString in interface javax.swing.text.Document
Overrides:
insertString in class DateDocument
Throws:
javax.swing.text.BadLocationException

buildPattern

protected void buildPattern()
Builds pattern for date and hour. Moreover, it concatenates both patterns.

Overrides:
buildPattern in class DateDocument

buildHourDatePattern

protected void buildHourDatePattern()
Concatenates both patterns.


setPattern

public void setPattern(java.lang.String patternHourDate)
Applies specified pattern to date formatter.

Parameters:
patternHourDate - The pattern to be applied.

buildHourPattern

protected void buildHourPattern()
Builds hour pattern.


isValid

public boolean isValid()
Pattern is valid when parsing returns a correct date.

Overrides:
isValid in class DateDocument

isValidHour

public boolean isValidHour(java.lang.String sHour)
Checks whether hour is valid.

Parameters:
sHour - String with hour
Returns:
True when hour is well formed according to the hour pattern

getText

public java.lang.String getText(int offset,
                                int length)
                         throws javax.swing.text.BadLocationException
Throws:
javax.swing.text.BadLocationException

setValue

public void setValue(java.util.Date value)
Overrides:
setValue in class DateDocument

getTimestampValue

public java.sql.Timestamp getTimestampValue()
Overrides:
getTimestampValue in class DateDocument

Ontimize