jstrachan    01/04/28 08:05:45

  Modified:    i18n     build.xml
               i18n/conf taglib.tld
  Added:       i18n/examples/web format.jsp format_include.jsp
               i18n/src/org/apache/taglibs/i18n FormatCurrencyTag.java
                        FormatDateTag.java FormatDateTagSupport.java
                        FormatDateTimeTag.java FormatNumberTag.java
                        FormatPercentTag.java FormatTagSupport.java
                        FormatTimeTag.java LocaleTag.java
  Log:
  first alpha release of the new <i18n:formatXXX> tags as described on the taglibs-dev 
discussion list. they implement simple formatting using the Format, NumberFormat, 
DecimalNumberFormt, DateFormat, SimpleDateFormat classes. The sample web application 
demonstrates most combinations of these tags in action. Though I should improve the 
documentation and example a little.
  
  Revision  Changes    Path
  1.2       +202 -202  jakarta-taglibs/i18n/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/build.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.xml 2001/03/31 16:08:47     1.1
  +++ build.xml 2001/04/28 15:05:42     1.2
  @@ -1,202 +1,202 @@
  -<!-- ANT Build Script for the "jspspec" Custom Tag Library -->
  -<!-- $Id: build.xml,v 1.1 2001/03/31 16:08:47 glenn Exp $ -->
  -<project name="i18n" default="main" basedir=".">
  -
  -    <!-- ******************** Adjustable Properties *********************** -->
  -
  -    <!--
  -
  -        The following property values should be examined and customized
  -     for each custom tag library subproject.
  -
  -     ant.home                    Home directory for the ANT build tool
  -                                 This is normally defaulted from the
  -                                 ANT_HOME environment variable in the
  -                                 build script.
  -
  -     servlet.jar                 Pathname of the servlet API classes
  -                                 you are using to compile, such as the
  -                                 one that comes with Tomcat.  This is
  -                                 normally defaulted from the SERVLET_JAR
  -                                 environment variable in the build script.
  -
  -        taglib.name              Base name of this tag library subproject.
  -
  -    -->
  -
  -    <property name="taglib.name"    value="i18n"/>
  -
  -    <!-- ****************** Project Standard Properties ******************* -->
  -
  -    <!--
  -
  -        The following property values reflect the standard directory
  -     organization for the jakarta-taglibs project, and should not
  -     be changed or overridden.
  -
  -     build.dir                   Base directory for build targets
  -     dist.dir                    Base directory for distribution targets
  -        taglibs.xsl                 Taglibs stylesheet
  -
  -    -->
  -
  -    <property name="build.dir"      value="../../build/taglibs"/>
  -    <property name="dist.dir"       value="../../dist/taglibs"/>
  -    <property name="taglibs.xsl"    
value="../../../src/doc/stylesheets/taglibs.xsl"/>
  -
  -    <!-- *********************** Default Properties ********************** -->
  -
  -    <!--
  -
  -        The following property values reflect the recommended directory
  -     structure for each custom tag library subproject.  You should only
  -     need to adjust or override them if you use a different organization.
  -
  -     conf.src                    Library configuration source directory
  -        doc.src                     Documentation app source directory
  -        examples.src                Examples app source directory
  -        library.src                 Library Java source directory
  -
  -    -->
  -
  -    <property name="conf.src"       value="conf"/>
  -    <property name="doc.src"        value="doc"/>
  -    <property name="examples.src"   value="examples"/>
  -    <property name="library.src"    value="src"/>
  -
  -
  -    <!-- ********************* Derived Properties ************************* -->
  -
  -    <!--
  -
  -        These property values are derived from the previously defined values,
  -     and should not normally be overridden from the command line.
  -
  -        build.doc                   Target directory for documentation app
  -        build.examples                   Target directory for examples app
  -        build.library               Target directory for tag library
  -     dist.doc                    Destination WAR for documentation app
  -     dist.examples               Destination WAR for examples app
  -     dist.library                Destination JAR for tag library
  -     dist.tld                    Destination TLD file for tag library
  -
  -    -->
  -
  -    <property name="build.doc"      value="${build.dir}/${taglib.name}-doc"/>
  -    <property name="build.examples" value="${build.dir}/${taglib.name}-examples"/>
  -    <property name="build.library"  value="${build.dir}/${taglib.name}"/>
  -    <property name="dist.doc"       
value="${dist.dir}/${taglib.name}/${taglib.name}-doc.war"/>
  -    <property name="dist.examples"  
value="${dist.dir}/${taglib.name}/${taglib.name}-examples.war"/>
  -    <property name="dist.library"   
value="${dist.dir}/${taglib.name}/${taglib.name}.jar"/>
  -    <property name="dist.tld"       
