KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jahia.content;
2
3 import java.util.ArrayList JavaDoc;
4
5 import org.jahia.exceptions.JahiaException;
6 import org.jahia.services.usermanager.JahiaUser;
7 import org.jahia.services.version.EntryLoadRequest;
8
9 /**
10  *
11  * <p>Title: Abstract Content Tree Visitor </p>
12  * <p>Description: </p>
13  * <p>Copyright: Copyright (c) 2002</p>
14  * <p>Company: </p>
15  * @author Khue Nguyen
16  * @version 1.0
17  */

18 public abstract class AbstractContentTreeVisitor implements ContentTreeVisitorInterface {
19
20     private int descendingPageLevel = 0;
21     private boolean withChildsContent = true;
22     private JahiaUser user;
23     private EntryLoadRequest loadRequest;
24     private String JavaDoc operationMode;
25
26     protected AbstractContentTreeVisitor(JahiaUser user,
27                                           EntryLoadRequest loadRequest,
28                                           String JavaDoc operationMode){
29         this.user = user;
30         this.loadRequest = loadRequest;
31         this.operationMode = operationMode;
32     }
33
34     /**
35      * Returns the internal user used to check rights access
36      * @return
37      */

38     public JahiaUser getUser(){
39         return this.user;
40     }
41
42     /**
43      * Set the internal user used to check rights access
44      * @param user
45      */

46     public void setUser(JahiaUser user){
47         this.user = user;
48     }
49
50     /**
51      * Returns the internal EntryLoadRequest used to retrieve's Content Object Childs.
52      * @return
53      */

54     public EntryLoadRequest getEntryLoadRequest(){
55         return this.loadRequest;
56     }
57
58     /**
59      * Set the EntryLoadRequest used to retrieve's Content Object Childs.
60      * @param loadRequest
61      */

62     public void setEntryLoadRequest(EntryLoadRequest loadRequest){
63         this.loadRequest = loadRequest;
64     }
65
66     /**
67      * Returns the internal OperationMode used to retrieve Content Object Childs.
68      * @return
69      */

70     public String JavaDoc getOperationMode(){
71         return this.operationMode;
72     }
73
74     /**
75      * Set the internal OperationMode used to retrieve's Content Object Childs.
76      * @param operationMode
77      */

78     public void setOperationMode(String JavaDoc operationMode){
79         this.operationMode = operationMode;
80     }
81
82     /**
83      * Returns the descending page level from the root page.
84      * @return
85      */

86     public int getDescendingPageLevel(){
87         return this.descendingPageLevel;
88     }
89
90     /**
91      * Set the descending page level.
92      */

93     public void setDescendingPageLevel(int level){
94         this.descendingPageLevel = level;
95     }
96
97     /**
98      * Return the internal ContentTree used to traverse the Content Tree
99      *
100      * @return
101      */

102     public abstract ContentTree getContentTree();
103
104     /**
105      * Returns true if the ContentTree should iterate on childs
106      *
107      * @return
108      */

109     public boolean withChildsContent(){
110         return this.withChildsContent;
111     }
112
113     /**
114      * Set if the ContentTree should iterate on childs
115      *
116      *
117      * @param value
118      * @return
119      */

120     public void withChildsContent(boolean value){
121         this.withChildsContent = value;
122     }
123
124     /**
125      * Returns a ContentTreeStatus implementation for a given ContentObject
126      *
127      * @param contentObject
128      * @return
129      */

130     public abstract ContentTreeStatusInterface getContentTreeStatus(ContentObject contentObject,
131             int currentPageLevel) throws JahiaException;
132
133     /**
134      * Returns an array list of childs for a given ContentObject
135      *
136      * @param contentObject
137      * @param currentPageLevel
138      * @return
139      */

140     public ArrayList JavaDoc getChilds(ContentObject contentObject,
141                                int currentPageLevel)
142     throws JahiaException {
143
144         return this.getContentTree().getContentChilds(contentObject,user,
145                 loadRequest,operationMode);
146     }
147
148     /**
149      * Called before processing the current content object's childs
150      *
151      * @param contentObject
152      * @param contentStatusInterface
153      * @param currentPageLevel
154      * @throws JahiaException
155      */

156     public void processContentObjectBeforeChilds(
157             ContentObject contentObject, int currentPageLevel)
158     throws JahiaException{
159         // do nothing by default
160
}
161
162     /**
163      * Called after processing the current object's childs when traversing the tree
164      *
165      * @param contentObject
166      * @param currentPageLevel
167      * @throws JahiaException
168      */

169     public void processContentObjectAfterChilds(
170             ContentObject contentObject, int currentPageLevel)
171     throws JahiaException{
172         // do nothing by default
173
}
174
175     /**
176      * Called after the childs has been processed and the ContentTreeStatus has been
177      * set with continueAfterChilds = false. usually, we should simply do nothing with
178      * the contentObject, as requested by one of this child.
179      *
180      * @param contentObject
181      * @param currentPageLevel
182      * @throws JahiaException
183      */

184     public void stopProcessContentObjectAfterChilds(
185         ContentObject contentObject, int currentPageLevel)
186         throws JahiaException {
187         // do nothing by default
188
}
189
190     /**
191      * Process the Last Content page Field on which, we reached the page level limit when
192      * descending in subtree.
193      *
194      * @param contentObject the last content page field on which we reach the page level limit.
195      * @param currentPageLevel
196      * @throws JahiaException
197      */

198     public void processLastContentPageField(
199             ContentObject contentObject, int currentPageLevel)
200     throws JahiaException{
201         // do nothing by default
202
}
203
204 }
205
Popular Tags