KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > portal > BasePortletSetConstraints


1 /*
2  * Copyright 2000-2001,2004 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
17 package org.apache.jetspeed.portal;
18
19 /**
20  * Trivial implementation of PortletSetConstraints
21  *
22  * @author <a HREF="mailto:raphael@apache.org">Raphaël Luta</a>
23  * @version $Id: BasePortletSetConstraints.java,v 1.3 2004/02/23 04:05:35 jford Exp $
24  */

25 public class BasePortletSetConstraints extends java.util.HashMap JavaDoc
26     implements PortletSet.Constraints
27 {
28     /** Get the column the portlet should be displayed in
29      *
30      * @return a positive column number or null
31      */

32     public Integer JavaDoc getColumn()
33     {
34         Object JavaDoc column = get("column");
35         if (column instanceof String JavaDoc)
36         {
37             try
38             {
39                 column = new Integer JavaDoc(Integer.parseInt((String JavaDoc)column));
40                 put("column", column);
41             }
42             catch (Exception JavaDoc e)
43             {
44                 remove("column");
45                 column=null;
46             }
47         }
48         return (Integer JavaDoc)column;
49     }
50         
51     /** Set the column the portlet should be displayed in. This
52      * integer must be positive
53      *
54      * @param col the column position
55      */

56     public void setColumn(Integer JavaDoc col) throws IllegalArgumentException JavaDoc
57     {
58         if (col.intValue() < 0)
59         {
60             throw new IllegalArgumentException JavaDoc("Column coordinate must be positive");
61         }
62         
63         put("column",col);
64     }
65
66     /** Get the row the portlet should be displayed in
67      *
68      * @return a positive row number or null
69      */

70     public Integer JavaDoc getRow()
71     {
72         Object JavaDoc row = get("row");
73         if (row instanceof String JavaDoc)
74         {
75             try
76             {
77                 row = new Integer JavaDoc(Integer.parseInt((String JavaDoc)row));
78                 put("row", row);
79             }
80             catch (Exception JavaDoc e)
81             {
82                 remove("row");
83                 row = null;
84             }
85         }
86         return (Integer JavaDoc)row;
87     }
88         
89     /** Set the row the portlet should be displayed in. This
90      * integer must be positive
91      *
92      * @param row the column position
93      */

94     public void setRow(Integer JavaDoc row) throws IllegalArgumentException JavaDoc
95     {
96         if (row.intValue() < 0)
97         {
98             throw new IllegalArgumentException JavaDoc("Row coordinate must be positive");
99         }
100         
101         put("row",row);
102     }
103 }
104
Popular Tags