value="${dist.dir}/${taglib.name}/${taglib.name}.tld"/>
  -
  -
  -  <!-- ********************** Destination Preparation ********************* -->
  -
  -  <target name="prepare">
  -    <!-- Set up build directories -->
  -    <mkdir dir="${build.dir}"/>
  -    <mkdir dir="${build.doc}"/>
  -    <mkdir dir="${build.doc}/WEB-INF"/>
  -    <mkdir dir="${build.doc}/WEB-INF/classes"/>
  -    <mkdir dir="${build.doc}/WEB-INF/lib"/>
  -    <mkdir dir="${build.examples}"/>
  -    <mkdir dir="${build.examples}/WEB-INF"/>
  -    <mkdir dir="${build.examples}/WEB-INF/classes"/>
  -    <mkdir dir="${build.examples}/WEB-INF/lib"/>
  -    <mkdir dir="${build.library}"/>
  -    <mkdir dir="${build.library}/META-INF"/>
  -    <!-- Set up distribution directory -->
  -    <mkdir dir="${dist.dir}"/>
  -    <mkdir dir="${dist.dir}/${taglib.name}"/>
  -  </target>
  -
  -
  -  <!-- **************** Compile Tag Library Components ******************** -->
  -
  -  <!-- Compile the documentation application -->
  -  <target name="documentation" depends="prepare">
  -    <copy todir="${build.doc}/WEB-INF">
  -      <fileset dir="${doc.src}/conf"/>
  -    </copy>
  -    <style basedir="${doc.src}/web" destdir="${build.doc}"
  -      extension=".html" style="${taglibs.xsl}" includes="*.xml"/>
  -    <copy todir="${build.doc}">
  -      <fileset dir="${doc.src}/web">
  -        <include name="**/*.html"/>
  -      </fileset>
  -    </copy>
  -  <!--
  -    <javac srcdir="${doc.src}/src"   destdir="${build.doc}/WEB-INF/classes"
  -           classpath="${servlet.jar}" debug="on"/>
  -    -->
  -  </target>
  -
  -  <!-- Compile the examples application -->
  -  <target name="examples" depends="library-dist">
  -    <copy toDir="${build.examples}/WEB-INF">
  -      <fileset dir="${examples.src}/conf"/>
  -    </copy>
  -    <copy toDir="${build.examples}">
  -      <fileset dir="${examples.src}/web"/>
  -    </copy>
  -    <copy file="${dist.tld}"
  -          toFile="${build.examples}/WEB-INF/${taglib.name}.tld"/>
  -    <copy file="${dist.library}"
  -          toFile="${build.examples}/WEB-INF/lib/${taglib.name}.jar"/>
  -    <javac srcdir="${examples.src}/src"
  -           destdir="${build.examples}/WEB-INF/classes"
  -           classpath="${servlet.jar}" debug="on"/>
  -    <copy todir="${build.examples}/WEB-INF/classes">
  -      <fileset dir="${examples.src}/src">
  -        <include name="**/*.properties"/>
  -      </fileset>
  -    </copy>
  -  </target>
  -
  -  <!-- Compile the tag library itself -->
  -  <target name="library" depends="prepare">
  -    <copy file="${conf.src}/taglib.tld"
  -          toFile="${build.library}/META-INF/taglib.tld"/>
  -    <javac srcdir="${library.src}" destdir="${build.library}"
  -           classpath="${servlet.jar}" debug="on"/>
  -  </target>
  -
  -  <!-- Compile the library as well as the associated applications -->
  -  <target name="main" depends="library,documentation,examples"/>
  -
  -
  -  <!-- ******************* Create Distribution Files ********************** -->
  -
  -  <!-- Create the documentation application WAR file -->
  -  <target name="documentation-dist" depends="documentation">
  -    <jar jarfile="${dist.doc}" basedir="${build.doc}"/>
  -  </target>
  -
  -  <!-- Create the examples application WAR file -->
  -  <target name="examples-dist" depends="examples">
  -    <jar jarfile="${dist.examples}" basedir="${build.examples}"/>
  -  </target>
  -
  -  <!-- Create the library distribution files -->
  -  <target name="library-dist" depends="library">
  -    <jar jarfile="${dist.library}" basedir="${build.library}"/>
  -    <copy file="${conf.src}/taglib.tld" toFile="${dist.tld}"/>
  -  </target>
  -
  -  <!-- Create the entire set of distribution files -->
  -  <target name="dist" depends="library-dist,examples-dist,documentation-dist"/>
  -
  -
  -
  -  <!-- ************************ Utility Commands ************************** -->
  -
  -  <!-- Delete output directories and files so we can build from scratch -->
  -  <target name="clean">
  -    <delete dir="${build.doc}"/>
  -    <delete dir="${build.examples}"/>
  -    <delete dir="${build.library}"/>
  -    <delete dir="${dist.dir}/${taglib.name}"/>
  -  </target>
  -
  -</project>
  +<!-- ANT Build Script for the "jspspec" Custom Tag Library -->
  +<!-- $Id: build.xml,v 1.2 2001/04/28 15:05:42 jstrachan Exp $ -->
  +<project name="i18n" default="main" basedir=".">
  +
  +    <!-- ******************** Adjustable Properties *********************** -->
  +
  +    <!--
  +
  +        The following property values should be examined and customized
  +     for each custom tag library subproject.
  +
  +     ant.home                    Home directory for the ANT build tool
  +                                 This is normally defaulted from the
  +                                 ANT_HOME environment variable in the
  +                                 build script.
  +
  +     servlet.jar                 Pathname of the servlet API classes
  +                                 you are using to compile, such as the
  +                                 one that comes with Tomcat.  This is
  +                                 normally defaulted from the SERVLET_JAR
  +                                 environment variable in the build script.
  +
  +        taglib.name              Base name of this tag library subproject.
  +
  +    -->
  +
  +    <property name="taglib.name"    value="i18n"/>
  +
  +    <!-- ****************** Project Standard Properties ******************* -->
  +
  +    <!--
  +
  +        The following property values reflect the standard directory
  +     organization for the jakarta-taglibs project, and should not
  +     be changed or overridden.
  +
  +     build.dir                   Base directory for build targets
  +     dist.dir                    Base directory for distribution targets
  +        taglibs.xsl                 Taglibs stylesheet
  +
  +    -->
  +
  +    <property name="build.dir"      value="../../build/taglibs"/>
  +    <property name="dist.dir"       value="../../dist/taglibs"/>
  +    <property name="taglibs.xsl"    
value="../../../src/doc/stylesheets/taglibs.xsl"/>
  +
  +    <!-- *********************** Default Properties ********************** -->
  +
  +    <!--
  +
  +        The following property values reflect the recommended directory
  +     structure for each custom tag library subproject.  You should only
  +     need to adjust or override them if you use a different organization.
  +
  +     conf.src                    Library configuration source directory
  +        doc.src                     Documentation app source directory
  +        examples.src                Examples app source directory
  +        library.src                 Library Java source directory
  +
  +    -->
  +
  +    <property name="conf.src"       value="conf"/>
  +    <property name="doc.src"        value="doc"/>
  +    <property name="examples.src"   value="examples"/>
  +    <property name="library.src"    value="src"/>
  +
  +
  +    <!-- ********************* Derived Properties ************************* -->
  +
  +    <!--
  +
  +        These property values are derived from the previously defined values,
  +     and should not normally be overridden from the command line.
  +
  +        build.doc                   Target directory for documentation app
  +        build.examples                   Target directory for examples app
  +        build.library               Target directory for tag library
  +     dist.doc                    Destination WAR for documentation app
  +     dist.examples               Destination WAR for examples app
  +     dist.library                Destination JAR for tag library
  +     dist.tld                    Destination TLD file for tag library
  +
  +    -->
  +
  +    <property name="build.doc"      value="${build.dir}/${taglib.name}-doc"/>
  +    <property name="build.examples" value="${build.dir}/${taglib.name}-examples"/>
  +    <property name="build.library"  value="${build.dir}/${taglib.name}"/>
  +    <property name="dist.doc"       
