Source Code Cross Referenced for UserGroupList.java in  » J2EE » fleXive » com » flexive » shared » 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 » J2EE » fleXive » com.flexive.shared.security 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /***************************************************************
002:         *  This file is part of the [fleXive](R) project.
003:         *
004:         *  Copyright (c) 1999-2008
005:         *  UCS - unique computing solutions gmbh (http://www.ucs.at)
006:         *  All rights reserved
007:         *
008:         *  The [fleXive](R) project is free software; you can redistribute
009:         *  it and/or modify it under the terms of the GNU General Public
010:         *  License as published by the Free Software Foundation;
011:         *  either version 2 of the License, or (at your option) any
012:         *  later version.
013:         *
014:         *  The GNU General Public License can be found at
015:         *  http://www.gnu.org/copyleft/gpl.html.
016:         *  A copy is found in the textfile GPL.txt and important notices to the
017:         *  license from the author are found in LICENSE.txt distributed with
018:         *  these libraries.
019:         *
020:         *  This library is distributed in the hope that it will be useful,
021:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
022:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
023:         *  GNU General Public License for more details.
024:         *
025:         *  For further information about UCS - unique computing solutions gmbh,
026:         *  please see the company website: http://www.ucs.at
027:         *
028:         *  For further information about [fleXive](R), please see the
029:         *  project website: http://www.flexive.org
030:         *
031:         *
032:         *  This copyright notice MUST APPEAR in all copies of the file!
033:         ***************************************************************/package com.flexive.shared.security;
034:
035:        import com.flexive.shared.FxArrayUtils;
036:
037:        import java.io.Serializable;
038:        import java.util.ArrayList;
039:        import java.util.List;
040:        import java.util.Arrays;
041:
042:        /**
043:         * A class for transporting and processing a list of groups.
044:         *
045:         * @author Gregor Schober (gregor.schober@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
046:         */
047:        public class UserGroupList implements  Serializable {
048:            private static final long serialVersionUID = -7462354889674331522L;
049:
050:            private UserGroup[] list = null;
051:
052:            /**
053:             * Constructor
054:             *
055:             * @param groups the groups in the list
056:             */
057:            public UserGroupList(UserGroup[] groups) {
058:                if (groups == null)
059:                    groups = new UserGroup[0];
060:                this .list = FxArrayUtils.clone(groups);
061:            }
062:
063:            /**
064:             * Constructor
065:             */
066:            public UserGroupList() {
067:                this .list = new UserGroup[0];
068:            }
069:
070:            /**
071:             * Returns the amount of groups in the list.
072:             *
073:             * @return the amount of groups in the list
074:             */
075:            public int size() {
076:                return list.length;
077:            }
078:
079:            /**
080:             * Returns all groups in the list.
081:             *
082:             * @return all groups in the list
083:             */
084:            public UserGroup[] getGroups() {
085:                return FxArrayUtils.clone(list);
086:            }
087:
088:            /**
089:             * Returns the group at the given position.
090:             *
091:             * @param pos the position
092:             * @return the group at the given position
093:             */
094:            public UserGroup get(int pos) {
095:                return this .list[pos];
096:            }
097:
098:            /**
099:             * Returns a array holding the id's of all groups in the list.
100:             *
101:             * @return a array holding the id's of all groups in the list
102:             */
103:            public long[] toLongArray() {
104:                long[] idArr = new long[list.length];
105:                for (int i = 0; i < list.length; i++)
106:                    idArr[i] = list[i].getId();
107:                return idArr;
108:            }
109:
110:            /**
111:             * Returns a array holding the names of all groups in the list.
112:             *
113:             * @return a array holding the names of all groups in the list
114:             */
115:            public String[] toNameArray() {
116:                if (list == null)
117:                    return new String[0];
118:                String idArr[] = new String[list.length];
119:                for (int i = 0; i < list.length; i++)
120:                    idArr[i] = list[i].getName();
121:                return idArr;
122:            }
123:
124:            /**
125:             * Removes a group from the list.
126:             *
127:             * @param group the group to remove from the list
128:             */
129:            public void remove(UserGroup group) {
130:                remove(group.getId());
131:            }
132:
133:            /**
134:             * Removes groups from the list.
135:             *
136:             * @param group the groups to remove from the list
137:             */
138:            public void remove(UserGroup[] group) {
139:                for (UserGroup aGroup : group)
140:                    remove(aGroup.getId());
141:            }
142:
143:            /**
144:             * Removes groups identified by the unique id from the list.
145:             *
146:             * @param groupId the groups to remove from the list
147:             */
148:            public void remove(long[] groupId) {
149:                for (long aGroupId : groupId)
150:                    remove(aGroupId);
151:            }
152:
153:            /**
154:             * Returns true if the group is contained in the group list.
155:             *
156:             * @param groupId the id of the group to look for
157:             * @return true if the group is contained in the group list.
158:             */
159:            public boolean contains(long groupId) {
160:                for (UserGroup aList : list)
161:                    if (aList.getId() == groupId)
162:                        return true;
163:                return false;
164:            }
165:
166:            /**
167:             * Removes a group identified by its unique id from the list.
168:             *
169:             * @param groupId the group to remove from the list
170:             */
171:            public void remove(long groupId) {
172:                if (list != null) {
173:                    int elementFound = 0;
174:                    while (elementFound != -1) {
175:                        // Look for the elemenet
176:                        elementFound = -1;
177:                        for (int i = 0; i < list.length; i++) {
178:                            if (list[i].getId() == groupId) {
179:                                elementFound = i;
180:                                break;
181:                            }
182:                        }
183:                        // Delete the element
184:                        if (elementFound != -1) {
185:                            UserGroup tmp[] = new UserGroup[list.length - 1];
186:                            int pos = 0;
187:                            for (int i = 0; i < list.length; i++) {
188:                                if (i != elementFound)
189:                                    tmp[pos++] = list[i];
190:                            }
191:                            list = tmp;
192:                        }
193:                    }
194:                }
195:            }
196:
197:            public List<UserGroup> getList() {
198:                ArrayList<UserGroup> result = new ArrayList<UserGroup>(
199:                        list == null ? 0 : list.length);
200:                if (list != null) {
201:                    result.addAll(Arrays.asList(list));
202:                }
203:                return result;
204:            }
205:
206:            /**
207:             * Returns a string representation of the groups.
208:             *
209:             * @return a string representation of the groups
210:             */
211:            @Override
212:            public String toString() {
213:                return UserGroupList.class + "@[" + toNameString() + "]";
214:            }
215:
216:            /**
217:             * Returns a comma seperated list of the group names.
218:             *
219:             * @return a comma seperated list of the group names.
220:             */
221:            public String toNameString() {
222:                String result = "";
223:                for (UserGroup aList : list) {
224:                    if (result.length() > 0)
225:                        result += ",";
226:                    result += aList.getName();
227:                }
228:                return result;
229:            }
230:
231:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.