cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From morr...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/generation DirectoryGenerator.java
Date Sun, 19 May 2002 11:42:00 GMT
morrijr     02/05/19 04:42:00

  Modified:    src/documentation/xdocs/userdocs/generators
                        directory-generator.xml
               src/java/org/apache/cocoon/generation
                        DirectoryGenerator.java
  Log:
  Changed default sort to by system dependant
  
  Revision  Changes    Path
  1.4       +4 -4      xml-cocoon2/src/documentation/xdocs/userdocs/generators/directory-generator.xml
  
  Index: directory-generator.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/documentation/xdocs/userdocs/generators/directory-generator.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- directory-generator.xml	17 May 2002 21:50:33 -0000	1.3
  +++ directory-generator.xml	19 May 2002 11:42:00 -0000	1.4
  @@ -70,10 +70,10 @@
                       regular expression.</li>
                   <li>sort (optional) : This parameter determines the order in
                       which the <code>file</code> and <code>directory</code>
nodes
  -                    are returned. Default sort order is by name. Possible
  -                    values are "name", "size", "time", and "directory".
  -                    "directory" is the same as "name", except that directory
  -                    entries are listed first.</li>
  +                    are returned. Default sort order is as defined by the
  +                    system. Possible values are "name", "size", "time", and
  +                    "directory". "directory" is the same as "name", except that
  +                    directory entries are listed first.</li>
                   <li>reverse (optional) : This parameter reverses the sort order.
                       reverse="false" is the default.</li>
               </ul>
  
  
  
  1.9       +17 -17    xml-cocoon2/src/java/org/apache/cocoon/generation/DirectoryGenerator.java
  
  Index: DirectoryGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/DirectoryGenerator.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DirectoryGenerator.java	17 May 2002 11:11:03 -0000	1.8
  +++ DirectoryGenerator.java	19 May 2002 11:42:00 -0000	1.9
  @@ -99,10 +99,10 @@
    * directory's immediate contents will be returned.
    * <dt> <i>sort</i> (optional)
    * <dd> Sort order in which the nodes are returned. Possible values are
  - * name (default), size, time, directory. directory is the same as name,
  - * except that the directory entries are listed first.
  + * name, size, time, directory. directory is the same as name,
  + * except that the directory entries are listed first. System order is default.
    * <dt> <i>reverse</i> (optional)
  - * <dd>
  + * <dd>	Reverse the order of the sort
    * <dt> <i>dateFormat</i> (optional)
    * <dd> Sets the format for the date attribute of each node, as
    * described in java.text.SimpleDateFormat. If unset, the default
  @@ -113,7 +113,7 @@
    *         (Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:conny@smb-tec.com">Conny Krappatsch</a>
    *         (SMB GmbH) for Virbus AG
  - * @version CVS $Id: DirectoryGenerator.java,v 1.8 2002/05/17 11:11:03 morrijr Exp $
  + * @version CVS $Id: DirectoryGenerator.java,v 1.9 2002/05/19 11:42:00 morrijr Exp $
    */
   public class DirectoryGenerator extends ComposerGenerator  {
     private static final String FILE = "file:";
  @@ -308,7 +308,19 @@
               if (depth>0) {
                   File contents[] = path.listFiles();
   
  -				if(sort.equals("size")) {
  +				if(sort.equals("name")) {
  +					Arrays.sort(contents,
  +						new Comparator() {
  +							public int compare(Object o1, Object o2) {
  +								if(reverse) {
  +									return ((File) o2).getName()
  +										.compareTo(((File) o1).getName());
  +								}
  +								return ((File) o1).getName()
  +									.compareTo(((File) o2).getName());
  +							}								
  +						});
  +				} else if(sort.equals("size")) {
   					Arrays.sort(contents,
   						new Comparator() {
   							public int compare(Object o1, Object o2) {
  @@ -351,18 +363,6 @@
   								if(f2.isFile() && f1.isDirectory())
   									return -1;
   								return f1.getName().compareTo(f2.getName());
  -							}								
  -						});
  -				} else { // sort.equals("name")
  -					Arrays.sort(contents,
  -						new Comparator() {
  -							public int compare(Object o1, Object o2) {
  -								if(reverse) {
  -									return ((File) o2).getName()
  -										.compareTo(((File) o1).getName());
  -								}
  -								return ((File) o1).getName()
  -									.compareTo(((File) o2).getName());
   							}								
   						});
   				}
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message