value="${dist.dir}/${taglib.name}/${taglib.name}-doc.war"/>
  +    <property name="dist.examples"  
value="${dist.dir}/${taglib.name}/${taglib.name}-examples.war"/>
  +    <property name="dist.library"   
value="${dist.dir}/${taglib.name}/${taglib.name}.jar"/>
  +    <property name="dist.tld"       
value="${dist.dir}/${taglib.name}/${taglib.name}.tld"/>
  +
  +
  +  <!-- ********************** Destination Preparation ********************* -->
  +
  +  <target name="prepare">
  +    <!-- Set up build directories -->
  +    <mkdir dir="${build.dir}"/>
  +    <mkdir dir="${build.doc}"/>
  +    <mkdir dir="${build.doc}/WEB-INF"/>
  +    <mkdir dir="${build.doc}/WEB-INF/classes"/>
  +    <mkdir dir="${build.doc}/WEB-INF/lib"/>
  +    <mkdir dir="${build.examples}"/>
  +    <mkdir dir="${build.examples}/WEB-INF"/>
  +    <mkdir dir="${build.examples}/WEB-INF/classes"/>
  +    <mkdir dir="${build.examples}/WEB-INF/lib"/>
  +    <mkdir dir="${build.library}"/>
  +    <mkdir dir="${build.library}/META-INF"/>
  +    <!-- Set up distribution directory -->
  +    <mkdir dir="${dist.dir}"/>
  +    <mkdir dir="${dist.dir}/${taglib.name}"/>
  +  </target>
  +
  +
  +  <!-- **************** Compile Tag Library Components ******************** -->
  +
  +  <!-- Compile the documentation application -->
  +  <target name="documentation" depends="prepare">
  +    <copy todir="${build.doc}/WEB-INF">
  +      <fileset dir="${doc.src}/conf"/>
  +    </copy>
  +    <style basedir="${doc.src}/web" destdir="${build.doc}"
  +      extension=".html" style="${taglibs.xsl}" includes="*.xml"/>
  +    <copy todir="${build.doc}">
  +      <fileset dir="${doc.src}/web">
  +        <include name="**/*.html"/>
  +      </fileset>
  +    </copy>
  +  <!--
  +    <javac srcdir="${doc.src}/src"   destdir="${build.doc}/WEB-INF/classes"
  +           classpath="${servlet.jar}" debug="on"/>
  +    -->
  +  </target>
  +
  +  <!-- Compile the examples application -->
  +  <target name="examples" depends="library-dist">
  +    <copy toDir="${build.examples}/WEB-INF">
  +      <fileset dir="${examples.src}/conf"/>
  +    </copy>
  +    <copy toDir="${build.examples}" overwrite="yes">
  +      <fileset dir="${examples.src}/web"/>
  +    </copy>
  +    <copy file="${dist.tld}"
  +          toFile="${build.examples}/WEB-INF/${taglib.name}.tld"/>
  +    <copy file="${dist.library}"
  +          toFile="${build.examples}/WEB-INF/lib/${taglib.name}.jar"/>
  +    <javac srcdir="${examples.src}/src"
  +           destdir="${build.examples}/WEB-INF/classes"
  +           classpath="${servlet.jar}" debug="on"/>
  +    <copy todir="${build.examples}/WEB-INF/classes">
  +      <fileset dir="${examples.src}/src">
  +        <include name="**/*.properties"/>
  +      </fileset>
  +    </copy>
  +  </target>
  +
  +  <!-- Compile the tag library itself -->
  +  <target name="library" depends="prepare">
  +    <copy file="${conf.src}/taglib.tld"
  +          toFile="${build.library}/META-INF/taglib.tld"/>
  +    <javac srcdir="${library.src}" destdir="${build.library}"
  +           classpath="${servlet.jar}" debug="on"/>
  +  </target>
  +
  +  <!-- Compile the library as well as the associated applications -->
  +  <target name="main" depends="library,documentation,examples"/>
  +
  +
  +  <!-- ******************* Create Distribution Files ********************** -->
  +
  +  <!-- Create the documentation application WAR file -->
  +  <target name="documentation-dist" depends="documentation">
  +    <jar jarfile="${dist.doc}" basedir="${build.doc}"/>
  +  </target>
  +
  +  <!-- Create the examples application WAR file -->
  +  <target name="examples-dist" depends="examples">
  +    <jar jarfile="${dist.examples}" basedir="${build.examples}"/>
  +  </target>
  +
  +  <!-- Create the library distribution files -->
  +  <target name="library-dist" depends="library">
  +    <jar jarfile="${dist.library}" basedir="${build.library}"/>
  +    <copy file="${conf.src}/taglib.tld" toFile="${dist.tld}"/>
  +  </target>
  +
  +  <!-- Create the entire set of distribution files -->
  +  <target name="dist" depends="library-dist,examples-dist,documentation-dist"/>
  +
  +
  +
  +  <!-- ************************ Utility Commands ************************** -->
  +
  +  <!-- Delete output directories and files so we can build from scratch -->
  +  <target name="clean">
  +    <delete dir="${build.doc}"/>
  +    <delete dir="${build.examples}"/>
  +    <delete dir="${build.library}"/>
  +    <delete dir="${dist.dir}/${taglib.name}"/>
  +  </target>
  +
  +</project>
  
  
  
  1.2       +346 -84   jakarta-taglibs/i18n/conf/taglib.tld
  
  Index: taglib.tld
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/conf/taglib.tld,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- taglib.tld        2001/03/31 16:08:47     1.1
  +++ taglib.tld        2001/04/28 15:05:42     1.2
  @@ -1,84 +1,346 @@
  -<?xml version="1.0" encoding="ISO-8859-1" ?>
  -<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" 
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd";>
  -
  -<taglib>
  -  <tlibversion>1.0</tlibversion>
  -  <jspversion>1.1</jspversion>
  -  <shortname>is.com</shortname>
  -  <info>
  -    These are WAM!NET internationalization tags.
  -  </info>
  -
  -  <tag>
  -    <name>bundle</name>
  -    <tagclass>org.apache.taglibs.i18n.BundleTag</tagclass>
  -    <info>Must be placed in a JSP before any other i18n tags.</info>
  -    <attribute>
  -      <name>baseName</name>
  -      <required>true</required>
  -    </attribute>
  -    <attribute>
  -      <name>locale</name>
  -      <required>false</required>
  -      <rtexprvalue>true</rtexprvalue>
  -    </attribute>
  -    <attribute>
  -      <name>localeAttribute</name>
  -      <required>false</required>
  -      <rtexprvalue>true</rtexprvalue>
  -    </attribute>
  -  </tag>
  -
  -  <tag>
  -    <name>message</name>
  -    <tagclass>org.apache.taglibs.i18n.MessageTag</tagclass>
  -    <bodycontent>JSP</bodycontent>
  -    <info>Must occur after a localize tag.</info>
  -    <attribute>
  -      <name>key</name>
  -      <required>true</required>
  -      <rtexprvalue>true</rtexprvalue>
  -    </attribute>
  -    <attribute>
  -      <name>args</name>
  -      <required>false</required>
  -      <rtexprvalue>true</rtexprvalue>
  -    </attribute>
  -  </tag>
  -
  -  <tag>
  -    <name>messageArg</name>
  -    <tagclass>org.apache.taglibs.i18n.MessageArgumentTag</tagclass>
  -    <info>Must be nested inside a message tag.</info>
  -    <attribute>
  -      <name>value</name>
  -      <required>true</required>
  -      <rtexprvalue>true</rtexprvalue>
  -    </attribute>
  -  </tag>
  -
  -  <tag>
  -    <name>ifdef</name>
  -    <tagclass>org.apache.taglibs.i18n.IfdefTag</tagclass>
  -    <bodycontent>JSP</bodycontent>
  -    <info>Must occur after a localize tag.</info>
  -    <attribute>
  -      <name>key</name>
  -      <required>true</required>
  -      <rtexprvalue>true</rtexprvalue>
  -    </attribute>
  -  </tag>
  -
  -  <tag>
  -    <name>ifndef</name>
  -    <tagclass>org.apache.taglibs.i18n.IfndefTag</tagclass>
  -    <bodycontent>JSP</bodycontent>
  -    <info>Must occur after a localize tag.</info>
  -    <attribute>
  -      <name>key</name>
  -      <required>true</required>
  -      <rtexprvalue>true</rtexprvalue>
  -    </attribute>
  -  </tag>
  -
  -</taglib>
  +<?xml version="1.0" encoding="ISO-8859-1" ?>
  +<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" 
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd";>
  +
  +<taglib>
  +  <tlibversion>1.0</tlibversion>
  +  <jspversion>1.1</jspversion>
  +  <shortname>i18n</shortname>
  +  <info>
  +    These are WAM!NET internationalization tags.
  +  </info>
  +
  +  <tag>
  +    <name>bundle</name>
  +    <tagclass>org.apache.taglibs.i18n.BundleTag</tagclass>
  +    <info>Must be placed in a JSP before any other i18n tags.</info>
  +    <attribute>
  +      <name>baseName</name>
  +      <required>true</required>
  +    </attribute>
  +    <attribute>
  +      <name>locale</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>localeAttribute</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +  <tag>
  +    <name>message</name>
  +    <tagclass>org.apache.taglibs.i18n.MessageTag</tagclass>
  +    <bodycontent>JSP</bodycontent>
  +    <info>Must occur after a localize tag.</info>
  +    <attribute>
  +      <name>key</name>
  +      <required>true</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>args</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +  <tag>
  +    <name>messageArg</name>
  +    <tagclass>org.apache.taglibs.i18n.MessageArgumentTag</tagclass>
  +    <info>Must be nested inside a message tag.</info>
  +    <attribute>
  +      <name>value</name>
  +      <required>true</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +  <tag>
  +    <name>ifdef</name>
  +    <tagclass>org.apache.taglibs.i18n.IfdefTag</tagclass>
  +    <bodycontent>JSP</bodycontent>
  +    <info>Must occur after a localize tag.</info>
  +    <attribute>
  +      <name>key</name>
  +      <required>true</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +  <tag>
  +    <name>ifndef</name>
  +    <tagclass>org.apache.taglibs.i18n.IfndefTag</tagclass>
  +    <bodycontent>JSP</bodycontent>
  +    <info>Must occur after a localize tag.</info>
  +    <attribute>
  +      <name>key</name>
  +      <required>true</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +
  +  <!-- new formatting tags --> 
  +
  +  <tag>
  +    <name>locale</name>
  +    <tagclass>org.apache.taglibs.i18n.LocaleTag</tagclass>
  +    <bodycontent>JSP</bodycontent>
  +    <info>
  +        Defines a locale context. This is either sepecified using the 
  +        locale property, the combination of 'language', 'country' and 
  +        the optional 'variant' property or the current HTTP request is used.
  +        If no other locale can be found then the default JVM locale is used.
  +        Other sub-tags will use this locale if no other locale is specified.
  +    </info>
  +    <attribute>
  +      <name>locale</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>language</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>country</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>variant</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +  <tag>
  +    <name>formatNumber</name>
  +    <tagclass>org.apache.taglibs.i18n.FormatNumberTag</tagclass>
  +    <bodycontent>JSP</bodycontent>
  +    <info>
  +        Formats a number using a locale.
  +
  +        A pattern can be specified such as '##,###.##'.
  +
  +        If the value is null then the default text is used.
  +
  +        If no locale is specified then the parent &lt;i18n:locale&gt; tag is used.
  +        If no parent &lt;i18n:locale&gt; tag exists then the locale is taken from 
