Package org.apache.velocity.app.tools
Class VelocityFormatter
java.lang.Object
org.apache.velocity.app.tools.VelocityFormatter
Deprecated.
This class has been replaced by NumberTool, DateTool,
DisplayTool, and AlternatorTool available from the Velocity-Tools sub-project.
VelocityFormatter will be removed in a future version of Velocity.
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)
- Version:
- $Id: VelocityFormatter.java 544641 2007-06-05 21:30:22Z nbubna $
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Deprecated.Class that returns alternating values in a template.class
Deprecated.As VelocityAlternator, but callsalternate()
automatically on rendering in a template. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionVelocityFormatter
(Context context) Deprecated.Constructor needs a backpointer to the context. -
Method Summary
Modifier and TypeMethodDescriptionformatArray
(Object array) Deprecated.Formats an array into the form "A, B and C".formatArray
(Object array, String delim) Deprecated.Formats an array into the form "A<delim>B<delim>C".formatArray
(Object array, String delim, String finaldelim) Deprecated.Formats an array into the form "A<delim>B<finaldelim>C".formatLongDate
(Date date) Deprecated.Formats a date inDateFormat.LONG
style.formatLongDateTime
(Date date) Deprecated.Formats a date/time in 'long' style.formatShortDate
(Date date) Deprecated.Formats a date inDateFormat.SHORT
style.formatShortDateTime
(Date date) Deprecated.Formats a date/time in 'short' style.formatVector
(List list) Deprecated.Formats a vector into the form "A, B and C".formatVector
(List list, String delim) Deprecated.Formats a vector into the form "A<delim>B<delim>C".formatVector
(List list, String delim, String finaldelim) Deprecated.Formats a list into the form "Adelim>B<finaldelim>C".Deprecated.Returns a default value if the object passed is null.Deprecated.Limits 'string' to 'maxlen' characters.Deprecated.Limits 'string' to 'maxlen' character.makeAlternator
(String name, String alt1, String alt2) Deprecated.Makes an alternator object that alternates between two values.makeAlternator
(String name, String alt1, String alt2, String alt3) Deprecated.Makes an alternator object that alternates between three values.Deprecated.Makes an alternator object that alternates between four values.makeAutoAlternator
(String name, String alt1, String alt2) Deprecated.Makes an alternator object that alternates between two values automatically.
-
Field Details
-
context
Context contextDeprecated.
-
-
Constructor Details
-
VelocityFormatter
Deprecated.Constructor needs a backpointer to the context.- Parameters:
context
- A Context.
-
-
Method Details
-
formatShortDate
Deprecated.Formats a date inDateFormat.SHORT
style.- Parameters:
date
- The date to format.- Returns:
- The formatted date as text.
-
formatLongDate
Deprecated.Formats a date inDateFormat.LONG
style.- Parameters:
date
- The date to format.- Returns:
- The formatted date as text.
-
formatShortDateTime
Deprecated.Formats a date/time in 'short' style.- Parameters:
date
- The date to format.- Returns:
- The formatted date as text.
-
formatLongDateTime
Deprecated.Formats a date/time in 'long' style.- Parameters:
date
- The date to format.- Returns:
- The formatted date as text.
-
formatArray
Deprecated.Formats an array into the form "A, B and C".- Parameters:
array
- An Object.- Returns:
- A String.
-
formatArray
Deprecated.Formats an array into the form "A<delim>B<delim>C".- Parameters:
array
- An Object.delim
- A String.- Returns:
- A String.
-
formatArray
Deprecated.Formats an array into the form "A<delim>B<finaldelim>C".- Parameters:
array
- An Object.delim
- A String.finaldelim
- A String.- Returns:
- A String.
-
formatVector
Deprecated.Formats a vector into the form "A, B and C".- Parameters:
list
- The list of elements to format.- Returns:
- A String.
-
formatVector
Deprecated.Formats a vector into the form "A<delim>B<delim>C".- Parameters:
list
- The list of elements to format.delim
- A String.- Returns:
- A String.
-
formatVector
Deprecated.Formats a list into the form "Adelim>B<finaldelim>C".- Parameters:
list
- The list of elements to format.delim
- A String.finaldelim
- A String.- Returns:
- A String.
-
limitLen
Deprecated.Limits 'string' to 'maxlen' characters. If the string gets curtailed, "..." is appended to it.- Parameters:
maxlen
- An int with the maximum length.string
- A String.- Returns:
- A String.
-
limitLen
Deprecated.Limits 'string' to 'maxlen' character. If the string gets curtailed, 'suffix' is appended to it.- Parameters:
maxlen
- An int with the maximum length.string
- A String.suffix
- A String.- Returns:
- A String.
-
makeAlternator
Deprecated.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.alt1
- The first alternate.alt2
- The second alternate.- Returns:
- The newly created instance.
-
makeAlternator
Deprecated.Makes an alternator object that alternates between three values.- Parameters:
name
-alt1
-alt2
-alt3
-- Returns:
- alternated object.
- See Also:
-
makeAlternator
Deprecated.Makes an alternator object that alternates between four values.- Parameters:
name
-alt1
-alt2
-alt3
-alt4
-- Returns:
- Alternated object.
- See Also:
-
makeAutoAlternator
Deprecated.Makes an alternator object that alternates between two values automatically.- Parameters:
name
-alt1
-alt2
-- Returns:
- Alternated object.
- See Also:
-
isNull
Deprecated.Returns a default value if the object passed is null.- Parameters:
o
-dflt
-- Returns:
- Object or default value when object is null.
-