KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > i18n > FormatDateTagSupport


1 /*
2  * Copyright 1999,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.taglibs.i18n;
18
19 import java.text.DateFormat JavaDoc;
20 import java.text.Format JavaDoc;
21 import java.util.Date JavaDoc;
22
23 /** Abstract base class which supports the defaulting of the value to 'now'
24   * if no other value is specified.
25   *
26   * @author James Strachan
27   * @version $Revision: 1.4 $
28   */

29 public abstract class FormatDateTagSupport extends FormatTagSupport {
30
31     private boolean initialised;
32     
33     public void release() {
34         super.release();
35         initialised = false;
36     }
37     
38     // Properties
39
//-------------------------------------------------------------------------
40
public Object JavaDoc getValue() {
41         if ( ! initialised ) {
42             // default to 'now' if no value has been specified
43
super.setValue( new Date JavaDoc() );
44             initialised = true;
45         }
46         return super.getValue();
47     }
48     
49     public void setValue( Object JavaDoc value ) {
50         super.setValue( value );
51         initialised = true;
52     }
53 }
54  
55
Popular Tags