KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > content > ContentTreeList


1 package org.jahia.content;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.Arrays JavaDoc;
5 import java.util.Comparator JavaDoc;
6
7 import org.jahia.exceptions.JahiaException;
8
9 /**
10  * <p>Title: Class to traverse Jahia's Content Tree and maintaining an internal ArrayList of object.</p>
11  * <p>Description: This class define a default implementation for traversing
12  * Jahia's Content Tree.</p>
13  * <p>Copyright: Copyright (c) 2002</p>
14  * <p>Company: </p>
15  * @author Khue Nguyen
16  * @version 1.0
17  */

18
19 public class ContentTreeList extends ContentTree {
20
21     private static org.apache.log4j.Logger logger =
22             org.apache.log4j.Logger.getLogger(ContentTreeList.class);
23
24     private ArrayList JavaDoc list;
25
26     /**
27      * The root content object of the three
28      *
29      * @param rootContentObject
30      */

31     public ContentTreeList(ContentObject rootContentObject) {
32         super(rootContentObject);
33         this.list = new ArrayList JavaDoc();
34     }
35
36     /**
37      * Iterate through the entire Tree
38      * Reset the internal list first before iterating the entire Tree
39      *
40      * @param visitor
41      */

42     public void iterate(ContentTreeVisitorInterface visitor)
43     throws JahiaException {
44         this.list = new ArrayList JavaDoc();
45         super.iterate(visitor);
46     }
47
48     /**
49      * Returns the internal list
50      *
51      * @return
52      */

53     public ArrayList JavaDoc getList(){
54         return this.list;
55     }
56
57     public void sort(Comparator JavaDoc comparator){
58         Object JavaDoc[] array = this.list.toArray();
59         Arrays.sort(array,comparator);
60         this.list = new ArrayList JavaDoc(Arrays.asList(array));
61     }
62 }
Popular Tags