Source Code Cross Referenced for Menu.java in  » Content-Management-System » contineo » org » contineo » core » 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 » Content Management System » contineo » org.contineo.core.security 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.contineo.core.security;
002:
003:        import java.util.ArrayList;
004:        import java.util.Collection;
005:        import java.util.HashSet;
006:        import java.util.Set;
007:
008:        import org.contineo.core.security.dao.MenuDAO;
009:        import org.contineo.util.Context;
010:
011:        /**
012:         * This class represents menus.
013:         * 
014:         * @author Michael Scholz
015:         * @author Marco Meschieri
016:         * @version 1.0
017:         */
018:        public class Menu {
019:
020:            public static final int MENUID_HOME = 1;
021:
022:            public static final int MENUID_PERSONAL = 4;
023:
024:            public static final int MENUID_DOCUMENTS = 5;
025:
026:            public static final int MENUID_MESSAGES = 13;
027:
028:            public static final int MENUID_EDITME = 19;
029:
030:            public static final int MENUTYPE_DIRECTORY = 3;
031:
032:            public static final int MENUTYPE_FILE = 5;
033:
034:            public static final int MENUTYPE_ACTION = 1;
035:
036:            public static final int MENUTYPE_HOME = 0;
037:
038:            // Special menu for browsing the document archive
039:            public static final String MENU_BROWSE = "Browse.do";
040:
041:            protected int menuId = 0;
042:
043:            protected String menuText = "";
044:
045:            protected int menuParent = 0;
046:
047:            protected int menuSort = 0;
048:
049:            protected String menuIcon = "";
050:
051:            protected String menuPath = "";
052:
053:            protected int menuType = 2;
054:
055:            protected int menuHier = 0;
056:
057:            protected String menuRef = "";
058:
059:            protected long size = 0;
060:
061:            protected Set<MenuGroup> menuGroups = new HashSet<MenuGroup>();
062:
063:            public Menu() {
064:            }
065:
066:            public int getMenuId() {
067:                return menuId;
068:            }
069:
070:            public String getMenuText() {
071:                return menuText;
072:            }
073:
074:            public int getMenuParent() {
075:                return menuParent;
076:            }
077:
078:            public int getMenuSort() {
079:                return menuSort;
080:            }
081:
082:            public String getMenuIcon() {
083:                return menuIcon;
084:            }
085:
086:            public String getMenuPath() {
087:                return menuPath;
088:            }
089:
090:            public int getMenuType() {
091:                return menuType;
092:            }
093:
094:            public int getMenuHier() {
095:                return menuHier;
096:            }
097:
098:            public String getMenuRef() {
099:                return menuRef;
100:            }
101:
102:            public Set<MenuGroup> getMenuGroups() {
103:                return menuGroups;
104:            }
105:
106:            protected void setMenuId(int id) {
107:                menuId = id;
108:            }
109:
110:            public void setMenuText(String text) {
111:                menuText = text;
112:            }
113:
114:            public void setMenuParent(int parent) {
115:                menuParent = parent;
116:            }
117:
118:            public void setMenuSort(int sort) {
119:                menuSort = sort;
120:            }
121:
122:            public void setMenuIcon(String icon) {
123:                menuIcon = icon;
124:            }
125:
126:            public void setMenuPath(String path) {
127:                menuPath = path;
128:            }
129:
130:            public void setMenuType(int type) {
131:                menuType = type;
132:            }
133:
134:            public void setMenuHier(int hier) {
135:                menuHier = hier;
136:            }
137:
138:            public void setMenuRef(String ref) {
139:                menuRef = ref;
140:            }
141:
142:            public void setMenuGroups(Set<MenuGroup> mgroup) {
143:                menuGroups = mgroup;
144:            }
145:
146:            public String[] getMenuGroupNames() {
147:                ArrayList<String> ids = new ArrayList<String>();
148:                for (MenuGroup mg : menuGroups) {
149:                    ids.add(mg.getGroupName());
150:                }
151:                return (String[]) ids.toArray(new String[] {});
152:            }
153:
154:            /**
155:             * Adds MenuGroup object given in a String array to the ArrayList of
156:             * MenuGroups.
157:             * 
158:             * @param groups
159:             */
160:            public void setMenuGroup(String[] groups) {
161:                menuGroups.clear();
162:                for (int i = 0; i < groups.length; i++) {
163:                    MenuGroup mg = new MenuGroup();
164:                    mg.setGroupName(groups[i]);
165:                    mg.setWriteEnable(1);
166:                    menuGroups.add(mg);
167:                }
168:            }
169:
170:            public Menu copy() {
171:                Menu menu = new Menu();
172:                menu.setMenuId(this .getMenuId());
173:                menu.setMenuText(this .getMenuText());
174:                menu.setMenuParent(this .getMenuParent());
175:                menu.setMenuSort(this .getMenuSort());
176:                menu.setMenuIcon(this .getMenuIcon());
177:                menu.setMenuPath(this .getMenuPath());
178:                menu.setMenuType(this .getMenuType());
179:                menu.setMenuHier(this .getMenuHier());
180:                menu.setMenuRef(this .getMenuRef());
181:                menu.setMenuGroups(this .getMenuGroups());
182:                return menu;
183:            }
184:
185:            /**
186:             * Returns a Collection of menus being a parent of the given menu. The
187:             * collection is sorted by the hierarchy level (menuHier) of the menus.
188:             * 
189:             * @return
190:             */
191:            public Collection<Menu> getParents() {
192:                Collection<Menu> coll = new ArrayList<Menu>();
193:
194:                try {
195:                    String[] menus = menuPath.split("/");
196:
197:                    if (menus.length > 0) {
198:                        if (menus[0].length() > 0) {
199:                            MenuDAO menuDao = (MenuDAO) Context.getInstance()
200:                                    .getBean(MenuDAO.class);
201:                            Menu home = menuDao
202:                                    .findByPrimaryKey(Menu.MENUID_HOME);
203:                            coll.add(home);
204:
205:                            for (int i = 1; i < menus.length; i++) {
206:                                try {
207:                                    Menu menu = menuDao
208:                                            .findByPrimaryKey(Integer
209:                                                    .parseInt(menus[i]));
210:                                    coll.add(menu);
211:                                } catch (NumberFormatException nfe) {
212:                                    ;
213:                                }
214:                            }
215:                        }
216:                    }
217:                } catch (Exception e) {
218:                    ;
219:                }
220:
221:                return coll;
222:            }
223:
224:            public MenuGroup getMenuGroup(String groupName) {
225:                for (MenuGroup mg : menuGroups) {
226:                    if (mg.getGroupName().equals(groupName))
227:                        return mg;
228:                }
229:                return null;
230:            }
231:
232:            @Override
233:            public boolean equals(Object arg0) {
234:                if (!(arg0 instanceof  Menu))
235:                    return false;
236:                Menu other = (Menu) arg0;
237:                return other.getMenuId() == this .getMenuId();
238:            }
239:
240:            @Override
241:            public int hashCode() {
242:                return new Integer(menuId).hashCode();
243:            }
244:
245:            /**
246:             * The size of the file associated to this menu expressed in bytes
247:             */
248:            public long getMenuSize() {
249:                return size;
250:            }
251:
252:            public void setMenuSize(long size) {
253:                this.size = size;
254:            }
255:
256:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.