blob: da5ff97ccc90a40f6d3cc206317fa33a52eeb185 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc on Wed Apr 14 08:26:32 EDT 2004 -->
<TITLE>
Velocity 1.4 API: Class VelocityFormatter
</TITLE>
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style">
</HEAD>
<BODY BGCOLOR="white">
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_top"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/VelocityFormatter.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;PREV CLASS&nbsp;
&nbsp;<A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.VelocityAlternator.html"><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> &nbsp;
&nbsp;<A HREF="VelocityFormatter.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: &nbsp;<A HREF="#inner_class_summary">INNER</A>&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: &nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
org.apache.velocity.app.tools</FONT>
<BR>
Class VelocityFormatter</H2>
<PRE>
java.lang.Object
|
+--<B>org.apache.velocity.app.tools.VelocityFormatter</B>
</PRE>
<HR>
<DL>
<DT>public class <B>VelocityFormatter</B><DT>extends java.lang.Object</DL>
<P>
Formatting tool for inserting into the Velocity WebContext. Can
format dates or lists of objects.
<p>Here's an example of some uses:
<code><pre>
$formatter.formatShortDate($object.Date)
$formatter.formatLongDate($db.getRecord(232).getDate())
$formatter.formatArray($array)
$formatter.limitLen(30, $object.Description)
</pre></code>
<P>
<DL>
<DT><B>Version: </B><DD>$Id: VelocityFormatter.java,v 1.9 2003/05/04 17:06:11 geirm Exp $</DD>
<DT><B>Author: </B><DD><a href="sean@somacity.com">Sean Legassick</a>, <a href="dlr@collab.net">Daniel Rall</a></DD>
</DL>
<HR>
<P>
<!-- ======== INNER CLASS SUMMARY ======== -->
<A NAME="inner_class_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Inner Class Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;class</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.VelocityAlternator.html">VelocityFormatter.VelocityAlternator</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Class that returns alternating values in a template.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;class</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.VelocityAutoAlternator.html">VelocityFormatter.VelocityAutoAlternator</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As VelocityAlternator, but calls <code>alternate()</code>
automatically on rendering in a template.</TD>
</TR>
</TABLE>
&nbsp;
<!-- =========== FIELD SUMMARY =========== -->
<A NAME="field_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<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>(package private) &nbsp;<A HREF="../../../../../org/apache/velocity/context/Context.html">Context</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#context">context</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>(package private) &nbsp;java.text.NumberFormat</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#nf">nf</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
</TABLE>
&nbsp;
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<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/app/tools/VelocityFormatter.html#VelocityFormatter(org.apache.velocity.context.Context)">VelocityFormatter</A></B>(<A HREF="../../../../../org/apache/velocity/context/Context.html">Context</A>&nbsp;context)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructor needs a backpointer to the context.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<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>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#formatArray(java.lang.Object)">formatArray</A></B>(java.lang.Object&nbsp;array)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats an array into the form "A, B and C".</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#formatArray(java.lang.Object, java.lang.String)">formatArray</A></B>(java.lang.Object&nbsp;array,
java.lang.String&nbsp;delim)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats an array into the form
"A&lt;delim&gt;B&lt;delim&gt;C".</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#formatArray(java.lang.Object, java.lang.String, java.lang.String)">formatArray</A></B>(java.lang.Object&nbsp;array,
java.lang.String&nbsp;delim,
java.lang.String&nbsp;finaldelim)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats an array into the form
"A&lt;delim&gt;B&lt;finaldelim&gt;C".</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#formatLongDate(java.util.Date)">formatLongDate</A></B>(java.util.Date&nbsp;date)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats a date in <code>DateFormat.LONG</code> style.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#formatLongDateTime(java.util.Date)">formatLongDateTime</A></B>(java.util.Date&nbsp;date)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats a date/time in 'long' style.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#formatShortDate(java.util.Date)">formatShortDate</A></B>(java.util.Date&nbsp;date)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats a date in <code>DateFormat.SHORT</code> style.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#formatShortDateTime(java.util.Date)">formatShortDateTime</A></B>(java.util.Date&nbsp;date)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats a date/time in 'short' style.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#formatVector(java.util.List)">formatVector</A></B>(java.util.List&nbsp;list)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats a vector into the form "A, B and C".</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#formatVector(java.util.List, java.lang.String)">formatVector</A></B>(java.util.List&nbsp;list,
java.lang.String&nbsp;delim)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats a vector into the form "A&lt;delim&gt;B&lt;delim&gt;C".</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#formatVector(java.util.List, java.lang.String, java.lang.String)">formatVector</A></B>(java.util.List&nbsp;list,
java.lang.String&nbsp;delim,
java.lang.String&nbsp;finaldelim)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats a list into the form
"Adelim&gt;B&lt;finaldelim&gt;C".</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Object</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#isNull(java.lang.Object, java.lang.Object)">isNull</A></B>(java.lang.Object&nbsp;o,
java.lang.Object&nbsp;dflt)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a default value if the object passed is null.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#limitLen(int, java.lang.String)">limitLen</A></B>(int&nbsp;maxlen,
java.lang.String&nbsp;string)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Limits 'string' to 'maxlen' characters.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#limitLen(int, java.lang.String, java.lang.String)">limitLen</A></B>(int&nbsp;maxlen,
java.lang.String&nbsp;string,
java.lang.String&nbsp;suffix)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Limits 'string' to 'maxlen' character.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#makeAlternator(java.lang.String, java.lang.String, java.lang.String)">makeAlternator</A></B>(java.lang.String&nbsp;name,
java.lang.String&nbsp;alt1,
java.lang.String&nbsp;alt2)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Makes an alternator object that alternates between two values.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#makeAlternator(java.lang.String, java.lang.String, java.lang.String, java.lang.String)">makeAlternator</A></B>(java.lang.String&nbsp;name,
java.lang.String&nbsp;alt1,
java.lang.String&nbsp;alt2,
java.lang.String&nbsp;alt3)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Makes an alternator object that alternates between three
values.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#makeAlternator(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)">makeAlternator</A></B>(java.lang.String&nbsp;name,
java.lang.String&nbsp;alt1,
java.lang.String&nbsp;alt2,
java.lang.String&nbsp;alt3,
java.lang.String&nbsp;alt4)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Makes an alternator object that alternates between four values.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#makeAutoAlternator(java.lang.String, java.lang.String, java.lang.String)">makeAutoAlternator</A></B>(java.lang.String&nbsp;name,
java.lang.String&nbsp;alt1,
java.lang.String&nbsp;alt2)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Makes an alternator object that alternates between two values
automatically.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class java.lang.Object</B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><clinit>, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ============ FIELD DETAIL =========== -->
<A NAME="field_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Field Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="context"><!-- --></A><H3>
context</H3>
<PRE>
<A HREF="../../../../../org/apache/velocity/context/Context.html">Context</A> <B>context</B></PRE>
<DL>
</DL>
<HR>
<A NAME="nf"><!-- --></A><H3>
nf</H3>
<PRE>
java.text.NumberFormat <B>nf</B></PRE>
<DL>
</DL>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="VelocityFormatter(org.apache.velocity.context.Context)"><!-- --></A><H3>
VelocityFormatter</H3>
<PRE>
public <B>VelocityFormatter</B>(<A HREF="../../../../../org/apache/velocity/context/Context.html">Context</A>&nbsp;context)</PRE>
<DL>
<DD>Constructor needs a backpointer to the context.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>context</CODE> - A Context.</DL>
</DD>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="formatShortDate(java.util.Date)"><!-- --></A><H3>
formatShortDate</H3>
<PRE>
public java.lang.String <B>formatShortDate</B>(java.util.Date&nbsp;date)</PRE>
<DL>
<DD>Formats a date in <code>DateFormat.SHORT</code> style.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>date</CODE> - The date to format.<DT><B>Returns:</B><DD>The formatted date as text.</DL>
</DD>
</DL>
<HR>
<A NAME="formatLongDate(java.util.Date)"><!-- --></A><H3>
formatLongDate</H3>
<PRE>
public java.lang.String <B>formatLongDate</B>(java.util.Date&nbsp;date)</PRE>
<DL>
<DD>Formats a date in <code>DateFormat.LONG</code> style.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>date</CODE> - The date to format.<DT><B>Returns:</B><DD>The formatted date as text.</DL>
</DD>
</DL>
<HR>
<A NAME="formatShortDateTime(java.util.Date)"><!-- --></A><H3>
formatShortDateTime</H3>
<PRE>
public java.lang.String <B>formatShortDateTime</B>(java.util.Date&nbsp;date)</PRE>
<DL>
<DD>Formats a date/time in 'short' style.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>date</CODE> - The date to format.<DT><B>Returns:</B><DD>The formatted date as text.</DL>
</DD>
</DL>
<HR>
<A NAME="formatLongDateTime(java.util.Date)"><!-- --></A><H3>
formatLongDateTime</H3>
<PRE>
public java.lang.String <B>formatLongDateTime</B>(java.util.Date&nbsp;date)</PRE>
<DL>
<DD>Formats a date/time in 'long' style.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>date</CODE> - The date to format.<DT><B>Returns:</B><DD>The formatted date as text.</DL>
</DD>
</DL>
<HR>
<A NAME="formatArray(java.lang.Object)"><!-- --></A><H3>
formatArray</H3>
<PRE>
public java.lang.String <B>formatArray</B>(java.lang.Object&nbsp;array)</PRE>
<DL>
<DD>Formats an array into the form "A, B and C".<DD><DL>
<DT><B>Parameters:</B><DD><CODE>array</CODE> - An Object.<DT><B>Returns:</B><DD>A String.</DL>
</DD>
</DL>
<HR>
<A NAME="formatArray(java.lang.Object, java.lang.String)"><!-- --></A><H3>
formatArray</H3>
<PRE>
public java.lang.String <B>formatArray</B>(java.lang.Object&nbsp;array,
java.lang.String&nbsp;delim)</PRE>
<DL>
<DD>Formats an array into the form
"A&lt;delim&gt;B&lt;delim&gt;C".<DD><DL>
<DT><B>Parameters:</B><DD><CODE>array</CODE> - An Object.<DD><CODE>delim</CODE> - A String.<DT><B>Returns:</B><DD>A String.</DL>
</DD>
</DL>
<HR>
<A NAME="formatArray(java.lang.Object, java.lang.String, java.lang.String)"><!-- --></A><H3>
formatArray</H3>
<PRE>
public java.lang.String <B>formatArray</B>(java.lang.Object&nbsp;array,
java.lang.String&nbsp;delim,
java.lang.String&nbsp;finaldelim)</PRE>
<DL>
<DD>Formats an array into the form
"A&lt;delim&gt;B&lt;finaldelim&gt;C".<DD><DL>
<DT><B>Parameters:</B><DD><CODE>array</CODE> - An Object.<DD><CODE>delim</CODE> - A String.<DD><CODE>finalDelim</CODE> - A String.<DT><B>Returns:</B><DD>A String.</DL>
</DD>
</DL>
<HR>
<A NAME="formatVector(java.util.List)"><!-- --></A><H3>
formatVector</H3>
<PRE>
public java.lang.String <B>formatVector</B>(java.util.List&nbsp;list)</PRE>
<DL>
<DD>Formats a vector into the form "A, B and C".<DD><DL>
<DT><B>Parameters:</B><DD><CODE>list</CODE> - The list of elements to format.<DT><B>Returns:</B><DD>A String.</DL>
</DD>
</DL>
<HR>
<A NAME="formatVector(java.util.List, java.lang.String)"><!-- --></A><H3>
formatVector</H3>
<PRE>
public java.lang.String <B>formatVector</B>(java.util.List&nbsp;list,
java.lang.String&nbsp;delim)</PRE>
<DL>
<DD>Formats a vector into the form "A&lt;delim&gt;B&lt;delim&gt;C".<DD><DL>
<DT><B>Parameters:</B><DD><CODE>list</CODE> - The list of elements to format.<DD><CODE>delim</CODE> - A String.<DT><B>Returns:</B><DD>A String.</DL>
</DD>
</DL>
<HR>
<A NAME="formatVector(java.util.List, java.lang.String, java.lang.String)"><!-- --></A><H3>
formatVector</H3>
<PRE>
public java.lang.String <B>formatVector</B>(java.util.List&nbsp;list,
java.lang.String&nbsp;delim,
java.lang.String&nbsp;finaldelim)</PRE>
<DL>
<DD>Formats a list into the form
"Adelim&gt;B&lt;finaldelim&gt;C".<DD><DL>
<DT><B>Parameters:</B><DD><CODE>list</CODE> - The list of elements to format.<DD><CODE>delim</CODE> - A String.<DD><CODE>finalDelim</CODE> - A String.<DT><B>Returns:</B><DD>A String.</DL>
</DD>
</DL>
<HR>
<A NAME="limitLen(int, java.lang.String)"><!-- --></A><H3>
limitLen</H3>
<PRE>
public java.lang.String <B>limitLen</B>(int&nbsp;maxlen,
java.lang.String&nbsp;string)</PRE>
<DL>
<DD>Limits 'string' to 'maxlen' characters. If the string gets
curtailed, "..." is appended to it.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>maxlen</CODE> - An int with the maximum length.<DD><CODE>string</CODE> - A String.<DT><B>Returns:</B><DD>A String.</DL>
</DD>
</DL>
<HR>
<A NAME="limitLen(int, java.lang.String, java.lang.String)"><!-- --></A><H3>
limitLen</H3>
<PRE>
public java.lang.String <B>limitLen</B>(int&nbsp;maxlen,
java.lang.String&nbsp;string,
java.lang.String&nbsp;suffix)</PRE>
<DL>
<DD>Limits 'string' to 'maxlen' character. If the string gets
curtailed, 'suffix' is appended to it.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>maxlen</CODE> - An int with the maximum length.<DD><CODE>string</CODE> - A String.<DD><CODE>suffix</CODE> - A String.<DT><B>Returns:</B><DD>A String.</DL>
</DD>
</DL>
<HR>
<A NAME="makeAlternator(java.lang.String, java.lang.String, java.lang.String)"><!-- --></A><H3>
makeAlternator</H3>
<PRE>
public java.lang.String <B>makeAlternator</B>(java.lang.String&nbsp;name,
java.lang.String&nbsp;alt1,
java.lang.String&nbsp;alt2)</PRE>
<DL>
<DD>Makes an alternator object that alternates between two values.
<p>Example usage in a Velocity template:
<code><pre>
&lt;table&gt;
$formatter.makeAlternator("rowcolor", "#c0c0c0", "#e0e0e0")
#foreach $item in $items
#begin
&lt;tr&gt;&lt;td bgcolor="$rowcolor"&gt;$item.Name&lt;/td&gt;&lt;/tr&gt;
$rowcolor.alternate()
#end
&lt;/table&gt;
</pre></code><DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - The name for the alternator int the context.<DD><CODE>alt1</CODE> - The first alternate.<DD><CODE>alt2</CODE> - The second alternate.<DT><B>Returns:</B><DD>The newly created instance.</DL>
</DD>
</DL>
<HR>
<A NAME="makeAlternator(java.lang.String, java.lang.String, java.lang.String, java.lang.String)"><!-- --></A><H3>
makeAlternator</H3>
<PRE>
public java.lang.String <B>makeAlternator</B>(java.lang.String&nbsp;name,
java.lang.String&nbsp;alt1,
java.lang.String&nbsp;alt2,
java.lang.String&nbsp;alt3)</PRE>
<DL>
<DD>Makes an alternator object that alternates between three
values.<DD><DL>
<DT><B>See Also: </B><DD><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#makeAlternator(java.lang.String, java.lang.String, java.lang.String)"><CODE>makeAlternator(String name, String alt1, String alt2)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="makeAlternator(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)"><!-- --></A><H3>
makeAlternator</H3>
<PRE>
public java.lang.String <B>makeAlternator</B>(java.lang.String&nbsp;name,
java.lang.String&nbsp;alt1,
java.lang.String&nbsp;alt2,
java.lang.String&nbsp;alt3,
java.lang.String&nbsp;alt4)</PRE>
<DL>
<DD>Makes an alternator object that alternates between four values.<DD><DL>
<DT><B>See Also: </B><DD><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#makeAlternator(java.lang.String, java.lang.String, java.lang.String)"><CODE>makeAlternator(String name, String alt1, String alt2)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="makeAutoAlternator(java.lang.String, java.lang.String, java.lang.String)"><!-- --></A><H3>
makeAutoAlternator</H3>
<PRE>
public java.lang.String <B>makeAutoAlternator</B>(java.lang.String&nbsp;name,
java.lang.String&nbsp;alt1,
java.lang.String&nbsp;alt2)</PRE>
<DL>
<DD>Makes an alternator object that alternates between two values
automatically.<DD><DL>
<DT><B>See Also: </B><DD><A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.html#makeAlternator(java.lang.String, java.lang.String, java.lang.String)"><CODE>makeAlternator(String name, String alt1, String alt2)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="isNull(java.lang.Object, java.lang.Object)"><!-- --></A><H3>
isNull</H3>
<PRE>
public java.lang.Object <B>isNull</B>(java.lang.Object&nbsp;o,
java.lang.Object&nbsp;dflt)</PRE>
<DL>
<DD>Returns a default value if the object passed is null.</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_bottom"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/VelocityFormatter.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;PREV CLASS&nbsp;
&nbsp;<A HREF="../../../../../org/apache/velocity/app/tools/VelocityFormatter.VelocityAlternator.html"><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> &nbsp;
&nbsp;<A HREF="VelocityFormatter.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: &nbsp;<A HREF="#inner_class_summary">INNER</A>&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: &nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
Copyright © 2002 Apache Software Foundation. All Rights Reserved.
</BODY>
</HTML>