Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.ujac.util.text
Class FormatHelper  view FormatHelper download FormatHelper.java

java.lang.Object
  extended byorg.ujac.util.text.FormatHelper

public class FormatHelper
extends java.lang.Object

Name: FormatHelper
Description: A helper class handling formatting objects.
Log: $Log: FormatHelper.java,v $
Log: Revision 1.9 2003/11/23 03:31:54 lauerc
Log: Fixed javadoc comments.
Log:
Log: Revision 1.8 2003/11/02 00:46:57 lauerc
Log: Fixed javadoc related documentation bugs.
Log:
Log: Revision 1.7 2003/11/01 12:06:38 lauerc
Log: Added copyright notice.
Log:
Log: Revision 1.6 2003/10/08 22:53:08 lauerc
Log: Changed visibility of format members.
Log:
Log: Revision 1.5 2003/10/07 05:27:39 lauerc
Log: Changed style of default time format to DEFAULT.
Log: Added clone method.
Log:
Log: Revision 1.4 2003/10/04 00:18:17 lauerc
Log: Improved localization.
Log:
Log: Revision 1.3 2003/10/03 07:00:19 lauerc
Log: Removed unneccessary import.
Log:
Log: Revision 1.2 2003/10/03 00:02:11 lauerc
Log: Added methods serving default formats for integers, decimals, Date, Time and Timestamp objects.
Log: Using class BigDecimalFormat for number formats now.
Log:
Log: Revision 1.1 2003/10/02 22:52:13 lauerc
Log: Initial revision.
Log:

Version:
$Revision: 1.9 $

Field Summary
static java.lang.String ATTRIBUTE_NAME
          Constant for the format helper attribute name, needed to store the format helper in the session or request.
protected  java.text.DateFormat dateFormat
          The date format.
protected  java.text.NumberFormat doubleFormat
          The floating point format.
protected  java.text.NumberFormat integerFormat
          The integer format.
protected  java.util.Locale locale
          The locale.
protected  java.text.DateFormat timeFormat
          The time format.
protected  java.text.DateFormat timestampFormat
          The timestamp format.
 
Constructor Summary
FormatHelper()
          Constructs a FormatHelper instance with no specific attributes.
FormatHelper(java.util.Locale locale)
          Constructs a FormatHelper instance with specific attributes.
 
Method Summary
 java.lang.Object clone()
          This method may be called to create a new copy of the Object.
 java.text.DateFormat createDateFormat(java.lang.String formatPattern)
          Creates a date format for the current locale.
 java.text.NumberFormat createNumberFormat(java.lang.String formatPattern)
          Creates a number format for the current locale.
 java.text.DateFormat getDateFormat()
          Gets the current date format.
 java.text.DateFormat getDefaultDateFormat(java.util.Locale locale)
          Gets the default date format for the given locale.
 java.text.NumberFormat getDefaultDoubleFormat(java.util.Locale locale)
          Gets the default double format for the given locale.
 java.text.NumberFormat getDefaultIntegerFormat(java.util.Locale locale)
          Gets the default integer format for the given locale.
 java.text.DateFormat getDefaultTimeFormat(java.util.Locale locale)
          Gets the default time format for the given locale.
 java.text.DateFormat getDefaultTimestampFormat(java.util.Locale locale)
          Gets the default timestamp format for the given locale.
 java.text.NumberFormat getDoubleFormat()
          Gets the current double format.
 java.text.NumberFormat getIntegerFormat()
          Gets the current integer format.
 java.util.Locale getLocale()
          Gets the used locale.
 java.text.DateFormat getTimeFormat()
          Gets the current time format.
 java.text.DateFormat getTimestampFormat()
          Gets the current timestamp format.
 void setDateFormat(java.text.DateFormat dateFormat)
          Sets the date format.
 java.text.DateFormat setDateFormat(java.lang.String formatPattern)
          Sets the date format.
 void setDoubleFormat(java.text.NumberFormat doubleFormat)
          Sets the double format.
 java.text.NumberFormat setDoubleFormat(java.lang.String formatPattern)
          Sets the double format.
 void setIntegerFormat(java.text.NumberFormat integerFormat)
          Sets the integer format.
 java.text.NumberFormat setIntegerFormat(java.lang.String formatPattern)
          Sets the integer format.
 void setTimeFormat(java.text.DateFormat timeFormat)
          Sets the timeFormat.
 java.text.DateFormat setTimeFormat(java.lang.String formatPattern)
          Sets the time format.
 void setTimestampFormat(java.text.DateFormat timestampFormat)
          Sets the timestampFormat.
 java.text.DateFormat setTimestampFormat(java.lang.String formatPattern)
          Sets the timestamp format.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTE_NAME

