KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > pluto > portlet > admin > bean > PageTO


1 /*
2  * Copyright 2003,2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.pluto.portlet.admin.bean;
17
18 import java.util.ArrayList JavaDoc;
19 import java.util.Iterator JavaDoc;
20 import java.util.List JavaDoc;
21
22 import org.apache.pluto.portalImpl.om.page.impl.FragmentImpl;
23 import org.apache.pluto.portlet.admin.BaseAdminObject;
24
25 /**
26  * A Transfer Object repesenting a page in pageregistry.xml
27  * where the fragment type equals page. It is used to decouple
28  * the XML persistence model from the JSP view.
29  *
30  * @author Craig Doremus
31  *
32  */

33 public class PageTO extends BaseAdminObject {
34
35     public static final String JavaDoc CLASS_NAME = "PageTO";
36
37     private FragmentImpl _page = null;
38     //By default there will be one row and one col
39
private int _rows = 1;
40     private int _cols = 1;
41     private String JavaDoc _name = "";
42     private String JavaDoc _title = "";
43     private String JavaDoc _description = "";
44     private List JavaDoc _portlets = new ArrayList JavaDoc();
45
46
47     /**
48      *
49      */

50     public PageTO() {
51         super(CLASS_NAME);
52     }
53     /**
54      *
55      */

56     public PageTO(FragmentImpl page) {
57         super(CLASS_NAME);
58         _page = page;
59     }
60
61     /**
62      * @return Returns the cols.
63      */

64     public int getCols() {
65         return _cols;
66     }
67     /**
68     /**
69      * @return Returns the page.
70      */

71     public FragmentImpl getPage() {
72         return _page;
73     }
74     /**
75      * @param page The page to set.
76      */

77     public void setPage(FragmentImpl page) {
78         _page = page;
79         _name = page.getName();
80     }
81     /**
82      * @return Returns the rows.
83      */

84     public int getRows() {
85         return _rows;
86     }
87
88     /**
89      * @param cols The cols to set.
90      */

91     public void setCols(int cols) {
92         _cols = cols;
93     }
94     /**
95      * @param rows The rows to set.
96      */

97     public void setRows(int rows) {
98         _rows = rows;
99     }
100     public String JavaDoc getName() {
101         return _name;
102     }
103
104     /**
105      * @param name The name to set.
106      */

107     public void setName(String JavaDoc name) {
108         _name = name;
109     }
110     public String JavaDoc getTitle(){
111         return _title;
112     }
113
114 /*
115     public void printFragment(FragmentType frag) {
116         final String METHOD_NAME = "printFragment()";
117         List frags = frag.getFragmentOrNavigationOrProperty();
118         Iterator iter = frags.iterator();
119         int count = 0;
120         while (iter.hasNext()) {
121             count++;
122             try {
123                 FragmentType element = (FragmentType) iter.next();
124                 logDebug(METHOD_NAME, "Fragment: " + element.getName() + " type: " + element.getTypeattr());
125             } catch (ClassCastException e) {
126                 logDebug(METHOD_NAME, "Not a fragment: ");
127             }
128             logDebug(METHOD_NAME, "Element number: " + count);
129         }
130     }
131 */

132
133 /*
134     public void recursePageFragment(FragmentType pagefragment) {
135         final String METHOD_NAME = "recurseFragment(pagefragment)";
136         List frags = pagefragment.getFragmentOrNavigationOrProperty();
137         Iterator iter = frags.iterator();
138         int count = 0;
139         while (iter.hasNext()) {
140             count++;
141             try {
142                 FragmentType element = (FragmentType) iter.next();
143                 logDebug(METHOD_NAME, "Fragment: " + element.getName() + " type: " + element.getTypeattr());
144             } catch (ClassCastException e) {
145                 logDebug(METHOD_NAME, "Not a fragment: ");
146             }
147             logDebug(METHOD_NAME, "Element number: " + count);
148         }
149     }
150 */

151
152     /**
153      *
154      * @param row
155      * @param col
156      * @return
157      */

158     public PortletTO getPortlet(int row, int col) {
159         PortletTO portlet = null;
160         _portlets = getPortlets();
161         Iterator JavaDoc iter = _portlets.iterator();
162         while (iter.hasNext()) {
163             PortletTO plet = (PortletTO) iter.next();
164             if (plet.getRow() == row && plet.getCol() == col) {
165                 portlet = plet;
166                 break;
167             }
168         }
169         return portlet;
170     }
171
172     /**
173      *
174      * @param value
175      * @return
176      */

177     public PortletTO getPortlet(String JavaDoc value) {
178         final String JavaDoc METHOD_NAME = "getPortlet(value)";
179         logMethodStart(METHOD_NAME);
180         PortletTO portlet = null;
181         Iterator JavaDoc iter = _portlets.iterator();
182         while (iter.hasNext()) {
183             PortletTO plet = (PortletTO) iter.next();
184             if (plet.getValue().equals(value)) {
185                 portlet = plet;
186                 break;
187             }
188         }
189         logMethodEnd(METHOD_NAME, portlet);
190         return portlet;
191     }
192
193
194     /**
195      *
196      * @param value
197      * @return
198      */

199     public PortletTO getPortletByCell(int row, int col) {
200         final String JavaDoc METHOD_NAME = "getPortletByCell(row,col)";
201         logMethodStart(METHOD_NAME);
202         PortletTO portlet = null;
203         Iterator JavaDoc iter = _portlets.iterator();
204         while (iter.hasNext()) {
205             PortletTO plet = (PortletTO) iter.next();
206             if (plet.getRow() == row && plet.getCol() == col) {
207                 portlet = plet;
208                 break;
209             }
210         }
211         logMethodEnd(METHOD_NAME, portlet);
212         return portlet;
213     }
214
215     /**
216      * @return Returns the portlets.
217      */

218     public List JavaDoc getPortlets() {
219         return _portlets;
220     }
221
222     /**
223      * @param portlets The portlets to set.
224      */

225     public void setPortlets(List JavaDoc portlets) {
226         _portlets = portlets;
227     }
228     /**
229      * @param description The description to set.
230      */

231     public void setDescription(String JavaDoc description) {
232         _description = description;
233     }
234     /**
235      * @param title The title to set.
236      */

237     public void setTitle(String JavaDoc title) {
238         _title = title;
239     }
240     /**
241      * @return Returns the portlets.
242      */

243     public String JavaDoc getDescription() {
244         return _description;
245     }
246
247     public String JavaDoc toString(){
248         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
249         sb.append("Page[ ");
250         sb.append(_title);
251         sb.append(" Rows=");
252         sb.append(_rows);
253         sb.append(" Cols=");
254         sb.append(_cols);
255         sb.append(" Portlets[ ");
256         Iterator JavaDoc iter = _portlets.iterator();
257         while (iter.hasNext()) {
258             PortletTO element = (PortletTO) iter.next();
259             sb.append(element + " ");
260         }
261         sb.append("] ]");
262         return sb.toString();
263     }
264 }
265
Popular Tags