| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
| <!--NewPage-->
|
| <HTML>
|
| <HEAD>
|
| <!-- Generated by javadoc (build 1.4.2_08) on Mon Nov 14 10:15:17 PST 2005 -->
|
| <TITLE>
|
| NumberTool (Velocity Tools 1.2 Documentation)
|
| </TITLE>
|
|
|
| <META NAME="keywords" CONTENT="org.apache.velocity.tools.generic.NumberTool class">
|
|
|
| <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style">
|
|
|
| <SCRIPT type="text/javascript">
|
| function windowTitle()
|
| {
|
| parent.document.title="NumberTool (Velocity Tools 1.2 Documentation)";
|
| }
|
| </SCRIPT>
|
|
|
| </HEAD>
|
|
|
| <BODY BGCOLOR="white" onload="windowTitle();">
|
|
|
| |
| <!-- ========= START OF TOP NAVBAR ======= -->
|
| <A NAME="navbar_top"><!-- --></A> |
| <A HREF="#skip-navbar_top" title="Skip navigation links"></A> |
| <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
| <TR>
|
| <TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
| <A NAME="navbar_top_firstrow"><!-- --></A> |
| <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
| <TR ALIGN="center" VALIGN="top">
|
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
|
| <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
|
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
| </TR>
|
| </TABLE>
|
| </TD>
|
| <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
| </EM>
|
| </TD>
|
| </TR>
|
|
|
| <TR>
|
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
| <A HREF="../../../../../org/apache/velocity/tools/generic/MathTool.html" title="class in org.apache.velocity.tools.generic"><B>PREV CLASS</B></A>
|
| <A HREF="../../../../../org/apache/velocity/tools/generic/RenderTool.html" title="class in org.apache.velocity.tools.generic"><B>NEXT CLASS</B></A></FONT></TD>
|
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
| <A HREF="../../../../../index.html" target="_top"><B>FRAMES</B></A>
|
| <A HREF="NumberTool.html" target="_top"><B>NO FRAMES</B></A>
|
| <SCRIPT type="text/javascript">
|
| <!--
|
| if(window==top) {
|
| document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
|
| }
|
| //-->
|
| </SCRIPT>
|
| <NOSCRIPT>
|
| <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
|
| </NOSCRIPT> |
|
|
| </FONT></TD>
|
| </TR>
|
| <TR>
|
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
| SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
|
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
| DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
|
| </TR>
|
| </TABLE>
|
| <A NAME="skip-navbar_top"></A> |
| <!-- ========= END OF TOP NAVBAR ========= -->
|
|
|
| <HR>
|
| <!-- ======== START OF CLASS DATA ======== -->
|
| <H2>
|
| <FONT SIZE="-1">
|
| org.apache.velocity.tools.generic</FONT>
|
| <BR>
|
| Class NumberTool</H2>
|
| <PRE>
|
| java.lang.Object
|
| <IMG SRC="../../../../../resources/inherit.gif" ALT="extended by"><B>org.apache.velocity.tools.generic.NumberTool</B>
|
| </PRE>
|
| <HR>
|
| <DL>
|
| <DT>public class <B>NumberTool</B><DT>extends java.lang.Object</DL>
|
|
|
| <P>
|
| Tool for working with <CODE>Number</CODE> in Velocity templates. |
| It is useful for accessing and |
| formatting arbitrary <CODE>Number</CODE> objects. Also |
| the tool can be used to retrieve <CODE>NumberFormat</CODE> instances |
| or make conversions to and from various number types. |
| <p><pre> |
| Example uses: |
| $myNumber -> 13.55 |
| $number.format('currency',$myNumber) -> $13.55 |
| $number.format('integer',$myNumber) -> 13 |
| |
| Example toolbox.xml config (if you want to use this with VelocityView): |
| <tool> |
| <key>number</key> |
| <scope>application</scope> |
| <class>org.apache.velocity.tools.generic.NumberTool</class> |
| </tool> |
| </pre></p> |
| |
| <p>This tool is entirely threadsafe, and has no instance members. |
| It may be used in any scope (request, session, or application). |
| As such, the methods are highly interconnected, and overriding |
| key methods provides an easy way to create subclasses that use |
| a non-default format or locale.</p>
|
| <P>
|
|
|
| <P>
|
| <DL>
|
| <DT><B>Since:</B></DT> |
| <DD>VelocityTools 1.2</DD> |
| <DT><B>Version:</B></DT> |
| <DD>$Id: NumberTool.java 71982 2004-02-18 20:11:07Z nbubna $</DD> |
| <DT><B>Author:</B></DT> |
| <DD><a href="mailto:nathan@esha.com">Nathan Bubna</a>, <a href="mailto:mkienenb@alaska.net">Mike Kienenberger</a></DD> |
| </DL>
|
| <HR>
|
|
|
| <P>
|
| <!-- ======== NESTED CLASS SUMMARY ======== -->
|
|
|
|
|
| <!-- =========== FIELD SUMMARY =========== -->
|
|
|
| <A NAME="field_summary"><!-- --></A> |
| <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
| <TD COLSPAN=2><FONT SIZE="+2">
|
| <B>Field Summary</B></FONT></TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE>static java.lang.String</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#DEFAULT_FORMAT">DEFAULT_FORMAT</A></B></CODE>
|
|
|
| <BR>
|
| The default format to be used when none is specified.</TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE>private static int</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#STYLE_CURRENCY">STYLE_CURRENCY</A></B></CODE>
|
|
|
| <BR>
|
| </TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE>private static int</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#STYLE_INTEGER">STYLE_INTEGER</A></B></CODE>
|
|
|
| <BR>
|
| </TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE>private static int</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#STYLE_NUMBER">STYLE_NUMBER</A></B></CODE>
|
|
|
| <BR>
|
| </TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE>private static int</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#STYLE_PERCENT">STYLE_PERCENT</A></B></CODE>
|
|
|
| <BR>
|
| </TD>
|
| </TR>
|
| </TABLE>
|
|
|
| <!-- ======== CONSTRUCTOR SUMMARY ======== -->
|
|
|
| <A NAME="constructor_summary"><!-- --></A> |
| <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
| <TD COLSPAN=2><FONT SIZE="+2">
|
| <B>Constructor Summary</B></FONT></TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#NumberTool()">NumberTool</A></B>()</CODE>
|
|
|
| <BR>
|
| Default constructor.</TD>
|
| </TR>
|
| </TABLE>
|
|
|
| <!-- ========== METHOD SUMMARY =========== -->
|
|
|
| <A NAME="method_summary"><!-- --></A> |
| <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
| <TD COLSPAN=2><FONT SIZE="+2">
|
| <B>Method Summary</B></FONT></TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE> java.lang.String</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#format(java.lang.Object)">format</A></B>(java.lang.Object obj)</CODE>
|
|
|
| <BR>
|
| Converts the specified object to a number and formats it according to |
| the pattern or style returned by <A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#getFormat()"><CODE>getFormat()</CODE></A>.</TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE> java.lang.String</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#format(java.lang.String, java.lang.Object)">format</A></B>(java.lang.String format, |
| java.lang.Object obj)</CODE>
|
|
|
| <BR>
|
| Converts the specified object to a number and returns |
| a formatted string representing that number in the locale |
| returned by <A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#getLocale()"><CODE>getLocale()</CODE></A>.</TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE> java.lang.String</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#format(java.lang.String, java.lang.Object, java.util.Locale)">format</A></B>(java.lang.String format, |
| java.lang.Object obj, |
| java.util.Locale locale)</CODE>
|
|
|
| <BR>
|
| Converts the specified object to a number and returns |
| a formatted string representing that number in the specified |
| <CODE>Locale</CODE>.</TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE> java.lang.String</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#getFormat()">getFormat</A></B>()</CODE>
|
|
|
| <BR>
|
| Return the pattern or style to be used for formatting numbers when none |
| is specified.</TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE>private java.text.NumberFormat</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#getIntegerInstance(java.util.Locale)">getIntegerInstance</A></B>(java.util.Locale locale)</CODE>
|
|
|
| <BR>
|
| Since we wish to continue supporting Java 1.3, |
| for the present we cannot use Java 1.4's |
| NumberFormat.getIntegerInstance(Locale) method.</TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE> java.util.Locale</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#getLocale()">getLocale</A></B>()</CODE>
|
|
|
| <BR>
|
| This implementation returns the default locale.</TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE>protected java.text.NumberFormat</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#getNumberFormat(int, java.util.Locale)">getNumberFormat</A></B>(int numberStyle, |
| java.util.Locale locale)</CODE>
|
|
|
| <BR>
|
| Returns a <CODE>NumberFormat</CODE> instance for the specified |
| number style and <CODE>Locale</CODE>.</TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE> java.text.NumberFormat</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#getNumberFormat(java.lang.String, java.util.Locale)">getNumberFormat</A></B>(java.lang.String format, |
| java.util.Locale locale)</CODE>
|
|
|
| <BR>
|
| Returns a <CODE>NumberFormat</CODE> instance for the specified |
| format and <CODE>Locale</CODE>.</TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE>protected int</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#getStyleAsInt(java.lang.String)">getStyleAsInt</A></B>(java.lang.String style)</CODE>
|
|
|
| <BR>
|
| Checks a string to see if it matches one of the standard |
| NumberFormat style patterns: |
| NUMBER, CURRENCY, PERCENT, INTEGER, or DEFAULT.</TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE> java.lang.Number</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#toNumber(java.lang.Object)">toNumber</A></B>(java.lang.Object obj)</CODE>
|
|
|
| <BR>
|
| Converts an object to an instance of <CODE>Number</CODE> using the |
| format returned by <A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#getFormat()"><CODE>getFormat()</CODE></A> and the <CODE>Locale</CODE> |
| returned by <A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#getLocale()"><CODE>getLocale()</CODE></A> if the object is not already |
| an instance of Number.</TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE> java.lang.Number</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#toNumber(java.lang.String, java.lang.Object)">toNumber</A></B>(java.lang.String format, |
| java.lang.Object obj)</CODE>
|
|
|
| <BR>
|
| Converts an object to an instance of <CODE>Number</CODE> using the |
| specified format and the <CODE>Locale</CODE> returned by |
| <A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#getLocale()"><CODE>getLocale()</CODE></A> if the object is not already an instance |
| of Number.</TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
| <CODE> java.lang.Number</CODE></FONT></TD>
|
| <TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#toNumber(java.lang.String, java.lang.Object, java.util.Locale)">toNumber</A></B>(java.lang.String format, |
| java.lang.Object obj, |
| java.util.Locale locale)</CODE>
|
|
|
| <BR>
|
| Converts an object to an instance of <CODE>Number</CODE> using the |
| specified format and <CODE>Locale</CODE>if the object is not already |
| an instance of Number.</TD>
|
| </TR>
|
| </TABLE>
|
| <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> |
| <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
| <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
|
| <TD><B>Methods inherited from class java.lang.Object</B></TD>
|
| </TR>
|
| <TR BGCOLOR="white" CLASS="TableRowColor">
|
| <TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
|
| </TR>
|
| </TABLE>
|
|
|
| <P>
|
|
|
| <!-- ============ FIELD DETAIL =========== -->
|
|
|
| <A NAME="field_detail"><!-- --></A> |
| <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
| <TD COLSPAN=1><FONT SIZE="+2">
|
| <B>Field Detail</B></FONT></TD>
|
| </TR>
|
| </TABLE>
|
|
|
| <A NAME="DEFAULT_FORMAT"><!-- --></A><H3>
|
| DEFAULT_FORMAT</H3>
|
| <PRE>
|
| public static final java.lang.String <B>DEFAULT_FORMAT</B></PRE>
|
| <DL>
|
| <DD>The default format to be used when none is specified.
|
| <P>
|
| <DL>
|
| <DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#org.apache.velocity.tools.generic.NumberTool.DEFAULT_FORMAT">Constant Field Values</A></DL>
|
| </DL>
|
| <HR>
|
|
|
| <A NAME="STYLE_NUMBER"><!-- --></A><H3>
|
| STYLE_NUMBER</H3>
|
| <PRE>
|
| private static final int <B>STYLE_NUMBER</B></PRE>
|
| <DL>
|
| <DL>
|
| <DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#org.apache.velocity.tools.generic.NumberTool.STYLE_NUMBER">Constant Field Values</A></DL>
|
| </DL>
|
| <HR>
|
|
|
| <A NAME="STYLE_CURRENCY"><!-- --></A><H3>
|
| STYLE_CURRENCY</H3>
|
| <PRE>
|
| private static final int <B>STYLE_CURRENCY</B></PRE>
|
| <DL>
|
| <DL>
|
| <DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#org.apache.velocity.tools.generic.NumberTool.STYLE_CURRENCY">Constant Field Values</A></DL>
|
| </DL>
|
| <HR>
|
|
|
| <A NAME="STYLE_PERCENT"><!-- --></A><H3>
|
| STYLE_PERCENT</H3>
|
| <PRE>
|
| private static final int <B>STYLE_PERCENT</B></PRE>
|
| <DL>
|
| <DL>
|
| <DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#org.apache.velocity.tools.generic.NumberTool.STYLE_PERCENT">Constant Field Values</A></DL>
|
| </DL>
|
| <HR>
|
|
|
| <A NAME="STYLE_INTEGER"><!-- --></A><H3>
|
| STYLE_INTEGER</H3>
|
| <PRE>
|
| private static final int <B>STYLE_INTEGER</B></PRE>
|
| <DL>
|
| <DL>
|
| <DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#org.apache.velocity.tools.generic.NumberTool.STYLE_INTEGER">Constant Field Values</A></DL>
|
| </DL>
|
|
|
| <!-- ========= CONSTRUCTOR DETAIL ======== -->
|
|
|
| <A NAME="constructor_detail"><!-- --></A> |
| <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
| <TD COLSPAN=1><FONT SIZE="+2">
|
| <B>Constructor Detail</B></FONT></TD>
|
| </TR>
|
| </TABLE>
|
|
|
| <A NAME="NumberTool()"><!-- --></A><H3>
|
| NumberTool</H3>
|
| <PRE>
|
| public <B>NumberTool</B>()</PRE>
|
| <DL>
|
| <DD>Default constructor.
|
| <P>
|
| </DL>
|
|
|
| <!-- ============ METHOD DETAIL ========== -->
|
|
|
| <A NAME="method_detail"><!-- --></A> |
| <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
| <TD COLSPAN=1><FONT SIZE="+2">
|
| <B>Method Detail</B></FONT></TD>
|
| </TR>
|
| </TABLE>
|
|
|
| <A NAME="getLocale()"><!-- --></A><H3>
|
| getLocale</H3>
|
| <PRE>
|
| public java.util.Locale <B>getLocale</B>()</PRE>
|
| <DL>
|
| <DD>This implementation returns the default locale. Subclasses |
| may override this to return alternate locales. Please note that |
| doing so will affect all formatting methods where no locale is |
| specified in the parameters.
|
| <P>
|
| <DD><DL>
|
| |
| <DT><B>Returns:</B><DD>the default <CODE>Locale</CODE></DL>
|
| </DD>
|
| </DL>
|
| <HR>
|
|
|
| <A NAME="getFormat()"><!-- --></A><H3>
|
| getFormat</H3>
|
| <PRE>
|
| public java.lang.String <B>getFormat</B>()</PRE>
|
| <DL>
|
| <DD>Return the pattern or style to be used for formatting numbers when none |
| is specified. This implementation gives a 'default' number format. |
| Subclasses may override this to provide a different default format. |
| |
| <p>NOTE: At some point in the future it may be feasible to configure |
| this value via the toolbox definition, but at present, it is not possible |
| to specify custom tool configurations there. For now you should just |
| override this in a subclass to have a different default.</p>
|
| <P>
|
| <DD><DL>
|
| </DL>
|
| </DD>
|
| </DL>
|
| <HR>
|
|
|
| <A NAME="format(java.lang.Object)"><!-- --></A><H3>
|
| format</H3>
|
| <PRE>
|
| public java.lang.String <B>format</B>(java.lang.Object obj)</PRE>
|
| <DL>
|
| <DD>Converts the specified object to a number and formats it according to |
| the pattern or style returned by <A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#getFormat()"><CODE>getFormat()</CODE></A>.
|
| <P>
|
| <DD><DL>
|
| <DT><B>Parameters:</B><DD><CODE>obj</CODE> - the number object to be formatted |
| <DT><B>Returns:</B><DD>the specified number formatted as a string<DT><B>See Also:</B><DD><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#format(java.lang.String, java.lang.Object, java.util.Locale)"><CODE>format(String format, Object obj, Locale locale)</CODE></A></DL>
|
| </DD>
|
| </DL>
|
| <HR>
|
|
|
| <A NAME="format(java.lang.String, java.lang.Object)"><!-- --></A><H3>
|
| format</H3>
|
| <PRE>
|
| public java.lang.String <B>format</B>(java.lang.String format, |
| java.lang.Object obj)</PRE>
|
| <DL>
|
| <DD>Converts the specified object to a number and returns |
| a formatted string representing that number in the locale |
| returned by <A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#getLocale()"><CODE>getLocale()</CODE></A>.
|
| <P>
|
| <DD><DL>
|
| <DT><B>Parameters:</B><DD><CODE>format</CODE> - the formatting instructions<DD><CODE>obj</CODE> - the number object to be formatted |
| <DT><B>Returns:</B><DD>a formatted string for this locale representing the specified |
| number or <code>null</code> if the parameters are invalid<DT><B>See Also:</B><DD><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#format(java.lang.String, java.lang.Object, java.util.Locale)"><CODE>format(String format, Object obj, Locale locale)</CODE></A></DL>
|
| </DD>
|
| </DL>
|
| <HR>
|
|
|
| <A NAME="format(java.lang.String, java.lang.Object, java.util.Locale)"><!-- --></A><H3>
|
| format</H3>
|
| <PRE>
|
| public java.lang.String <B>format</B>(java.lang.String format, |
| java.lang.Object obj, |
| java.util.Locale locale)</PRE>
|
| <DL>
|
| <DD>Converts the specified object to a number and returns |
| a formatted string representing that number in the specified |
| <CODE>Locale</CODE>.
|
| <P>
|
| <DD><DL>
|
| <DT><B>Parameters:</B><DD><CODE>format</CODE> - the custom or standard pattern to be used<DD><CODE>obj</CODE> - the number object to be formatted<DD><CODE>locale</CODE> - the <CODE>Locale</CODE> to be used when formatting |
| <DT><B>Returns:</B><DD>a formatted string representing the specified number or |
| <code>null</code> if the parameters are invalid</DL>
|
| </DD>
|
| </DL>
|
| <HR>
|
|
|
| <A NAME="getNumberFormat(java.lang.String, java.util.Locale)"><!-- --></A><H3>
|
| getNumberFormat</H3>
|
| <PRE>
|
| public java.text.NumberFormat <B>getNumberFormat</B>(java.lang.String format, |
| java.util.Locale locale)</PRE>
|
| <DL>
|
| <DD>Returns a <CODE>NumberFormat</CODE> instance for the specified |
| format and <CODE>Locale</CODE>. If the format specified is a standard |
| style pattern, then a number instance |
| will be returned with the number style set to the |
| specified style. If it is a custom format, then a customized |
| <CODE>NumberFormat</CODE> will be returned.
|
| <P>
|
| <DD><DL>
|
| <DT><B>Parameters:</B><DD><CODE>format</CODE> - the custom or standard formatting pattern to be used<DD><CODE>locale</CODE> - the <CODE>Locale</CODE> to be used |
| <DT><B>Returns:</B><DD>an instance of <CODE>NumberFormat</CODE><DT><B>See Also:</B><DD><CODE>NumberFormat</CODE></DL>
|
| </DD>
|
| </DL>
|
| <HR>
|
|
|
| <A NAME="getNumberFormat(int, java.util.Locale)"><!-- --></A><H3>
|
| getNumberFormat</H3>
|
| <PRE>
|
| protected java.text.NumberFormat <B>getNumberFormat</B>(int numberStyle, |
| java.util.Locale locale)</PRE>
|
| <DL>
|
| <DD>Returns a <CODE>NumberFormat</CODE> instance for the specified |
| number style and <CODE>Locale</CODE>.
|
| <P>
|
| <DD><DL>
|
| <DT><B>Parameters:</B><DD><CODE>numberStyle</CODE> - the number style (number will be ignored if this is |
| less than zero or the number style is not recognized)<DD><CODE>locale</CODE> - the <CODE>Locale</CODE> to be used |
| <DT><B>Returns:</B><DD>an instance of <CODE>NumberFormat</CODE> or <code>null</code> |
| if an instance cannot be constructed with the given |
| parameters</DL>
|
| </DD>
|
| </DL>
|
| <HR>
|
|
|
| <A NAME="getIntegerInstance(java.util.Locale)"><!-- --></A><H3>
|
| getIntegerInstance</H3>
|
| <PRE>
|
| private java.text.NumberFormat <B>getIntegerInstance</B>(java.util.Locale locale)</PRE>
|
| <DL>
|
| <DD>Since we wish to continue supporting Java 1.3, |
| for the present we cannot use Java 1.4's |
| NumberFormat.getIntegerInstance(Locale) method. |
| This method mimics that method (at least as of JDK1.4.2_01). |
| It is private so that it can be removed later |
| without a deprecation period.
|
| <P>
|
| <DD><DL>
|
| </DL>
|
| </DD>
|
| </DL>
|
| <HR>
|
|
|
| <A NAME="getStyleAsInt(java.lang.String)"><!-- --></A><H3>
|
| getStyleAsInt</H3>
|
| <PRE>
|
| protected int <B>getStyleAsInt</B>(java.lang.String style)</PRE>
|
| <DL>
|
| <DD>Checks a string to see if it matches one of the standard |
| NumberFormat style patterns: |
| NUMBER, CURRENCY, PERCENT, INTEGER, or DEFAULT. |
| if it does it will return the integer constant for that pattern. |
| if not, it will return -1.
|
| <P>
|
| <DD><DL>
|
| <DT><B>Parameters:</B><DD><CODE>style</CODE> - the string to be checked |
| <DT><B>Returns:</B><DD>the int identifying the style pattern<DT><B>See Also:</B><DD><CODE>NumberFormat</CODE></DL>
|
| </DD>
|
| </DL>
|
| <HR>
|
|
|
| <A NAME="toNumber(java.lang.Object)"><!-- --></A><H3>
|
| toNumber</H3>
|
| <PRE>
|
| public java.lang.Number <B>toNumber</B>(java.lang.Object obj)</PRE>
|
| <DL>
|
| <DD>Converts an object to an instance of <CODE>Number</CODE> using the |
| format returned by <A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#getFormat()"><CODE>getFormat()</CODE></A> and the <CODE>Locale</CODE> |
| returned by <A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#getLocale()"><CODE>getLocale()</CODE></A> if the object is not already |
| an instance of Number.
|
| <P>
|
| <DD><DL>
|
| <DT><B>Parameters:</B><DD><CODE>obj</CODE> - the number to convert |
| <DT><B>Returns:</B><DD>the object as a <CODE>Number</CODE> or <code>null</code> if no |
| conversion is possible</DL>
|
| </DD>
|
| </DL>
|
| <HR>
|
|
|
| <A NAME="toNumber(java.lang.String, java.lang.Object)"><!-- --></A><H3>
|
| toNumber</H3>
|
| <PRE>
|
| public java.lang.Number <B>toNumber</B>(java.lang.String format, |
| java.lang.Object obj)</PRE>
|
| <DL>
|
| <DD>Converts an object to an instance of <CODE>Number</CODE> using the |
| specified format and the <CODE>Locale</CODE> returned by |
| <A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#getLocale()"><CODE>getLocale()</CODE></A> if the object is not already an instance |
| of Number.
|
| <P>
|
| <DD><DL>
|
| <DT><B>Parameters:</B><DD><CODE>format</CODE> - - the format the number is in<DD><CODE>obj</CODE> - - the number to convert |
| <DT><B>Returns:</B><DD>the object as a <CODE>Number</CODE> or <code>null</code> if no |
| conversion is possible<DT><B>See Also:</B><DD><A HREF="../../../../../org/apache/velocity/tools/generic/NumberTool.html#toNumber(java.lang.String, java.lang.Object, java.util.Locale)"><CODE>toNumber(String format, Object obj, Locale locale)</CODE></A></DL>
|
| </DD>
|
| </DL>
|
| <HR>
|
|
|
| <A NAME="toNumber(java.lang.String, java.lang.Object, java.util.Locale)"><!-- --></A><H3>
|
| toNumber</H3>
|
| <PRE>
|
| public java.lang.Number <B>toNumber</B>(java.lang.String format, |
| java.lang.Object obj, |
| java.util.Locale locale)</PRE>
|
| <DL>
|
| <DD>Converts an object to an instance of <CODE>Number</CODE> using the |
| specified format and <CODE>Locale</CODE>if the object is not already |
| an instance of Number.
|
| <P>
|
| <DD><DL>
|
| <DT><B>Parameters:</B><DD><CODE>format</CODE> - - the format the number is in<DD><CODE>obj</CODE> - - the number to convert<DD><CODE>locale</CODE> - - the <CODE>Locale</CODE> |
| <DT><B>Returns:</B><DD>the object as a <CODE>Number</CODE> or <code>null</code> if no |
| conversion is possible<DT><B>See Also:</B><DD><CODE>NumberFormat.parse(java.lang.String)</CODE></DL>
|
| </DD>
|
| </DL>
|
| <!-- ========= END OF CLASS DATA ========= -->
|
| <HR>
|
|
|
| |
| <!-- ======= START OF BOTTOM NAVBAR ====== -->
|
| <A NAME="navbar_bottom"><!-- --></A> |
| <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> |
| <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
| <TR>
|
| <TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
| <A NAME="navbar_bottom_firstrow"><!-- --></A> |
| <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
| <TR ALIGN="center" VALIGN="top">
|
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
|
| <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
|
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
| </TR>
|
| </TABLE>
|
| </TD>
|
| <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
| </EM>
|
| </TD>
|
| </TR>
|
|
|
| <TR>
|
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
| <A HREF="../../../../../org/apache/velocity/tools/generic/MathTool.html" title="class in org.apache.velocity.tools.generic"><B>PREV CLASS</B></A>
|
| <A HREF="../../../../../org/apache/velocity/tools/generic/RenderTool.html" title="class in org.apache.velocity.tools.generic"><B>NEXT CLASS</B></A></FONT></TD>
|
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
| <A HREF="../../../../../index.html" target="_top"><B>FRAMES</B></A>
|
| <A HREF="NumberTool.html" target="_top"><B>NO FRAMES</B></A>
|
| <SCRIPT type="text/javascript">
|
| <!--
|
| if(window==top) {
|
| document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
|
| }
|
| //-->
|
| </SCRIPT>
|
| <NOSCRIPT>
|
| <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
|
| </NOSCRIPT> |
|
|
| </FONT></TD>
|
| </TR>
|
| <TR>
|
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
| SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
|
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
| DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
|
| </TR>
|
| </TABLE>
|
| <A NAME="skip-navbar_bottom"></A> |
| <!-- ======== END OF BOTTOM NAVBAR ======= -->
|
|
|
| <HR>
|
| Copyright (c) 2003 Apache Software Foundation
|
| </BODY>
|
| </HTML>
|