1 22 26 package org.jresearch.gossip.am.values; 27 28 import java.io.Serializable ; 29 import java.util.HashMap ; 30 import java.util.Hashtable ; 31 32 import org.jresearch.gossip.exception.SystemException; 33 34 38 public class PermissionAttributes implements Serializable { 39 42 private static final long serialVersionUID = 2871133928578166536L; 43 44 47 public static final PermissionAttributes ALL_ATTRIBUTES = new PermissionAttributes(); 48 49 private HashMap values = new HashMap (); 50 51 54 public PermissionAttributes() { 55 super(); 56 } 57 58 63 public void addValue(String key, Integer value) throws SystemException { 64 if (this != ALL_ATTRIBUTES) { 65 this.values.put(key, value); 66 } else { 67 throw new SystemException("value can't be added in ALL_ATTRIBUTES"); 68 } 69 } 70 71 76 public void addValue(String key, String value) throws SystemException { 77 if (this != ALL_ATTRIBUTES) { 78 this.values.put(key, value); 79 } else { 80 throw new SystemException("value can't be added in ALL_ATTRIBUTES"); 81 } 82 } 83 84 89 public int hashCode() { 90 if (values.isEmpty()) { 91 return 0; 92 } else { 93 return values.hashCode(); 94 } 95 } 96 97 102 public boolean equals(Object obj) { 103 if (obj instanceof PermissionAttributes) { 104 PermissionAttributes pa = (PermissionAttributes) obj; 105 return this == ALL_ATTRIBUTES || pa == ALL_ATTRIBUTES 106 || this.values.equals(pa.values); 107 } 108 109 return false; 110 111 } 112 } | Popular Tags |