1 package org.apache.turbine.om.security; 2 3 18 19 import java.util.Collections ; 20 import java.util.HashMap ; 21 import java.util.Map ; 22 23 import org.apache.torque.om.BaseObject; 24 25 34 public abstract class SecurityObject extends BaseObject implements Comparable 35 { 36 37 private String name; 38 39 40 private int id; 41 42 43 private Map attributes; 44 45 48 public SecurityObject() 49 { 50 this(""); 51 } 52 53 58 public SecurityObject(String name) 59 { 60 setName(name); 61 setId(0); 62 setAttributes(Collections.synchronizedMap(new HashMap ())); 63 } 64 65 70 public Map getAttributes() 71 { 72 return attributes; 73 } 74 75 80 public void setAttributes(Map attributes) 81 { 82 this.attributes = attributes; 83 } 84 85 91 public Object getAttribute(String name) 92 { 93 return attributes.get(name); 94 } 95 96 102 public void setAttribute(String name, Object value) 103 { 104 attributes.put(name, value); 105 } 106 107 112 public String getName() 113 { 114 return name; 115 } 116 117 122 public void setName(String name) 123 { 124 this.name = name; 125 } 126 127 134 public int getId() 135 { 136 return id; 137 } 138 139 146 public Integer getIdAsObj() 147 { 148 return new Integer (id); 149 } 150 151 158 public void setId(int id) 159 { 160 this.id = id; 161 } 162 163 170 public int compareTo(Object obj) 171 { 172 if (this.getClass() != obj.getClass()) 173 { 174 throw new ClassCastException (); 175 } 176 String name1 = ((SecurityObject) obj).getName(); 177 String name2 = this.getName(); 178 179 return name2.compareTo(name1); 180 } 181 182 188 public String toString() 189 { 190 return (getName() + ':' + getAttributes().toString()); 191 } 192 } 193 | Popular Tags |