the
  +        current request. If still no locale could be found then the 
  +        current JVM locale is used.
  +    </info>
  +    <attribute>
  +      <name>value</name>
  +      <required>true</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>pattern</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>locale</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>defaultText</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +  <tag>
  +    <name>formatCurrency</name>
  +    <tagclass>org.apache.taglibs.i18n.FormatCurrencyTag</tagclass>
  +    <bodycontent>JSP</bodycontent>
  +    <info>
  +        Formats a number as a currency using a locale.
  +
  +        If the value is null then the default text is used.
  +
  +        If no locale is specified then the parent &lt;i18n:locale&gt; tag is used.
  +        If no parent &lt;i18n:locale&gt; tag exists then the locale is taken from 
the
  +        current request. If still no locale could be found then the 
  +        current JVM locale is used.
  +    </info>
  +    <attribute>
  +      <name>value</name>
  +      <required>true</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>locale</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>defaultText</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +  <tag>
  +    <name>formatPercent</name>
  +    <tagclass>org.apache.taglibs.i18n.FormatPercentTag</tagclass>
  +    <bodycontent>JSP</bodycontent>
  +    <info>
  +        Formats a number as a percentage using a locale.
  +
  +        If the value is null then the default text is used.
  +
  +        If no locale is specified then the parent &lt;i18n:locale&gt; tag is used.
  +        If no parent &lt;i18n:locale&gt; tag exists then the locale is taken from 
