KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > webapp > tiles > portal > PortalSettings


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

18
19 package org.apache.struts.webapp.tiles.portal;
20
21 import java.util.ArrayList JavaDoc;
22 import java.util.List JavaDoc;
23
24   /**
25    * Objects of this class hold portal settings for one user.
26    */

27    public class PortalSettings
28    {
29        /** Number of columms*/
30      protected int numCols;
31        /** List of lists (one per column) */
32      protected List JavaDoc lists = new ArrayList JavaDoc();
33
34        /**
35         * Get number of columns.
36         */

37      public int getNumCols()
38        {
39        return numCols;
40        }
41        /**
42         * Set number of columns
43         */

44      public void setNumCols( String JavaDoc numCols )
45        {
46        setNumCols( Integer.parseInt(numCols) );
47        }
48        /**
49         * Set number of columns.
50         * Ensure capacity for internal list.
51         */

52      public void setNumCols( int numCols )
53        {
54        this.numCols = numCols;
55        }
56        /**
57         * Get list at specified index
58         */

59      public List JavaDoc getListAt( int index )
60        {
61        return (List JavaDoc)lists.get(index);
62        }
63
64        /**
65         * Add a list without checking
66         */

67      public void addList( List JavaDoc list )
68        {
69        lists.add( list);
70        }
71
72        /**
73         * Set list at specified index. Previous list is disguarded.
74         * Add empty list if necessary.
75         * Indexes go from 0 to numCols-1
76         * @param index index of the list to add.
77         * @param list list to set.
78         */

79      public void setListAt( int index, List JavaDoc list )
80        {
81          // First, ensure capacity
82
while( index>lists.size() ) lists.add(new ArrayList JavaDoc());
83        lists.add( index, list);
84        }
85
86        /**
87         * Reset settings
88         */

89      public void reset()
90        {
91        numCols = 0;
92        lists.clear();
93        }
94
95      public String JavaDoc toString()
96        {
97        return "colCount=" + numCols
98               + " , lists=" + lists;
99        }
100    }
101
Popular Tags