public static final java.lang.String ATTRIBUTE_NAME
Constant for the format helper attribute name, needed to store the format helper in the session or request.

See Also:
Constant Field Values

locale

protected java.util.Locale locale
The locale.


dateFormat

protected java.text.DateFormat dateFormat
The date format.


timeFormat

protected java.text.DateFormat timeFormat
The time format.


timestampFormat

protected java.text.DateFormat timestampFormat
The timestamp format.


integerFormat

protected java.text.NumberFormat integerFormat
The integer format.


doubleFormat

protected java.text.NumberFormat doubleFormat
The floating point format.

Constructor Detail

FormatHelper

public FormatHelper()
Constructs a FormatHelper instance with no specific attributes.


FormatHelper

public FormatHelper(java.util.Locale locale)
Constructs a FormatHelper instance with specific attributes.

Method Detail

getLocale

public java.util.Locale getLocale()
Gets the used locale.


getIntegerFormat

public java.text.NumberFormat getIntegerFormat()
Gets the current integer format.


setIntegerFormat

public void setIntegerFormat(java.text.NumberFormat integerFormat)
Sets the integer format.


setIntegerFormat

public java.text.NumberFormat setIntegerFormat(java.lang.String formatPattern)
Sets the integer format.


getDoubleFormat

public java.text.NumberFormat getDoubleFormat()
Gets the current double format.


setDoubleFormat

public void setDoubleFormat(java.text.NumberFormat doubleFormat)
Sets the double format.


setDoubleFormat

public java.text.NumberFormat setDoubleFormat(java.lang.String formatPattern)
Sets the double format.


getDateFormat

public java.text.DateFormat getDateFormat()
Gets the current date format.


setDateFormat

public void setDateFormat(java.text.DateFormat dateFormat)
Sets the date format.


setDateFormat

public java.text.DateFormat setDateFormat(java.lang.String formatPattern)
Sets the date format.


getTimeFormat

public java.text.DateFormat getTimeFormat()
Gets the current time format.


setTimeFormat

public void setTimeFormat(java.text.DateFormat timeFormat)
Sets the timeFormat.


setTimeFormat

public java.text.DateFormat setTimeFormat(java.lang.String formatPattern)
Sets the time format.


getTimestampFormat

public java.text.DateFormat getTimestampFormat()
Gets the current timestamp format.


setTimestampFormat

public void setTimestampFormat(java.text.DateFormat timestampFormat)
Sets the timestampFormat.


setTimestampFormat

public java.text.DateFormat setTimestampFormat(java.lang.String formatPattern)
Sets the timestamp format.


createNumberFormat

public java.text.NumberFormat createNumberFormat(java.lang.String formatPattern)
Creates a number format for the current locale.


createDateFormat

public java.text.DateFormat createDateFormat(java.lang.String formatPattern)
Creates a date format for the current locale.


getDefaultIntegerFormat

public java.text.NumberFormat getDefaultIntegerFormat(java.util.Locale locale)
Gets the default integer format for the given locale.


getDefaultDoubleFormat

public java.text.NumberFormat getDefaultDoubleFormat(java.util.Locale locale)
Gets the default double format for the given locale.


getDefaultDateFormat

public java.text.DateFormat getDefaultDateFormat(java.util.Locale locale)
Gets the default date format for the given locale.


getDefaultTimeFormat

public java.text.DateFormat getDefaultTimeFormat(java.util.Locale locale)
Gets the default time format for the given locale.


getDefaultTimestampFormat

public java.text.DateFormat getDefaultTimestampFormat(java.util.Locale locale)
Gets the default timestamp format for the given locale.


clone

public java.lang.Object clone()
Description copied from class: java.lang.Object
This method may be called to create a new copy of the Object. The typical behavior is as follows:
  • o == o.clone() is false
  • o.getClass() == o.clone().getClass() is true
  • o.equals(o) is true

However, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override Object.equals(Object)>Object.equals(Object) 55 .

If the Object you call clone() on does not implement java.lang.Cloneable (which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.

Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.

All array types implement Cloneable, and override this method as follows (it should never fail):

 public Object clone()
 {
   try
     {
       super.clone();
     }
   catch (CloneNotSupportedException e)
     {
       throw new InternalError(e.getMessage());
     }
 }