FileDocCategorySizeDatePackage
XYZPayrollPermission.javaAPI DocExample3651Sun Oct 25 18:13:34 GMT 1998None

XYZPayrollPermission

public class XYZPayrollPermission extends Permission

Fields Summary
protected int
mask
private static int
VIEW
private static int
UPDATE
Constructors Summary
public XYZPayrollPermission(String name)


	   
		this(name, "view");
	
public XYZPayrollPermission(String name, String action)

		super(name);
		if (action == null)
			action = "view";
		parse(action);
	
Methods Summary
public booleanequals(java.lang.Object o)

		if (!(o instanceof XYZPayrollPermission))
			return false;
		
		XYZPayrollPermission p = (XYZPayrollPermission) o;
		return ((p.getName().equals(getName())) && (p.mask == mask));
	
public java.lang.StringgetActions()

		if (mask == 0)
			return "";
		else if (mask == VIEW)
			return "view";
		else if (mask == UPDATE)
			return "update";
		else if (mask == (VIEW | UPDATE))
			return "view, update";
		else throw new IllegalArgumentException("Unknown mask");
	
public inthashCode()

		return getName().hashCode() ^ mask;
	
public booleanimplies(java.security.Permission permission)

		if (!(permission instanceof XYZPayrollPermission))
			return false;
		
		XYZPayrollPermission p = (XYZPayrollPermission) permission;
		String name = getName();
		if (!name.equals("*") && !name.equals(p.getName()))
			return false;
		if ((mask & p.mask) != p.mask)
			return false;
		return true;
	
public static voidmain(java.lang.String[] args)

		XYZPayrollPermission sdo = new XYZPayrollPermission("sdo", "view");
		XYZPayrollPermission sdoAll = new XYZPayrollPermission("sdo", "view, update");
		XYZPayrollPermission su = new XYZPayrollPermission("*", "view, update");

		System.out.println("sdo -> sdoAll " + sdo.implies(sdoAll));
		System.out.println("sdoAll -> sdo " + sdoAll.implies(sdo));
		System.out.println("sdoAll -> su " + sdoAll.implies(su));
		System.out.println("su -> sdo " + su.implies(sdo));
	
public java.security.PermissionCollectionnewPermissionsCollection()

		return new XYZPayrollPermissionCollection();
	
private voidparse(java.lang.String action)

		StringTokenizer st = new StringTokenizer(action, ",\t ");

		mask = 0;
		while (st.hasMoreTokens()) {
			String tok = st.nextToken();
			if (tok.equals("view"))
				mask |= VIEW;
			else if (tok.equals("update"))
				mask |= UPDATE;
			else throw new IllegalArgumentException("Unknown action " + tok);
		}