1 23 24 package com.sun.enterprise.deployment; 25 26 import com.sun.enterprise.deployment.Role; 27 28 35 public class MethodPermission extends Descriptor { 36 37 private static MethodPermission unchecked; 38 private static MethodPermission excluded; 39 private boolean isUnchecked = false; 40 private boolean isExcluded = false; 41 private Role role; 42 43 48 public MethodPermission(Role role) { 49 this.role = role; 50 } 51 52 private MethodPermission() { 54 } 55 56 60 public static MethodPermission getUncheckedMethodPermission() { 61 if (unchecked==null) { 62 unchecked = new MethodPermission(); 63 unchecked.isUnchecked=true; 64 } 65 return unchecked; 66 } 67 68 72 public static MethodPermission getExcludedMethodPermission() { 73 if (excluded==null) { 74 excluded = new MethodPermission(); 75 excluded.isExcluded=true; 76 } 77 return excluded; 78 } 79 80 83 public boolean isRoleBased() { 84 return role!=null; 85 } 86 87 90 public boolean isUnchecked() { 91 return isUnchecked; 92 } 93 94 97 public boolean isExcluded() { 98 return isExcluded; 99 } 100 101 105 public Role getRole() { 106 return role; 107 } 108 109 public int hashCode() { 111 if (role!=null) 112 return role.hashCode(); 113 else 114 return super.hashCode(); 115 } 116 117 public boolean equals(Object other) { 119 boolean ret = false; 120 if(other instanceof MethodPermission) { 121 MethodPermission o = (MethodPermission) other; 122 if (isRoleBased()) { 123 ret = role.equals(o.getRole()); 124 } else { 125 ret = (isExcluded == o.isExcluded()) && (isUnchecked == o.isUnchecked()); 126 } 127 } 128 return ret; 129 } 130 131 public void print(StringBuffer toStringBuffer) { 132 if (isRoleBased()) { 133 toStringBuffer.append(role.toString()); 134 } else { 135 if (isExcluded) 136 toStringBuffer.append("excluded"); 137 else 138 toStringBuffer.append("unchecked"); 139 } 140 } 141 } 142 143 | Popular Tags |