1 23 24 31 package com.sun.enterprise.config.impl; 32 33 import java.io.Serializable ; 34 import java.util.HashMap ; 35 import java.util.Set ; 36 import java.util.Iterator ; 37 38 42 public class ConfigUpdateImpl extends ConfigChangeImpl implements com.sun.enterprise.config.ConfigUpdate, Serializable { 43 44 private HashMap oldValues = new HashMap (); 46 private HashMap newValues = new HashMap (); 47 48 public ConfigUpdateImpl(String xpath, String attrName, String oldValue, String newValue) { 49 this.xpath = xpath; 50 addChangedAttribute(attrName, oldValue, newValue); 51 } 52 53 public String getConfigChangeType() { 54 return TYPE_UPDATE; 55 } 56 57 60 public void addChangedAttribute(String attrName, String oldValue, String newValue) { 61 64 if(oldValues.get(attrName) == null) { 65 oldValues.put(attrName, oldValue); 67 newValues.put(attrName, newValue); 68 } else if(oldValues.get(attrName).equals(newValue)) { 72 oldValues.remove(attrName); 73 newValues.remove(attrName); 74 } else { 75 newValues.put(attrName, newValue); 76 } 77 } 78 79 public String getOldValue(String attrName) { 80 return (String )oldValues.get(attrName); 81 } 82 83 public String getNewValue(String attrName) { 84 return (String )newValues.get(attrName); 85 } 86 87 public Set getAttributeSet() { 88 return oldValues.keySet(); 89 } 90 91 public void removeAttribute(String attrName) { 92 if (attrName == null) { 93 throw new IllegalArgumentException ("Attribute name is null"); 94 } 95 if (oldValues.containsKey(attrName) && newValues.containsKey(attrName)) { 96 oldValues.remove(attrName); 97 newValues.remove(attrName); 98 } 99 } 100 101 public String toString() { 102 String ret = "update xpath=" +xpath +"\n"; 103 Set s = newValues.keySet(); 104 for(Iterator iter = s.iterator(); iter.hasNext();) { 105 String next = (String ) iter.next(); 106 ret+= "\t" + "attr=" + next + " " + oldValues.get(next) + "-->" + newValues.get(next) + "\n"; 107 } 108 return ret; 109 } 110 111 public String getName() { 112 return null; } 114 } | Popular Tags |