001: /*********************************************************************************
002: * The contents of this file are subject to the OpenI Public License Version 1.0
003: * ("License"); You may not use this file except in compliance with the
004: * License. You may obtain a copy of the License at
005: * http://www.openi.org/docs/LICENSE.txt
006: *
007: * Software distributed under the License is distributed on an "AS IS" basis,
008: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
009: * the specific language governing rights and limitations under the License.
010: *
011: * The Original Code is: OpenI Open Source
012: *
013: * The Initial Developer of the Original Code is Loyalty Matrix, Inc.
014: * Portions created by Loyalty Matrix, Inc. are
015: * Copyright (C) 2005 Loyalty Matrix, Inc.; All Rights Reserved.
016: *
017: * Contributor(s): i18n: Pedro Casals Fradera (2006/05/12)
018: *
019: ********************************************************************************/package org.openi.menu;
020:
021: import java.io.Serializable;
022: import java.util.*;
023:
024: /**
025: * @author plucas
026: *
027: * Revision:
028: * Ver 1.1 Uddhab Pant - Feb 18,2005
029: * Renamed MenuNode class to MenuItem as followed Java convention
030: * for Menu and MenuItem. Removed childNodes since Menu Item
031: * doesn't have childs. Only Menu contains childs.
032: *
033: */
034: public class MenuItem implements Serializable {
035: private String url;
036: private String idItem;
037: private String displayName;
038: private String target;
039: private String permissions;
040:
041: /**
042: * Default constuctor
043: */
044: public MenuItem() {
045: }
046:
047: /**
048: * Constructs menu item with display name.
049: * @param displayName String
050: public MenuItem(String displayName) {
051: this.displayName = displayName;
052: }
053: */
054:
055: public MenuItem(String idItem, String displayName, String url) {
056: this .idItem = idItem;
057: this .displayName = displayName;
058: this .url = url;
059: }
060:
061: public MenuItem(String idItem, String url) {
062: this .idItem = idItem;
063: this .displayName = "";
064: this .url = url;
065: }
066:
067: /**
068: * @return Returns the displayName. If is empty, returns the id
069: */
070: public String getDisplayName() {
071: return (displayName.equals("")) ? idItem : displayName;
072: }
073:
074: /**
075: * @return Returns the displayName.
076: */
077: public String getRawDisplayName() {
078: return displayName;
079: }
080:
081: /**
082: * @param displayName The displayName to set.
083: */
084: public void setDisplayName(String displayName) {
085: this .displayName = displayName;
086: }
087:
088: /**
089: * @return Returns the target.
090: */
091: public String getTarget() {
092: return target;
093: }
094:
095: /**
096: * @param target The target to set.
097: */
098: public void setTarget(String target) {
099: this .target = target;
100: }
101:
102: /**
103: * @return Returns the url.
104: */
105: public String getUrl() {
106: return url;
107: }
108:
109: /**
110: * @param url The url to set.
111: */
112: public void setUrl(String url) {
113: this .url = url;
114: }
115:
116: /**
117: *
118: * @return displayName
119: */
120: public String toString() {
121: return String.valueOf(displayName);
122: }
123:
124: /**
125: * returns list of rights that are allowed to access this menu item
126: * @return
127: */
128: public String getPermissions() {
129: return permissions;
130: }
131:
132: /**
133: * sets list of rights that are allowed to access this menu item
134: * @return
135: */
136: public void setPermissions(String permissions) {
137: this .permissions = permissions;
138: }
139:
140: public String getIdItem() {
141: return idItem;
142: }
143:
144: public void setIdItem(String idItem) {
145: this .idItem = idItem;
146: }
147:
148: public Object clone() {
149: MenuItem menuitem = new MenuItem("", "");
150: menuitem.displayName = this.displayName;
151: menuitem.idItem = this.idItem;
152: menuitem.target = this.target;
153: menuitem.url = this.url;
154: return menuitem;
155: }
156: }
|