Source Code Cross Referenced for GroupSet.java in  » Web-Framework » TURBINE » org » apache » turbine » util » security » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » TURBINE » org.apache.turbine.util.security 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.turbine.util.security;
002:
003:        /*
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *   http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        import java.util.Collection;
023:        import java.util.Iterator;
024:
025:        import org.apache.commons.lang.StringUtils;
026:
027:        import org.apache.turbine.om.security.Group;
028:
029:        /**
030:         * This class represents a set of Groups. It's useful for building
031:         * administration UI.  It enforces that only
032:         * Group objects are allowed in the set and only relevant methods
033:         * are available.
034:         *
035:         * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
036:         * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
037:         * @author <a href="mailto:marco@intermeta.de">Marco Kn&uuml;ttel</a>
038:         * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
039:         * @version $Id: GroupSet.java 534527 2007-05-02 16:10:59Z tv $
040:         */
041:        public class GroupSet extends SecuritySet {
042:            /** Serial Version UID */
043:            private static final long serialVersionUID = 34735375738993720L;
044:
045:            /**
046:             * Constructs an empty GroupSet
047:             */
048:            public GroupSet() {
049:                super ();
050:            }
051:
052:            /**
053:             * Constructs a new GroupSet with specified contents.
054:             *
055:             * If the given collection contains multiple objects that are
056:             * identical WRT equals() method, some objects will be overwritten.
057:             *
058:             * @param groups A collection of groups to be contained in the set.
059:             */
060:            public GroupSet(Collection groups) {
061:                super ();
062:                add(groups);
063:            }
064:
065:            /**
066:             * Adds a Group to this GroupSet.
067:             *
068:             * @param group A Group.
069:             * @return True if Group was added; false if GroupSet
070:             * already contained the Group.
071:             */
072:            public boolean add(Group group) {
073:                boolean res = contains(group);
074:                nameMap.put(group.getName(), group);
075:                idMap.put(group.getIdAsObj(), group);
076:                return res;
077:            }
078:
079:            /**
080:             * Adds the Groups in a Collection to this GroupSet.
081:             *
082:             * @param groups A Collection of Groups.
083:             * @return True if this GroupSet changed as a result; false
084:             * if no change to this GroupSet occurred (this GroupSet
085:             * already contained all members of the added GroupSet).
086:             */
087:            public boolean add(Collection groups) {
088:                boolean res = false;
089:                for (Iterator it = groups.iterator(); it.hasNext();) {
090:                    Group g = (Group) it.next();
091:                    res |= add(g);
092:                }
093:                return res;
094:            }
095:
096:            /**
097:             * Adds the Groups in another GroupSet to this GroupSet.
098:             *
099:             * @param groupSet A GroupSet.
100:             * @return True if this GroupSet changed as a result; false
101:             * if no change to this GroupSet occurred (this GroupSet
102:             * already contained all members of the added GroupSet).
103:             */
104:            public boolean add(GroupSet groupSet) {
105:                boolean res = false;
106:                for (Iterator it = groupSet.iterator(); it.hasNext();) {
107:                    Group g = (Group) it.next();
108:                    res |= add(g);
109:                }
110:                return res;
111:            }
112:
113:            /**
114:             * Removes a Group from this GroupSet.
115:             *
116:             * @param group A Group.
117:             * @return True if this GroupSet contained the Group
118:             * before it was removed.
119:             */
120:            public boolean remove(Group group) {
121:                boolean res = contains(group);
122:                nameMap.remove(group.getName());
123:                idMap.remove(group.getIdAsObj());
124:                return res;
125:            }
126:
127:            /**
128:             * Checks whether this GroupSet contains a Group.
129:             *
130:             * @param group A Group.
131:             * @return True if this GroupSet contains the Group,
132:             * false otherwise.
133:             */
134:            public boolean contains(Group group) {
135:                return nameMap.containsValue((Object) group);
136:            }
137:
138:            /**
139:             * Returns a Group with the given name, if it is contained in
140:             * this GroupSet.
141:             *
142:             * @param groupName Name of Group.
143:             * @return Group if argument matched a Group in this
144:             * GroupSet; null if no match.
145:             * @deprecated Use <a href="#getGroupByName">getGroupByName</a> instead.
146:             */
147:            public Group getGroup(String groupName) {
148:                return getGroupByName(groupName);
149:            }
150:
151:            /**
152:             * Returns a Group with the given name, if it is contained in
153:             * this GroupSet.
154:             *
155:             * @param groupName Name of Group.
156:             * @return Group if argument matched a Group in this
157:             * GroupSet; null if no match.
158:             */
159:            public Group getGroupByName(String groupName) {
160:                return (StringUtils.isNotEmpty(groupName)) ? (Group) nameMap
161:                        .get(groupName) : null;
162:            }
163:
164:            /**
165:             * Returns a Group with the given id, if it is contained in
166:             * this GroupSet.
167:             *
168:             * @param groupId Id of the group
169:             * @return Group if argument matched a Group in this
170:             * GroupSet; null if no match.
171:             */
172:            public Group getGroupById(int groupId) {
173:                return (groupId != 0) ? (Group) idMap.get(new Integer(groupId))
174:                        : null;
175:            }
176:
177:            /**
178:             * Returns an Array of Groups in this GroupSet.
179:             *
180:             * @return An Array of Group objects.
181:             */
182:            public Group[] getGroupsArray() {
183:                return (Group[]) getSet().toArray(new Group[0]);
184:            }
185:
186:            /**
187:             * Print out a GroupSet as a String
188:             *
189:             * @returns The Group Set as String
190:             *
191:             */
192:            public String toString() {
193:                StringBuffer sb = new StringBuffer();
194:                sb.append("GroupSet: ");
195:
196:                for (Iterator it = iterator(); it.hasNext();) {
197:                    Group g = (Group) it.next();
198:                    sb.append('[');
199:                    sb.append(g.getName());
200:                    sb.append(" -> ");
201:                    sb.append(g.getIdAsObj());
202:                    sb.append(']');
203:                    if (it.hasNext()) {
204:                        sb.append(", ");
205:                    }
206:                }
207:
208:                return sb.toString();
209:            }
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.