View Javadoc

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
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 getColumn()
33      {
34          Object column = get("column");
35          if (column instanceof String)
36          {
37              try
38              {
39                  column = new Integer(Integer.parseInt((String)column));
40                  put("column", column);
41              }
42              catch (Exception e)
43              {
44                  remove("column");
45                  column=null;
46              }
47          }
48          return (Integer)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 col) throws IllegalArgumentException
57      {
58          if (col.intValue() < 0)
59          {
60              throw new IllegalArgumentException("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 getRow()
71      {
72          Object row = get("row");
73          if (row instanceof String)
74          {
75              try
76              {
77                  row = new Integer(Integer.parseInt((String)row));
78                  put("row", row);
79              }
80              catch (Exception e)
81              {
82                  remove("row");
83                  row = null;
84              }
85          }
86          return (Integer)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 row) throws IllegalArgumentException
95      {
96          if (row.intValue() < 0)
97          {
98              throw new IllegalArgumentException("Row coordinate must be positive");
99          }
100         
101         put("row",row);
102     }
103 }