View Javadoc

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 org.apache.pluto.portlet.admin.BaseAdminObject;
19  
20  /***
21   * A Transfer Object repesenting a portlet in pageregistry.xml
22   * where the fragment type equals portlet. It is used to decouple
23   * the XML persistence model from the JSP view.
24   *
25   * @author Craig Doremus
26   *
27   */
28  public class PortletTO extends BaseAdminObject implements Comparable {
29  	private static final String CLASS_NAME = "PortletTO";
30  	private String _name = "";
31  	//Value is appID.portletID
32  	private String _value = null;
33  	//row in column in the page layout
34  	private int _row = 1;
35  	private int _col = 1;
36  
37  	/*
38  	 * Default constuctor
39  	 */
40  	public PortletTO(){
41  		super(CLASS_NAME);
42  	}
43  
44  	/***
45  	 *
46  	 *
47  	 * @param name
48  	 * @param value
49  	 * @param row
50  	 * @param col
51  	 */
52  	public PortletTO(String name, String value, int row, int col) {
53  		super(CLASS_NAME);
54  		_name = name;
55  		_value = value;
56  		_row = row;
57  		_col = col;
58  	}
59  
60  
61  	/***
62  	 * @return Returns the col.
63  	 */
64  	public int getCol() {
65  		return _col;
66  	}
67  	/***
68  	 * @param col The col to set.
69  	 */
70  	public void setCol(int col) {
71  		_col = col;
72  	}
73  	/***
74  	 * @return Returns the name.
75  	 */
76  	public String getName() {
77  		return _name;
78  	}
79  	/***
80  	 * @param name The name to set.
81  	 */
82  	public void setName(String name) {
83  		_name = name;
84  	}
85  	/***
86  	 * @return Returns the row.
87  	 */
88  	public int getRow() {
89  		return _row;
90  	}
91  	/***
92  	 * @param row The row to set.
93  	 */
94  	public void setRow(int row) {
95  		_row = row;
96  	}
97  	/***
98  	 * @return Returns the value.
99  	 */
100 	public String getValue() {
101 		return _value;
102 	}
103 	/***
104 	 * @param value The value to set.
105 	 */
106 	public void setValue(String value) {
107 		_value = value;
108 	}
109 
110 
111 	public String toString() {
112 		StringBuffer sb = new StringBuffer();
113 		sb.append("portlet[");
114 		sb.append(_name);
115 		sb.append("=");
116 		sb.append(_value);
117 		sb.append(" ; row: ");
118 		sb.append(_row);
119 		sb.append(" col: ");
120 		sb.append(_col);
121 		sb.append("] ");
122 		return sb.toString();
123 	}
124 	/***
125 	 * Implemented to portlets to show in correct row/column order
126 	 * in the user interface.
127 	 *
128 	 * @see java.lang.Comparable#compareTo(java.lang.Object)
129 	 */
130 	public int compareTo(Object p_portlet) {
131 		int retVal = 0;
132 		PortletTO portlet = (PortletTO)p_portlet;
133 		int p_row = portlet.getRow();
134 		if (_row > p_row) {
135 			retVal = 1;
136 		} else if (_row < p_row){
137 			retVal = -1;
138 		} else {
139 			int p_col = portlet.getCol();
140 			if (_col > p_col) {
141 				retVal = 1;
142 			} else if (_col < p_col) {
143 				retVal = -1;
144 			}
145 		}
146 		return retVal;
147 	}
148 }