KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > tools > userManagement > UserBean


1 /*
2  * Copyright 1999-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.cocoon.portal.tools.userManagement;
17
18 import java.util.Collection JavaDoc;
19 import java.util.HashMap JavaDoc;
20
21 /**
22  * Object storing information of an user context.
23  *
24  * @version CVS $Id: UserBean.java 149055 2005-01-29 18:21:34Z cziegeler $
25  */

26 public class UserBean {
27     
28     private HashMap JavaDoc context = new HashMap JavaDoc ();
29     private String JavaDoc picture = "";
30     
31     
32     public UserBean () {
33     }
34     
35     /**
36      * Add a single context information
37      *
38      * @param key name of the context
39      * @param value value of the context
40      */

41     public void addContext (String JavaDoc key, String JavaDoc value){
42         this.context.put (key, new ContextItem (key, value));
43     }
44     
45     /**
46      * Get the whole context of the current user
47      *
48      * @return Collection of the whole context
49      */

50     public Collection JavaDoc getContext () {
51         return this.context.values();
52     }
53     
54     /**
55      * return specified context value
56      *
57      * @param key
58      * @return
59      */

60     public String JavaDoc getContextItem (String JavaDoc key) {
61         if (this.context.get(key) != null) {
62             return ((ContextItem) this.context.get(key)).getValue();
63         } else {
64             return "";
65         }
66     }
67     
68     /**
69      * Special Attribute for the cocoon portal tool example:
70      * you can store even extra attributes in the bean
71      *
72      * @return name of the picture file
73      */

74     public String JavaDoc getPicture() {
75         return picture;
76     }
77     
78     /**
79      * Special Attribute for the cocoon portal tool example:
80      * you can store even extra attributes in the bean
81      *
82      * @param string name of the picture file
83      */

84     public void setPicture(String JavaDoc string) {
85         picture = string;
86     }
87 }
88
Popular Tags