the
  +        current request. If still no locale could be found then the 
  +        current JVM locale is used.
  +    </info>
  +    <attribute>
  +      <name>value</name>
  +      <required>true</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>locale</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>defaultText</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +  <tag>
  +    <name>formatDate</name>
  +    <tagclass>org.apache.taglibs.i18n.FormatDateTag</tagclass>
  +    <bodycontent>JSP</bodycontent>
  +    <info>
  +        Formats a Date value as a time using a locale.
  +
  +        A style (short/medium/long/full) can be specified
  +        or a pattern such as 'YYYY MMM ddd'.
  +
  +        If the value is null then the default text is used.
  +
  +        If no locale is specified then the parent &lt;i18n:locale&gt; tag is used.
  +        If no parent &lt;i18n:locale&gt; tag exists then the locale is taken from 
the
  +        current request. If still no locale could be found then the 
  +        current JVM locale is used.
  +    </info>
  +    <attribute>
  +      <name>value</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>style</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>pattern</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>locale</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>defaultText</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +
  +  <tag>
  +    <name>formatDateTime</name>
  +    <tagclass>org.apache.taglibs.i18n.FormatDateTimeTag</tagclass>
  +    <bodycontent>JSP</bodycontent>
  +    <info>
  +        Formats a Date value as a date-time using a locale.
  +
  +        A dateStyle and a timeStyle (short/medium/long/full) can be specified.
  +
  +        If the value is null then the default text is used.
  +
  +        If no locale is specified then the parent &lt;i18n:locale&gt; tag is used.
  +        If no parent &lt;i18n:locale&gt; tag exists then the locale is taken from 
the
  +        current request. If still no locale could be found then the 
  +        current JVM locale is used.
  +    </info>
  +    <attribute>
  +      <name>value</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>dateStyle</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>timeStyle</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>locale</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>defaultText</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +  <tag>
  +    <name>formatTime</name>
  +    <tagclass>org.apache.taglibs.i18n.FormatTimeTag</tagclass>
  +    <bodycontent>JSP</bodycontent>
  +    <info>
  +        Formats a Date value as a time using a locale.
  +
  +        A style (short/medium/long/full) can be specified.
  +
  +        If the value is null then the default text is used.
  +
  +        If no locale is specified then the parent &lt;i18n:locale&gt; tag is used.
  +        If no parent &lt;i18n:locale&gt; tag exists then the locale is taken from 
the
  +        current request. If still no locale could be found then the 
  +        current JVM locale is used.
  +    </info>
  +    <attribute>
  +      <name>value</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>style</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>locale</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +      <name>defaultText</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +</taglib>
  
  
  
  1.1                  jakarta-taglibs/i18n/examples/web/format.jsp
  
  Index: format.jsp
  ===================================================================
  <%--
    this page contains a variety of demonstrations of the <i18n:formatXXX> tags
  --%>
  <%@ taglib uri="http://jakarta.apache.org/taglibs/i18n-1.0"; prefix="i18n" %>
  <%@ page import="java.util.Date" %>
  <%@ page import="java.util.Locale" %>
  <html>
  <head>
  <title>Examples of using the Formatting tags in the i18n Tag Library Tag</title>
  </head>
  <body>
  
  <%
      Number n = new Double( 1234567.89 );
      Date d = new Date();
  %>
  
  
  <h2>US Locale</h2>
  
  <i18n:locale locale="<%= Locale.US %>">
  
  <%@ include file="format_include.jsp" %>
  
  </i18n:locale>
  
  
  <h2>FRANCE Locale</h2>
  
  <i18n:locale locale="<%= Locale.FRANCE %>">
  
  <%@ include file="format_include.jsp" %>
  
  </i18n:locale>
  
  
  <h2>Default Request Locale</h2>
  
  <%@ include file="format_include.jsp" %>
  
  
  <%
      String country = request.getParameter( "country" );
      if ( country == null ) {
          country = "CH";
      }
      String language = request.getParameter( "language" );
      if ( language == null ) {
          language = "fr";
      }
  %>
  
  <h2>Country: <%= country %> and Language: <%= language %></h2>
  
  <i18n:locale country="<%= country %>" language="<%= language %>">
  
  <%@ include file="format_include.jsp" %>
  
  </i18n:locale>
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-taglibs/i18n/examples/web/format_include.jsp
  
  Index: format_include.jsp
  ===================================================================
  <h3>The time is now:-</h3>
  
  <ul>
  <li>
      <i18n:formatTime/> (default)
  </li>
  <li>
      <i18n:formatTime style="short"/> (short)
  </li>
  <li>
      <i18n:formatTime style="medium"/> (medium)
  </li>
  <li>
      <i18n:formatTime style="full"/> (full)
  </li>
  </ul>
  
  
  <h3>The date is now:-</h3>
  
  <ul>
  <li>
      <i18n:formatDate/> (default)
  </li>
  <li>
      <i18n:formatDate pattern="yyyy MMMMM ddd hh:mm:ss"/> (pattern)
  </li>
  <li>
      <i18n:formatDate style="short"/> (short)
  </li>
  <li>
      <i18n:formatDate style="medium"/> (medium)
  </li>
  <li>
      <i18n:formatDate style="full"/> (full)
  </li>
  </ul>
  
  
  <h3>The datetime is now:-</h3>
  
  <ul>
  <li>
      <i18n:formatDateTime/> (default)
  </li>
  <li>
      <i18n:formatDateTime dateStyle="short" timeStyle="short"/> (short, short)
  </li>
  <li>
      <i18n:formatDateTime dateStyle="medium" timeStyle="medium"/> (medium, medium)
  </li>
  <li>
      <i18n:formatDateTime dateStyle="full" timeStyle="full"/> (full, full)
  </li>
  </ul>
  
  
  <h3>The number is:-</h3>
  
  <ul>
  <li>
      <i18n:formatNumber value="<%= n %>"/> (number)
  </li>
  <li>
      <i18n:formatNumber value="<%= n %>" pattern="##,###,###.##"/> (number with 
pattern)
  </li>
  <li>
      <i18n:formatCurrency value="<%= n %>"/> (currency)
  </li>
  <li>
      <i18n:formatPercent value="<%= n %>"/> (percent)
  </li>
  </ul>
  
  
  
  
  
  
  1.1                  
jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatCurrencyTag.java
  
  Index: FormatCurrencyTag.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatCurrencyTag.java,v 
1.1 2001/04/28 15:05:44 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2001/04/28 15:05:44 $
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.taglibs.i18n;
  
  import java.text.Format;
  import java.text.NumberFormat;
  
  /** Formats a {@link Number} instance using the current {@link Locale} 
    * and the Currency {@link NumberFormat}.
    *
    * @author James Strachan
    * @version $Revision: 1.1 $
    */
  public class FormatCurrencyTag extends FormatTagSupport {
  
      public FormatCurrencyTag() {
      }
      
      // Implementation methods
      //-------------------------------------------------------------------------
      protected Format getFormat() {
          return NumberFormat.getCurrencyInstance( getLocale() );
      }
  }
  
  
  
  1.1                  
jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatDateTag.java
  
  Index: FormatDateTag.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatDateTag.java,v 1.1 
2001/04/28 15:05:44 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2001/04/28 15:05:44 $
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.taglibs.i18n;
  
  import java.text.DateFormat;
  import java.text.Format;
  import java.text.SimpleDateFormat;
  import java.util.Date;
  
  /** Formats a {@link Date} instance using a {@link Locale} and either a 
    * {@link DateFormat} or a pattern based {@link SimpleDateFormat}.
    *
    * @author James Strachan
    * @version $Revision: 1.1 $
    */
  public class FormatDateTag extends FormatDateTagSupport {
      
      private Format format;
      private String pattern;
      private int style = DateFormat.SHORT;
      
  
      public FormatDateTag() {
      }
      
  
      // Tag interface
      //-------------------------------------------------------------------------
      public void release() {
          super.release();
          format = null;
          pattern = null;
      }
      
      // Properties
      //-------------------------------------------------------------------------
      
      /** If no {@link DateFormat} is configured then use a 
        * {@link SimpleDateFormat} instance if a pattern is configured else
        * use the default DateFormat for the {@link Locale}
        */
      public Format getFormat() {
          if ( format == null ) {
              String pattern = getPattern();
              if ( pattern != null ) {
                  format = getPatternFormat( pattern );
              }
              if ( pattern == null ) {
                  format = getDateFormat();
              }
          }
          return format;
      }
  
      public void setFormat( DateFormat format ) {
          this.format = format;
      }
  
      public String getPattern() {
          return pattern;
      }
      
      public void setPattern( String pattern ) {
          this.pattern = pattern;
      }
  
      public void setStyle( String style ) {
          this.style = getStyleCode( style );
      }
      
      
      // Implementation methods
      //-------------------------------------------------------------------------
      protected DateFormat getPatternFormat( String pattern ) {
          // XXXX: Use a Locale based cache for these objects as per Craig's 
          // XXXX: suggestion        
          return new SimpleDateFormat( pattern, getLocale() );
      }
      
      protected DateFormat getDateFormat() {
          return DateFormat.getDateInstance( style, getLocale() );
      }
      
  }
  
  
  
  1.1                  
jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatDateTagSupport.java
  
  Index: FormatDateTagSupport.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatDateTagSupport.java,v 
1.1 2001/04/28 15:05:44 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2001/04/28 15:05:44 $
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.taglibs.i18n;
  
  import java.text.DateFormat;
  import java.text.Format;
  import java.util.Date;
  
  /** Abstract base class which supports the defaulting of the value to 'now' 
    * if no other value is specified. 
    *
    * @author James Strachan
    * @version $Revision: 1.1 $
    */
  public abstract class FormatDateTagSupport extends FormatTagSupport  {
  
      private boolean initialised;
      
      public FormatDateTagSupport() {
      }
      
      public void release() {
          super.release();
          initialised = false;
      }
      
      // Properties
      //-------------------------------------------------------------------------
      public Object getValue() {
          if ( ! initialised ) {
              // default to 'now' if no value has been specified
              super.setValue( new Date() );
              initialised = true;
          }
          return super.getValue();
      }
      
      public void setValue( Object value ) {
          super.setValue( value );
          initialised = true;
      }
  }
   
  
  
  1.1                  
jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatDateTimeTag.java
  
  Index: FormatDateTimeTag.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatDateTimeTag.java,v 
