⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 permission.java

📁 CRMS客户关系管理系统(JAVA版),这是一个客户关系管理系统。
💻 JAVA
字号:
    /* CRMS, customer relationship management system    Copyright (C) 2003  Service To Youth Council    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA    For further information contact the SYC ICT department on GPL@syc.net.au    98 Kermode Street    North Adelaide    South Australia    SA 5006     +61 (0)8 8367 0755    *//* * Permission.java * * Created on 15 May 2003, 11:18 */package crms.vo;import crms.util.*;import java.util.*;/** * * @author  dmurphy */public class Permission {        public static final int READ_PERMISSION = 0;    public static final int WRITE_PERMISSION = 1;    public static final int DELETE_PERMISSION = 2;    public static final int SECURITY_PERMISSION = 3;        public static String[] NAMES = { "Read", "Write", "Delete", "Security" };        private int entityID = -1;    private EntityType entityType = null;    private String id = null;    private String location = null;    private String division = null;	private int power = 0;    private PermissionType permissionType = null;    private Object reference = null;        public boolean[] permissions = { false, false, false, false };        /** Creates a new instance of Permission */    public Permission() {    }        public void setEntityID(int entityID) {        this.entityID = entityID;       }        public int getEntityID() {        return entityID;       }    public void setLocation(String new_location) {		location = new_location;    }    public String getLocation() {        return location;       }        public void setDivision(String new_division) {		division = new_division;    }    public String getDivision() {        return division;       }        public void setEntityType(EntityType type) {        this.entityType = type;       }        public EntityType getEntityType() {        return entityType;       }        public void setID(String id) {        this.id = id;    }        public String getID(){        return id;       }	public void setPower(int power) {		this.power = power;	}	public int getPower() {		return power;	}        public void setPermissionType(PermissionType type) {        this.permissionType = type;       }        public PermissionType getPermissionType() {        return permissionType;       }        public void setPermission(int permission, boolean set) {        permissions[permission] = set;    }        public boolean hasPermission(int permission) {        return permissions[permission];    }        public boolean hasAnyPermission() {        for (int i=0; i < 2; i++) {            if (permissions[i]) {             return true;               }        }        return false;    }        public boolean canRead() {        return permissions[READ_PERMISSION] ||            permissions[WRITE_PERMISSION] ||            permissions[DELETE_PERMISSION];       }    public boolean canWrite() {        return permissions[WRITE_PERMISSION] ||            permissions[DELETE_PERMISSION];       }        public boolean canDelete() {    	return permissions[DELETE_PERMISSION];       }    public boolean canSecurity() {    	return permissions[SECURITY_PERMISSION];       }        public void setPermissions( boolean[] perms) {        permissions = perms;       }        public boolean[] getPermissions() {     return permissions;       }        /**     * Sets the "reference" on this permission, eg: a StaffMember     * object if the permission is a user permission, or a Group object     * if a group permission.     */        public void setReference(Object ref) {        this.reference = ref;        }        public Object getReference() {        return reference;    }        public String toString() {        StringBuffer buf =  new StringBuffer();        buf.append("EntityID: " + getEntityID());        buf.append(" EntityType: " + getEntityType());        buf.append(" ID: " + getID());        buf.append(" Power: " + getPower());        buf.append(" Division: " + getDivision());        buf.append(" Location: " + getLocation());        buf.append(" PermissionType: " + getPermissionType());        buf.append(" Rights: " );        for (int i=0; i < permissions.length; i++) {            boolean auth = hasPermission(i);               if (auth) {                buf.append( " " + NAMES[i]);            }        }                return buf.toString();    }        public static Comparator HIGHEST_PERMISSION_ORDER = new Comparator() {        public int compare(Object o1, Object o2) {            Permission p1 = (Permission) o1;            Permission p2 = (Permission) o2;			int p1w = 0;			if (p1.getID() != null) p1w = 4;			else if (p1.getDivision() != null && p1.getLocation() != null) p1w = 3;			else if (p1.getDivision() != null) p1w = 2;			else p1w = 1;			int p2w = 0;			if (p2.getID() != null) p2w = 4;			else if (p2.getDivision() != null && p2.getLocation() != null) p2w = 3;			else if (p2.getDivision() != null) p2w = 2;			else p2w = 1;			p2w += p2.getPower();			p1w += p1.getPower();                        return p2w - p1w;        }    };}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -