1 23 24 package com.sun.enterprise.deployment; 25 26 import java.util.*; 27 28 35 public class DynamicAttributesDescriptor extends Observable { 36 37 private Map dynamicAttributes; 38 39 43 44 public Map getExtraAttributes() { 45 if (dynamicAttributes == null) { 46 dynamicAttributes = new Hashtable(); 47 } 48 return dynamicAttributes; 49 } 50 51 56 public void addExtraAttribute(String name, Object value) { 57 if (value==null) { 58 return; 59 } 60 if (dynamicAttributes == null) { 61 dynamicAttributes = new Hashtable(); 62 } 63 dynamicAttributes.put(name, value); 64 changed(); 65 } 66 67 72 public Object getExtraAttribute(String name) { 73 if (dynamicAttributes == null) { 74 return null; 75 } 76 return dynamicAttributes.get(name); 77 } 78 79 83 public void removeExtraAttribute(String name) { 84 if (dynamicAttributes == null) { 85 return; 86 } 87 dynamicAttributes.remove(name); 88 changed(); 89 } 90 91 119 public void print(StringBuffer toStringBuffer) { 120 if (dynamicAttributes==null) { 121 toStringBuffer.append("<== No attribute ==>"); 122 } else { 123 toStringBuffer.append("==>Dynamic Attribute"); 124 Set keys = dynamicAttributes.keySet(); 125 for (Iterator itr = keys.iterator();itr.hasNext();) { 126 String keyName = (String ) itr.next(); 127 Object o = getExtraAttribute(keyName); 128 if (o instanceof Object []) { 129 Object [] objects = (Object []) o; 130 for (int i=0;i<objects.length;i++) { 131 toStringBuffer.append("\n Indexed prop name ").append(keyName).append("[").append(i).append("] = "); 132 if(objects[i] instanceof DynamicAttributesDescriptor) 133 ((DynamicAttributesDescriptor)objects[i]).print(toStringBuffer); 134 else 135 toStringBuffer.append(objects[i]); 136 } 137 } else { 138 toStringBuffer.append("\n Property name = ").append(keyName).append(" value = "); 139 if(o instanceof DynamicAttributesDescriptor) 140 ((DynamicAttributesDescriptor)o).print(toStringBuffer); 141 else 142 toStringBuffer.append(o); 143 } 144 } 145 toStringBuffer.append("\n<==End"); 146 return ; 147 } 148 } 149 155 public String toString() { 156 StringBuffer toStringBuf = new StringBuffer (); 157 this.print(toStringBuf); 158 return toStringBuf.toString(); 159 } 160 161 164 private void changed() { 165 setChanged(); 166 notifyObservers(); 167 } 168 } | Popular Tags |