1.1 2001/04/28 15:05:44 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2001/04/28 15:05:44 $
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.taglibs.i18n;
  
  import java.text.DateFormat;
  import java.text.Format;
  
  /** Formats a {@link Date} instance using the default Date and Time formatter 
    * for the current {@link Locale}.
    *
    * @author James Strachan
    * @version $Revision: 1.1 $
    */
  public class FormatDateTimeTag extends FormatDateTagSupport   {
      
      private int dateStyle = DateFormat.SHORT;
      private int timeStyle = DateFormat.SHORT;
      
      
      public FormatDateTimeTag() {
      }
      
      // Properties
      //-------------------------------------------------------------------------
      public void setDateStyle( String style ) {
          this.dateStyle = getStyleCode( style );
      }
      
      public void setTimeStyle( String style ) {
          this.timeStyle = getStyleCode( style );
      }
      
      // Implementation methods
      //-------------------------------------------------------------------------
      protected Format getFormat() {
          return DateFormat.getDateTimeInstance( dateStyle, timeStyle, getLocale() );
      }      
  }
   
  
  
  1.1                  
jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatNumberTag.java
  
  Index: FormatNumberTag.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatNumberTag.java,v 1.1 
2001/04/28 15:05:44 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2001/04/28 15:05:44 $
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.taglibs.i18n;
  
  import java.io.IOException;
  import java.text.DecimalFormat;
  import java.text.DecimalFormatSymbols;
  import java.text.Format;
  import java.text.NumberFormat;
  import java.util.Enumeration;
  import java.util.Locale;
  
  /** Formats a {@link Number} instance using a {@link Locale} and the 
    * {@link NumberFormat} or a {@link DecimalFormat} if a pattern is specified.
    *
    * @author James Strachan
    * @version $Revision: 1.1 $
    */
  public class FormatNumberTag extends FormatTagSupport {
      
      private NumberFormat format;
      private String pattern;
      
      //-------------------------------------------------------------------------
      public FormatNumberTag() {
      }
      
  
      // Tag interface
      //-------------------------------------------------------------------------
      public void release() {
          super.release();
          format = null;
          pattern = null;
      }
      
      // Properties
      //-------------------------------------------------------------------------
      
      /** If no {@link NumberFormat} is configured then use a 
        * {@link DecimalFormat} instance if a pattern is configured else
        * use the default NumberFormat for the {@link Locale}
        */
      public Format getFormat() {
          if ( format == null ) {
              String pattern = getPattern();
              if ( pattern != null ) {
                  format = getPatternFormat( pattern );
              }
              if ( pattern == null ) {
                  format = getNumberFormat();
              }
          }
          return format;
      }
  
      public void setFormat( NumberFormat format ) {
          this.format = format;
      }
  
      public String getPattern() {
          return pattern;
      }
      
      public void setPattern( String pattern ) {
          this.pattern = pattern;
      }
  
      // Implementation methods
      //-------------------------------------------------------------------------
      protected NumberFormat getPatternFormat( String pattern ) {
          // XXXX: Use a Locale based cache for these objects as per Craig's 
          // XXXX: suggestion        
          return new DecimalFormat( pattern, new DecimalFormatSymbols( getLocale() ) 
);
      }
      
      /** @return the default number formatter for the current Locale 
        */
      protected NumberFormat getNumberFormat() {
          return NumberFormat.getInstance( getLocale() );
          // XXXX: what's the difference with the following:=
          // return NumberFormat.getNumberInstance( getLocale() );
      }
      
  }
  
  
  
  1.1                  
jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatPercentTag.java
  
  Index: FormatPercentTag.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatPercentTag.java,v 1.1 
2001/04/28 15:05:44 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2001/04/28 15:05:44 $
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.taglibs.i18n;
  
  import java.text.Format;
  import java.text.NumberFormat;
  
  /** Formats a {@link Number} instance using the current {@link Locale} 
    * and the Percent {@link NumberFormat}.
    *
    * @author James Strachan
    * @version $Revision: 1.1 $
    */
  public class FormatPercentTag extends FormatTagSupport {
      
      public FormatPercentTag() {
      }
      
      // Implementation methods
      //-------------------------------------------------------------------------
      protected Format getFormat() {
          return NumberFormat.getPercentInstance( getLocale() );
      }
  }
  
  
  
  1.1                  
jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatTagSupport.java
  
  Index: FormatTagSupport.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatTagSupport.java,v 1.1 
2001/04/28 15:05:44 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2001/04/28 15:05:44 $
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.taglibs.i18n;
  
  import java.io.IOException;
  import java.text.Format;
  import java.text.DateFormat;
  import java.util.Enumeration;
  import java.util.Locale;
  
  import javax.servlet.ServletRequest;
  import javax.servlet.jsp.JspException;
  import javax.servlet.jsp.JspWriter;
  import javax.servlet.jsp.PageContext;
  import javax.servlet.jsp.tagext.Tag;
  import javax.servlet.jsp.tagext.TagSupport;
  
  /** An abstract base class for the formatting tags to provide 
    * implementation inheritence.
    *
    * @author James Strachan
    * @version $Revision: 1.1 $
    */
  public abstract class FormatTagSupport extends TagSupport {
      
      /** the value to be formatted */
      private Object value;    
      /** Holds value of property locale. */
      private Locale locale;
      /** Holds value of property defaultText. */
      private String defaultText = "";
  
  
      public FormatTagSupport() {
      }
      
  
      // Tag interface
      //-------------------------------------------------------------------------
      public int doStartTag() throws JspException {
          return EVAL_BODY_INCLUDE;
      }
      
      public int doEndTag() throws JspException {
          try {
              Object value = getValue();
              JspWriter out = pageContext.getOut();
              String text = null;
              if ( value != null ) {
                  Format formatter = getFormat();
                  if ( formatter == null ) {
                      throw new JspException( "Could not find valid Format instance" 
);
                  }
                  text = formatter.format( value );
              }
              else {
                  text = getDefaultText();
              }
              if ( text != null ) {
                  out.print( text );
              }
          }
          catch ( IOException e ) {
              handleIOException( e );
          }
          return EVAL_PAGE;
      }
      
      public void release() {
          super.release();
          value = null;
          locale = null;
          defaultText = "";
      }
      
      // Properties
      //-------------------------------------------------------------------------    
      public Object getValue() {
          return value;
      }
      
      public void setValue( Object value ) {
          this.value = value;
      }
  
      /** If no {@link Locale} has been explicitly configured then use the
        * parent LocaleTag if present else the Locale from the ServletRequest
        * else use the default JVM {@link Locale}.
        */
      public Locale getLocale() {
          if ( locale == null ) {
              locale = findLocale();
          }
          return locale;
      }
      
      public void setLocale( Locale locale ) {
          this.locale = locale;
      }
  
      public String getDefaultText() {
          return defaultText;
      }
      
      public void setDefaultText( String defaultText ) {
          this.defaultText = defaultText;
      }
  
      
      // Implementation methods
      //-------------------------------------------------------------------------
      
      /** Abstract class to return the value formatter 
        */
      protected abstract Format getFormat();    
      
      protected void handleIOException( IOException e ) throws JspException {
          pageContext.getServletContext().log( "Caught: IOException: " + e );
          throw new JspException( "IOException: " + e );
      }
  
      /** finds the current locale from either an outer LocaleTag or the 
        * current SerlvetRequest or the current JVM.
        *
        * @return a Locale instance
        */
      protected Locale findLocale() {
          // lets try find a LocaleTag first
          LocaleTag localeTag = (LocaleTag) findAncestorWithClass( this, 
LocaleTag.class );
          if ( localeTag != null ) {
              return localeTag.getLocale();
          }        
          // otherwise lets use the ServletRequest
          return LocaleTag.getLocaleFromRequest( pageContext.getRequest() );
      }
      
      
      /** A helper method for date, datetime & time based formatting tags.
        * This method converts a string into a DateFormat style code.
        */
      protected int getStyleCode( String style ) {
          if ( "short".equalsIgnoreCase( style ) ) {
              return DateFormat.SHORT; 
          }
          else if ( "medium".equalsIgnoreCase( style ) ) {
              return DateFormat.MEDIUM; 
          }
          else if ( "long".equalsIgnoreCase( style ) ) {
              return DateFormat.LONG; 
          }
          else if ( "full".equalsIgnoreCase( style ) ) {
              return DateFormat.FULL; 
          }
          else {
              return DateFormat.SHORT;
          }
      }
  }
  
  
  
  
  
  1.1                  
jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatTimeTag.java
  
  Index: FormatTimeTag.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatTimeTag.java,v 1.1 
2001/04/28 15:05:44 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2001/04/28 15:05:44 $
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.taglibs.i18n;
  
  import java.text.DateFormat;
  import java.text.Format;
  
  /** Formats a {@link Date} instance using a {@link Locale} and the 
    * default time format.
    *
    * @author James Strachan
    * @version $Revision: 1.1 $
    */
  public class FormatTimeTag extends FormatDateTagSupport  {
  
      private int style = DateFormat.SHORT;
      
      
      public FormatTimeTag() {
      }
      
      // Properties
      //-------------------------------------------------------------------------
      public void setStyle( String style ) {
          this.style = getStyleCode( style );
      }
      
      // Implementation methods
      //-------------------------------------------------------------------------
      protected Format getFormat() {
          return DateFormat.getTimeInstance( style, getLocale() );
      }  
  }
   
  
  
  1.1                  jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/LocaleTag.java
  
  Index: LocaleTag.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/LocaleTag.java,v 1.1 
2001/04/28 15:05:44 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2001/04/28 15:05:44 $
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.taglibs.i18n;
  
  import java.util.Enumeration;
  import java.util.Locale;
  
  import javax.servlet.ServletRequest;
  import javax.servlet.jsp.JspException;
  import javax.servlet.jsp.PageContext;
  import javax.servlet.jsp.tagext.TagSupport;
  
  /** This tag defines a {@link Locale} context for use by other inner JSP tags.
    * If no has been configured directly via the "locale" property then the 
    * language, country and optional varient properties are used to
    * create a new Locale instance. 
    * If these properties are not specified then the Locale is taken from 
    * {@link ServletRequest} is used. 
    * If still no {@link Locale} could be found then the default JVM 
    * {@link Locale} is used.
    *
    * @author James Strachan
    * @version $Revision: 1.1 $
    */
  public class LocaleTag extends TagSupport {
      
      /** Holds value of property locale. */
      private Locale locale;
      /** Holds value of property language. */
      private String language;
      /** Holds value of property country. */
      private String country;
      /** Holds value of property variant. */
      private String variant;
  
      //-------------------------------------------------------------------------
      public LocaleTag() {
      }
      
  
      // Tag interface
      //-------------------------------------------------------------------------
      public int doStartTag() throws JspException {
          return EVAL_BODY_INCLUDE;
      }
      
      public void release() {
          super.release();
          locale = null;
          language = null;
          country = null;
          variant = null;
      }
      
      // Properties
      //-------------------------------------------------------------------------
      public Locale getLocale() {
          if ( locale == null ) {
              locale = createLocale();
          }
          return locale;
      }
      
      public void setLocale( Locale locale ) {
          this.locale = locale;
      }
  
      public String getLanguage() {
          return language;
      }
      
      public void setLanguage( String language ) {
          this.language = language;
      }
  
      public String getCountry() {
          return country;
      }
      
      public void setCountry( String country ) {
          this.country = country;
      }
  
      public String getVariant() {
          return variant;
      }
      
      public void setVariant( String variant ) {
          this.variant = variant;
      }
  
      // Implementation methods
      //-------------------------------------------------------------------------
      protected Locale createLocale() {
          // let's try use the language & country properties first...
          if ( language != null && country != null ) {
              return (variant != null) 
                  ? new Locale( language, country, variant )
                  : new Locale( language, country );
          }
          // otherwise lets use the ServletRequest
          return getLocaleFromRequest( pageContext.getRequest() );
      }
      
      /** Extracts the {@link Locale} from the given {@link ServletRequest}
        * or returns the default JVM's {@link Locale} if it could not be found
        */
      protected static Locale getLocaleFromRequest(ServletRequest request) {
          Locale answer = request.getLocale();
          if ( answer == null ) {
              for ( Enumeration enum = request.getLocales(); enum.hasMoreElements(); ) 
{
                  answer = (Locale) enum.nextElement();
                  if ( answer != null ) {
                      break;
                  }
              }
              if ( answer == null ) {
                  // XXXX: should we use the JVM default?
                  // XXXX: or throw some exception?
                  answer = Locale.getDefault();
              }
          }
          return answer;
      }
  }
  
  
  

Reply via email to