| java.lang.Object org.apache.velocity.app.tools.VelocityFormatter
VelocityFormatter | public class VelocityFormatter (Code) | | Formatting tool for inserting into the Velocity WebContext. Can
format dates or lists of objects.
Here's an example of some uses:
$formatter.formatShortDate($object.Date)
$formatter.formatLongDate($db.getRecord(232).getDate())
$formatter.formatArray($array)
$formatter.limitLen(30, $object.Description)
author: Sean Legassick author: Daniel Rall version: $Id: VelocityFormatter.java 463298 2006-10-12 16:10:32Z henning $ |
Inner Class :public class VelocityAlternator | |
Inner Class :public class VelocityAutoAlternator extends VelocityAlternator | |
Method Summary | |
public String | formatArray(Object array) Formats an array into the form "A, B and C".
Parameters: array - An Object. | public String | formatArray(Object array, String delim) Formats an array into the form
"A<delim>B<delim>C".
Parameters: array - An Object. Parameters: delim - A String. | public String | formatArray(Object array, String delim, String finaldelim) Formats an array into the form
"A<delim>B<finaldelim>C".
Parameters: array - An Object. Parameters: delim - A String. Parameters: finaldelim - A String. | public String | formatLongDate(Date date) Formats a date in DateFormat.LONG style.
Parameters: date - The date to format. | public String | formatLongDateTime(Date date) Formats a date/time in 'long' style.
Parameters: date - The date to format. | public String | formatShortDate(Date date) Formats a date in DateFormat.SHORT style.
Parameters: date - The date to format. | public String | formatShortDateTime(Date date) Formats a date/time in 'short' style.
Parameters: date - The date to format. | public String | formatVector(List list) Formats a vector into the form "A, B and C".
Parameters: list - The list of elements to format. | public String | formatVector(List list, String delim) Formats a vector into the form "A<delim>B<delim>C".
Parameters: list - The list of elements to format. Parameters: delim - A String. | public String | formatVector(List list, String delim, String finaldelim) Formats a list into the form
"Adelim>B<finaldelim>C".
Parameters: list - The list of elements to format. Parameters: delim - A String. Parameters: finaldelim - A String. | public Object | isNull(Object o, Object dflt) Returns a default value if the object passed is null. | public String | limitLen(int maxlen, String string) Limits 'string' to 'maxlen' characters. | public String | limitLen(int maxlen, String string, String suffix) Limits 'string' to 'maxlen' character. | public String | makeAlternator(String name, String alt1, String alt2) Makes an alternator object that alternates between two values.
Example usage in a Velocity template:
<table>
$formatter.makeAlternator("rowcolor", "#c0c0c0", "#e0e0e0")
#foreach $item in $items
#begin
<tr><td bgcolor="$rowcolor">$item.Name</td></tr>
$rowcolor.alternate()
#end
</table>
Parameters: name - The name for the alternator int the context. Parameters: alt1 - The first alternate. Parameters: alt2 - The second alternate. | public String | makeAlternator(String name, String alt1, String alt2, String alt3) Makes an alternator object that alternates between three
values. | public String | makeAlternator(String name, String alt1, String alt2, String alt3, String alt4) Makes an alternator object that alternates between four values. | public String | makeAutoAlternator(String name, String alt1, String alt2) Makes an alternator object that alternates between two values
automatically. |
VelocityFormatter | public VelocityFormatter(Context context)(Code) | | Constructor needs a backpointer to the context.
Parameters: context - A Context. |
formatArray | public String formatArray(Object array)(Code) | | Formats an array into the form "A, B and C".
Parameters: array - An Object. A String. |
formatArray | public String formatArray(Object array, String delim)(Code) | | Formats an array into the form
"A<delim>B<delim>C".
Parameters: array - An Object. Parameters: delim - A String. A String. |
formatArray | public String formatArray(Object array, String delim, String finaldelim)(Code) | | Formats an array into the form
"A<delim>B<finaldelim>C".
Parameters: array - An Object. Parameters: delim - A String. Parameters: finaldelim - A String. A String. |
formatLongDate | public String formatLongDate(Date date)(Code) | | Formats a date in DateFormat.LONG style.
Parameters: date - The date to format. The formatted date as text. |
formatLongDateTime | public String formatLongDateTime(Date date)(Code) | | Formats a date/time in 'long' style.
Parameters: date - The date to format. The formatted date as text. |
formatShortDate | public String formatShortDate(Date date)(Code) | | Formats a date in DateFormat.SHORT style.
Parameters: date - The date to format. The formatted date as text. |
formatShortDateTime | public String formatShortDateTime(Date date)(Code) | | Formats a date/time in 'short' style.
Parameters: date - The date to format. The formatted date as text. |
formatVector | public String formatVector(List list)(Code) | | Formats a vector into the form "A, B and C".
Parameters: list - The list of elements to format. A String. |
formatVector | public String formatVector(List list, String delim)(Code) | | Formats a vector into the form "A<delim>B<delim>C".
Parameters: list - The list of elements to format. Parameters: delim - A String. A String. |
formatVector | public String formatVector(List list, String delim, String finaldelim)(Code) | | Formats a list into the form
"Adelim>B<finaldelim>C".
Parameters: list - The list of elements to format. Parameters: delim - A String. Parameters: finaldelim - A String. A String. |
isNull | public Object isNull(Object o, Object dflt)(Code) | | Returns a default value if the object passed is null.
Parameters: o - Parameters: dflt - Object or default value when object is null. |
limitLen | public String limitLen(int maxlen, String string)(Code) | | Limits 'string' to 'maxlen' characters. If the string gets
curtailed, "..." is appended to it.
Parameters: maxlen - An int with the maximum length. Parameters: string - A String. A String. |
limitLen | public String limitLen(int maxlen, String string, String suffix)(Code) | | Limits 'string' to 'maxlen' character. If the string gets
curtailed, 'suffix' is appended to it.
Parameters: maxlen - An int with the maximum length. Parameters: string - A String. Parameters: suffix - A String. A String. |
makeAlternator | public String makeAlternator(String name, String alt1, String alt2)(Code) | | Makes an alternator object that alternates between two values.
Example usage in a Velocity template:
<table>
$formatter.makeAlternator("rowcolor", "#c0c0c0", "#e0e0e0")
#foreach $item in $items
#begin
<tr><td bgcolor="$rowcolor">$item.Name</td></tr>
$rowcolor.alternate()
#end
</table>
Parameters: name - The name for the alternator int the context. Parameters: alt1 - The first alternate. Parameters: alt2 - The second alternate. The newly created instance. |
|
|