Modified: jakarta/velocity/tools/trunk/docs/javadoc/org/apache/velocity/tools/generic/SortTool.html URL: http://svn.apache.org/viewvc/jakarta/velocity/tools/trunk/docs/javadoc/org/apache/velocity/tools/generic/SortTool.html?view=diff&rev=477914&r1=477913&r2=477914 ============================================================================== --- jakarta/velocity/tools/trunk/docs/javadoc/org/apache/velocity/tools/generic/SortTool.html (original) +++ jakarta/velocity/tools/trunk/docs/javadoc/org/apache/velocity/tools/generic/SortTool.html Tue Nov 21 13:52:11 2006 @@ -1,514 +1,514 @@ -<!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.5.0_02) on Thu Oct 20 10:35:34 PDT 2005 --> -<TITLE> -SortTool (Velocity Tools 1.2 Documentation) -</TITLE> - -<META NAME="keywords" CONTENT="org.apache.velocity.tools.generic.SortTool class"> - -<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style"> - -<SCRIPT type="text/javascript"> -function windowTitle() -{ - parent.document.title="SortTool (Velocity Tools 1.2 Documentation)"; -} -</SCRIPT> -<NOSCRIPT> -</NOSCRIPT> - -</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=2 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/RenderTool.html" title="class in org.apache.velocity.tools.generic"><B>PREV CLASS</B></A> - <A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.PropertiesComparator.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?org/apache/velocity/tools/generic/SortTool.html" target="_top"><B>FRAMES</B></A> - <A HREF="SortTool.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: <A HREF="#nested_class_summary">NESTED</A> | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> -<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> -DETAIL: FIELD | <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 SortTool</H2> -<PRE> -java.lang.Object - <IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><B>org.apache.velocity.tools.generic.SortTool</B> -</PRE> -<HR> -<DL> -<DT><PRE>public class <B>SortTool</B><DT>extends java.lang.Object</DL> -</PRE> - -<P> -SortTool allows a user to sort a collection (or array, iterator, etc) - on any arbitary set of properties exposed by the objects contained - within the collection. - - <p>The sort tool is specifically designed to use within a #foreach - but you may find other uses for it.</p> - - <p>The sort tool can handle all of the collection types supported by - #foreach and the same constraints apply as well as the following. - Every object in the collection must support the set of properties - selected to sort on. Each property which is to be sorted on must - return one of the follow: - <ul> - <li>Primitive type: e.g. int, char, long etc</li> - <li>Standard Object: e.g. String, Integer, Long etc</li> - <li>Object which implements the Comparable interface.</li> - </ul> - </p> - - <p>During the sort operation all properties are compared by calling - compareTo() with the exception of Strings for which - compareToIgnoreCase() is called.</p> - - <p>The sort is performed by calling Collections.sort() after - marshalling the collection to sort into an appropriate collection type. - The original collection will not be re-ordered; a new list containing - the sorted elements will always be returned.</p> - - <p>The tool is used as follows: - <pre> - Single Property Sort - #foreach($obj in $sorter.sort($objects, "name")) - $obj.name Ordinal= $obj.ordinal - #end - End - - Multiple Property Sort - #foreach($obj in $sorter.sort($objects, ["name", "ordinal"])) - $obj.name, $obj.ordinal - #end - End - </pre> - - The sort method takes two parameters a collection and a property name - or an array of property names. The property names and corresponding - methods must conform to java bean standards since commons-beanutils - is used to extract the property values.</p> - - <p>By default the sort tool sorts ascending, you can override this by - adding a sort type suffix to any property name.</p> - - <p>The supported suffixes are: - <pre> - For ascending - :asc - For descending - :desc - - Example - #foreach($obj in $sorter.sort($objects, ["name:asc", "ordinal:desc"])) - $obj.name, $obj.ordinal - #end - </pre><p> - - <p>This will sort first by Name in ascending order and then by Ordinal - in descending order, of course you could have left the :asc off of the - 'Name' property as ascending is always the default.</p> -<P> - -<P> -<DL> -<DT><B>Since:</B></DT> - <DD>VelocityTools 1.2</DD> -<DT><B>Version:</B></DT> - <DD>$Id: SortTool.java 72079 2004-07-22 01:27:12Z nbubna $</DD> -<DT><B>Author:</B></DT> - <DD>S. Brett Sutton, Nathan Bubna</DD> -</DL> -<HR> - -<P> -<!-- ======== NESTED CLASS SUMMARY ======== --> - -<A NAME="nested_class_summary"><!-- --></A> -<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> -<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> -<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> -<B>Nested Class Summary</B></FONT></TH> -</TR> -<TR BGCOLOR="white" CLASS="TableRowColor"> -<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> -<CODE> class</CODE></FONT></TD> -<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.PropertiesComparator.html" title="class in org.apache.velocity.tools.generic">SortTool.PropertiesComparator</A></B></CODE> - -<BR> - Does all of the comparisons</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"> -<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> -<B>Constructor Summary</B></FONT></TH> -</TR> -<TR BGCOLOR="white" CLASS="TableRowColor"> -<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#SortTool()">SortTool</A></B>()</CODE> - -<BR> - </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"> -<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> -<B>Method Summary</B></FONT></TH> -</TR> -<TR BGCOLOR="white" CLASS="TableRowColor"> -<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> -<CODE>protected static java.lang.Comparable</CODE></FONT></TD> -<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#getComparable(java.lang.Object, java.lang.String)">getComparable</A></B>(java.lang.Object object, - java.lang.String property)</CODE> - -<BR> - Safely retrieves the comparable value for the specified property - from the specified object.</TD> -</TR> -<TR BGCOLOR="white" CLASS="TableRowColor"> -<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> -<CODE>protected java.util.Collection</CODE></FONT></TD> -<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#internalSort(java.util.List, java.util.List)">internalSort</A></B>(java.util.List list, - java.util.List properties)</CODE> - -<BR> - </TD> -</TR> -<TR BGCOLOR="white" CLASS="TableRowColor"> -<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> -<CODE> java.util.Collection</CODE></FONT></TD> -<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#sort(java.util.Collection)">sort</A></B>(java.util.Collection collection)</CODE> - -<BR> - </TD> -</TR> -<TR BGCOLOR="white" CLASS="TableRowColor"> -<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> -<CODE> java.util.Collection</CODE></FONT></TD> -<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#sort(java.util.Collection, java.util.List)">sort</A></B>(java.util.Collection collection, - java.util.List properties)</CODE> - -<BR> - </TD> -</TR> -<TR BGCOLOR="white" CLASS="TableRowColor"> -<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> -<CODE> java.util.Collection</CODE></FONT></TD> -<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#sort(java.util.Map)">sort</A></B>(java.util.Map map)</CODE> - -<BR> - </TD> -</TR> -<TR BGCOLOR="white" CLASS="TableRowColor"> -<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> -<CODE> java.util.Collection</CODE></FONT></TD> -<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#sort(java.util.Map, java.util.List)">sort</A></B>(java.util.Map map, - java.util.List properties)</CODE> - -<BR> - </TD> -</TR> -<TR BGCOLOR="white" CLASS="TableRowColor"> -<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> -<CODE> java.util.Collection</CODE></FONT></TD> -<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#sort(java.lang.Object[])">sort</A></B>(java.lang.Object[] array)</CODE> - -<BR> - </TD> -</TR> -<TR BGCOLOR="white" CLASS="TableRowColor"> -<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> -<CODE> java.util.Collection</CODE></FONT></TD> -<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#sort(java.lang.Object[], java.util.List)">sort</A></B>(java.lang.Object[] array, - java.util.List properties)</CODE> - -<BR> - </TD> -</TR> -<TR BGCOLOR="white" CLASS="TableRowColor"> -<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> -<CODE> java.util.Collection</CODE></FONT></TD> -<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#sort(java.lang.Object, java.lang.String)">sort</A></B>(java.lang.Object object, - java.lang.String property)</CODE> - -<BR> - Sorts the collection on a single property.</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"> -<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH> -</TR> -<TR BGCOLOR="white" CLASS="TableRowColor"> -<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD> -</TR> -</TABLE> - -<P> - -<!-- ========= CONSTRUCTOR DETAIL ======== --> - -<A NAME="constructor_detail"><!-- --></A> -<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> -<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> -<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> -<B>Constructor Detail</B></FONT></TH> -</TR> -</TABLE> - -<A NAME="SortTool()"><!-- --></A><H3> -SortTool</H3> -<PRE> -public <B>SortTool</B>()</PRE> -<DL> -</DL> - -<!-- ============ METHOD DETAIL ========== --> - -<A NAME="method_detail"><!-- --></A> -<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> -<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> -<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> -<B>Method Detail</B></FONT></TH> -</TR> -</TABLE> - -<A NAME="sort(java.util.Collection)"><!-- --></A><H3> -sort</H3> -<PRE> -public java.util.Collection <B>sort</B>(java.util.Collection collection)</PRE> -<DL> -<DD><DL> -</DL> -</DD> -</DL> -<HR> - -<A NAME="sort(java.lang.Object[])"><!-- --></A><H3> -sort</H3> -<PRE> -public java.util.Collection <B>sort</B>(java.lang.Object[] array)</PRE> -<DL> -<DD><DL> -</DL> -</DD> -</DL> -<HR> - -<A NAME="sort(java.util.Map)"><!-- --></A><H3> -sort</H3> -<PRE> -public java.util.Collection <B>sort</B>(java.util.Map map)</PRE> -<DL> -<DD><DL> -</DL> -</DD> -</DL> -<HR> - -<A NAME="sort(java.lang.Object, java.lang.String)"><!-- --></A><H3> -sort</H3> -<PRE> -public java.util.Collection <B>sort</B>(java.lang.Object object, - java.lang.String property)</PRE> -<DL> -<DD>Sorts the collection on a single property. -<P> -<DD><DL> -<DT><B>Parameters:</B><DD><CODE>object</CODE> - the collection to be sorted.<DD><CODE>property</CODE> - the property to sort on.</DL> -</DD> -</DL> -<HR> - -<A NAME="sort(java.util.Collection, java.util.List)"><!-- --></A><H3> -sort</H3> -<PRE> -public java.util.Collection <B>sort</B>(java.util.Collection collection, - java.util.List properties)</PRE> -<DL> -<DD><DL> -</DL> -</DD> -</DL> -<HR> - -<A NAME="sort(java.util.Map, java.util.List)"><!-- --></A><H3> -sort</H3> -<PRE> -public java.util.Collection <B>sort</B>(java.util.Map map, - java.util.List properties)</PRE> -<DL> -<DD><DL> -</DL> -</DD> -</DL> -<HR> - -<A NAME="sort(java.lang.Object[], java.util.List)"><!-- --></A><H3> -sort</H3> -<PRE> -public java.util.Collection <B>sort</B>(java.lang.Object[] array, - java.util.List properties)</PRE> -<DL> -<DD><DL> -</DL> -</DD> -</DL> -<HR> - -<A NAME="internalSort(java.util.List, java.util.List)"><!-- --></A><H3> -internalSort</H3> -<PRE> -protected java.util.Collection <B>internalSort</B>(java.util.List list, - java.util.List properties)</PRE> -<DL> -<DD><DL> -</DL> -</DD> -</DL> -<HR> - -<A NAME="getComparable(java.lang.Object, java.lang.String)"><!-- --></A><H3> -getComparable</H3> -<PRE> -protected static java.lang.Comparable <B>getComparable</B>(java.lang.Object object, - java.lang.String property)</PRE> -<DL> -<DD>Safely retrieves the comparable value for the specified property - from the specified object. Subclasses that wish to perform more - advanced, efficient, or just different property retrieval methods - should override this method to do so. -<P> -<DD><DL> -</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=2 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/RenderTool.html" title="class in org.apache.velocity.tools.generic"><B>PREV CLASS</B></A> - <A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.PropertiesComparator.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?org/apache/velocity/tools/generic/SortTool.html" target="_top"><B>FRAMES</B></A> - <A HREF="SortTool.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: <A HREF="#nested_class_summary">NESTED</A> | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> -<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> -DETAIL: FIELD | <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> +<!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.5.0_09) on Tue Nov 21 22:45:25 CET 2006 --> +<TITLE> +SortTool (Velocity Tools 1.3-dev Documentation) +</TITLE> + +<META NAME="keywords" CONTENT="org.apache.velocity.tools.generic.SortTool class"> + +<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style"> + +<SCRIPT type="text/javascript"> +function windowTitle() +{ + parent.document.title="SortTool (Velocity Tools 1.3-dev Documentation)"; +} +</SCRIPT> +<NOSCRIPT> +</NOSCRIPT> + +</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=2 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/RenderTool.html" title="class in org.apache.velocity.tools.generic"><B>PREV CLASS</B></A> + <A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.PropertiesComparator.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?org/apache/velocity/tools/generic/SortTool.html" target="_top"><B>FRAMES</B></A> + <A HREF="SortTool.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: <A HREF="#nested_class_summary">NESTED</A> | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> +<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> +DETAIL: FIELD | <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 SortTool</H2> +<PRE> +java.lang.Object + <IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><B>org.apache.velocity.tools.generic.SortTool</B> +</PRE> +<HR> +<DL> +<DT><PRE>public class <B>SortTool</B><DT>extends java.lang.Object</DL> +</PRE> + +<P> +SortTool allows a user to sort a collection (or array, iterator, etc) + on any arbitary set of properties exposed by the objects contained + within the collection. + + <p>The sort tool is specifically designed to use within a #foreach + but you may find other uses for it.</p> + + <p>The sort tool can handle all of the collection types supported by + #foreach and the same constraints apply as well as the following. + Every object in the collection must support the set of properties + selected to sort on. Each property which is to be sorted on must + return one of the follow: + <ul> + <li>Primitive type: e.g. int, char, long etc</li> + <li>Standard Object: e.g. String, Integer, Long etc</li> + <li>Object which implements the Comparable interface.</li> + </ul> + </p> + + <p>During the sort operation all properties are compared by calling + compareTo() with the exception of Strings for which + compareToIgnoreCase() is called.</p> + + <p>The sort is performed by calling Collections.sort() after + marshalling the collection to sort into an appropriate collection type. + The original collection will not be re-ordered; a new list containing + the sorted elements will always be returned.</p> + + <p>The tool is used as follows: + <pre> + Single Property Sort + #foreach($obj in $sorter.sort($objects, "name")) + $obj.name Ordinal= $obj.ordinal + #end + End + + Multiple Property Sort + #foreach($obj in $sorter.sort($objects, ["name", "ordinal"])) + $obj.name, $obj.ordinal + #end + End + </pre> + + The sort method takes two parameters a collection and a property name + or an array of property names. The property names and corresponding + methods must conform to java bean standards since commons-beanutils + is used to extract the property values.</p> + + <p>By default the sort tool sorts ascending, you can override this by + adding a sort type suffix to any property name.</p> + + <p>The supported suffixes are: + <pre> + For ascending + :asc + For descending + :desc + + Example + #foreach($obj in $sorter.sort($objects, ["name:asc", "ordinal:desc"])) + $obj.name, $obj.ordinal + #end + </pre><p> + + <p>This will sort first by Name in ascending order and then by Ordinal + in descending order, of course you could have left the :asc off of the + 'Name' property as ascending is always the default.</p> +<P> + +<P> +<DL> +<DT><B>Since:</B></DT> + <DD>VelocityTools 1.2</DD> +<DT><B>Version:</B></DT> + <DD>$Id: SortTool.java 385138 2006-03-11 19:01:28Z nbubna $</DD> +<DT><B>Author:</B></DT> + <DD>S. Brett Sutton, Nathan Bubna</DD> +</DL> +<HR> + +<P> +<!-- ======== NESTED CLASS SUMMARY ======== --> + +<A NAME="nested_class_summary"><!-- --></A> +<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> +<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> +<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> +<B>Nested Class Summary</B></FONT></TH> +</TR> +<TR BGCOLOR="white" CLASS="TableRowColor"> +<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> +<CODE> class</CODE></FONT></TD> +<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.PropertiesComparator.html" title="class in org.apache.velocity.tools.generic">SortTool.PropertiesComparator</A></B></CODE> + +<BR> + Does all of the comparisons</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"> +<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> +<B>Constructor Summary</B></FONT></TH> +</TR> +<TR BGCOLOR="white" CLASS="TableRowColor"> +<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#SortTool()">SortTool</A></B>()</CODE> + +<BR> + </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"> +<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> +<B>Method Summary</B></FONT></TH> +</TR> +<TR BGCOLOR="white" CLASS="TableRowColor"> +<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> +<CODE>protected static java.lang.Comparable</CODE></FONT></TD> +<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#getComparable(java.lang.Object, java.lang.String)">getComparable</A></B>(java.lang.Object object, + java.lang.String property)</CODE> + +<BR> + Safely retrieves the comparable value for the specified property + from the specified object.</TD> +</TR> +<TR BGCOLOR="white" CLASS="TableRowColor"> +<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> +<CODE>protected java.util.Collection</CODE></FONT></TD> +<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#internalSort(java.util.List, java.util.List)">internalSort</A></B>(java.util.List list, + java.util.List properties)</CODE> + +<BR> + </TD> +</TR> +<TR BGCOLOR="white" CLASS="TableRowColor"> +<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> +<CODE> java.util.Collection</CODE></FONT></TD> +<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#sort(java.util.Collection)">sort</A></B>(java.util.Collection collection)</CODE> + +<BR> + </TD> +</TR> +<TR BGCOLOR="white" CLASS="TableRowColor"> +<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> +<CODE> java.util.Collection</CODE></FONT></TD> +<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#sort(java.util.Collection, java.util.List)">sort</A></B>(java.util.Collection collection, + java.util.List properties)</CODE> + +<BR> + </TD> +</TR> +<TR BGCOLOR="white" CLASS="TableRowColor"> +<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> +<CODE> java.util.Collection</CODE></FONT></TD> +<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#sort(java.util.Map)">sort</A></B>(java.util.Map map)</CODE> + +<BR> + </TD> +</TR> +<TR BGCOLOR="white" CLASS="TableRowColor"> +<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> +<CODE> java.util.Collection</CODE></FONT></TD> +<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#sort(java.util.Map, java.util.List)">sort</A></B>(java.util.Map map, + java.util.List properties)</CODE> + +<BR> + </TD> +</TR> +<TR BGCOLOR="white" CLASS="TableRowColor"> +<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> +<CODE> java.util.Collection</CODE></FONT></TD> +<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#sort(java.lang.Object[])">sort</A></B>(java.lang.Object[] array)</CODE> + +<BR> + </TD> +</TR> +<TR BGCOLOR="white" CLASS="TableRowColor"> +<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> +<CODE> java.util.Collection</CODE></FONT></TD> +<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#sort(java.lang.Object[], java.util.List)">sort</A></B>(java.lang.Object[] array, + java.util.List properties)</CODE> + +<BR> + </TD> +</TR> +<TR BGCOLOR="white" CLASS="TableRowColor"> +<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> +<CODE> java.util.Collection</CODE></FONT></TD> +<TD><CODE><B><A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.html#sort(java.lang.Object, java.lang.String)">sort</A></B>(java.lang.Object object, + java.lang.String property)</CODE> + +<BR> + Sorts the collection on a single property.</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"> +<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH> +</TR> +<TR BGCOLOR="white" CLASS="TableRowColor"> +<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD> +</TR> +</TABLE> + +<P> + +<!-- ========= CONSTRUCTOR DETAIL ======== --> + +<A NAME="constructor_detail"><!-- --></A> +<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> +<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> +<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> +<B>Constructor Detail</B></FONT></TH> +</TR> +</TABLE> + +<A NAME="SortTool()"><!-- --></A><H3> +SortTool</H3> +<PRE> +public <B>SortTool</B>()</PRE> +<DL> +</DL> + +<!-- ============ METHOD DETAIL ========== --> + +<A NAME="method_detail"><!-- --></A> +<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> +<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> +<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> +<B>Method Detail</B></FONT></TH> +</TR> +</TABLE> + +<A NAME="sort(java.util.Collection)"><!-- --></A><H3> +sort</H3> +<PRE> +public java.util.Collection <B>sort</B>(java.util.Collection collection)</PRE> +<DL> +<DD><DL> +</DL> +</DD> +</DL> +<HR> + +<A NAME="sort(java.lang.Object[])"><!-- --></A><H3> +sort</H3> +<PRE> +public java.util.Collection <B>sort</B>(java.lang.Object[] array)</PRE> +<DL> +<DD><DL> +</DL> +</DD> +</DL> +<HR> + +<A NAME="sort(java.util.Map)"><!-- --></A><H3> +sort</H3> +<PRE> +public java.util.Collection <B>sort</B>(java.util.Map map)</PRE> +<DL> +<DD><DL> +</DL> +</DD> +</DL> +<HR> + +<A NAME="sort(java.lang.Object, java.lang.String)"><!-- --></A><H3> +sort</H3> +<PRE> +public java.util.Collection <B>sort</B>(java.lang.Object object, + java.lang.String property)</PRE> +<DL> +<DD>Sorts the collection on a single property. +<P> +<DD><DL> +<DT><B>Parameters:</B><DD><CODE>object</CODE> - the collection to be sorted.<DD><CODE>property</CODE> - the property to sort on.</DL> +</DD> +</DL> +<HR> + +<A NAME="sort(java.util.Collection, java.util.List)"><!-- --></A><H3> +sort</H3> +<PRE> +public java.util.Collection <B>sort</B>(java.util.Collection collection, + java.util.List properties)</PRE> +<DL> +<DD><DL> +</DL> +</DD> +</DL> +<HR> + +<A NAME="sort(java.util.Map, java.util.List)"><!-- --></A><H3> +sort</H3> +<PRE> +public java.util.Collection <B>sort</B>(java.util.Map map, + java.util.List properties)</PRE> +<DL> +<DD><DL> +</DL> +</DD> +</DL> +<HR> + +<A NAME="sort(java.lang.Object[], java.util.List)"><!-- --></A><H3> +sort</H3> +<PRE> +public java.util.Collection <B>sort</B>(java.lang.Object[] array, + java.util.List properties)</PRE> +<DL> +<DD><DL> +</DL> +</DD> +</DL> +<HR> + +<A NAME="internalSort(java.util.List, java.util.List)"><!-- --></A><H3> +internalSort</H3> +<PRE> +protected java.util.Collection <B>internalSort</B>(java.util.List list, + java.util.List properties)</PRE> +<DL> +<DD><DL> +</DL> +</DD> +</DL> +<HR> + +<A NAME="getComparable(java.lang.Object, java.lang.String)"><!-- --></A><H3> +getComparable</H3> +<PRE> +protected static java.lang.Comparable <B>getComparable</B>(java.lang.Object object, + java.lang.String property)</PRE> +<DL> +<DD>Safely retrieves the comparable value for the specified property + from the specified object. Subclasses that wish to perform more + advanced, efficient, or just different property retrieval methods + should override this method to do so. +<P> +<DD><DL> +</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=2 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/RenderTool.html" title="class in org.apache.velocity.tools.generic"><B>PREV CLASS</B></A> + <A HREF="../../../../../org/apache/velocity/tools/generic/SortTool.PropertiesComparator.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?org/apache/velocity/tools/generic/SortTool.html" target="_top"><B>FRAMES</B></A> + <A HREF="SortTool.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: <A HREF="#nested_class_summary">NESTED</A> | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> +<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> +DETAIL: FIELD | <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-2006 Apache Software Foundation +</BODY> +</HTML>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
