org.mmbase.datatypes
Class DateTimePattern.Element

java.lang.Object
  extended by org.mmbase.datatypes.DateTimePattern.Element
Enclosing class:
DateTimePattern

public static class DateTimePattern.Element
extends Object

A wrapper arround a field in a Calendar object. It provides a minimal and maximal value for the integer value, which can be requested by code which is producing a user interface to enter dates.


Field Summary
(package private)  int field
           
 
Constructor Summary
DateTimePattern.Element(String n, int field, int min, int max)
           
DateTimePattern.Element(String n, int field, int min, int max, int offset)
           
 
Method Summary
 int getField()
          The associated constant in Calendar, e.g.
 int getMax()
          The maximal value this field of the Calendar object can take.
 int getMin()
          The minimal value this field of the Calendar object can take.
 String getName()
          The name of the field in a Calendar object.
 int getNullValue()
          The int-value representing null.
 int getOffset()
          An offset to be used for presentation.
 int getValue(Calendar cal)
          Normally equivalent with cal.getValue(getField())
 String toString()
           
 String toString(int value, Locale locale, int length)
          Converts a value for the Calendar field associated with this Element to a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

field

final int field
Constructor Detail

DateTimePattern.Element

DateTimePattern.Element(String n,
                        int field,
                        int min,
                        int max)

DateTimePattern.Element

DateTimePattern.Element(String n,
                        int field,
                        int min,
                        int max,
                        int offset)
Method Detail

getName

public final String getName()
The name of the field in a Calendar object. Like e.g. 'day' or 'second'.


getField

public final int getField()
The associated constant in Calendar, e.g. Calendar.DAY_OF_MONTH or Calendar.SECOND


getMin

public final int getMin()
The minimal value this field of the Calendar object can take.


getMax

public final int getMax()
The maximal value this field of the Calendar object can take.


getOffset

public final int getOffset()
An offset to be used for presentation. E.g. months are represented by number from 0 to 11 in Calendar objects but you typically want to present 1 to 12, so the offset is 1 then.


getValue

public int getValue(Calendar cal)
Normally equivalent with cal.getValue(getField())

Returns:
The value for this element for a certain Calendar instance

toString

public String toString(int value,
                       Locale locale,
                       int length)
Converts a value for the Calendar field associated with this Element to a String. Typically used when creating optionlists.

Parameters:
value - the value to convert
locale - A locale can be used in some instances. E.g. to generate month names.
length - An indication of verboseness. Typically numeric results if a small number (perhaps filled to this length) or words if a big number (and it makes sense, e.g. for months, and weekdays).

toString

public String toString()
Overrides:
toString in class Object

getNullValue

public int getNullValue()
The int-value representing null. Some otherwise impossible value for the field. This can be use as a marker value in the option-list to set the calendar value to null.



MMBase 2.0-SNAPSHOT - null