FileDocCategorySizeDatePackage
ConfigUpdateImpl.javaAPI DocGlassfish v2 API4941Fri May 04 22:31:18 BST 2007com.sun.enterprise.config.impl

ConfigUpdateImpl

public class ConfigUpdateImpl extends ConfigChangeImpl implements Serializable, com.sun.enterprise.config.ConfigUpdate
A configuration change for an element. Holds xpath, list of changed attributes, their old and new values.

Fields Summary
private HashMap
oldValues
private HashMap
newValues
Constructors Summary
public ConfigUpdateImpl(String xpath, String attrName, String oldValue, String newValue)

    
             
        this.xpath = xpath;
        addChangedAttribute(attrName, oldValue, newValue);
    
Methods Summary
public voidaddChangedAttribute(java.lang.String attrName, java.lang.String oldValue, java.lang.String newValue)
add attr changes to the hashmap

        //FIXME: This solution will not work for cases involving setAttribute(A, NULL)
        // null has to be handled gracefully in future releases.
        
        if(oldValues.get(attrName) == null) {
           // if(!oldValue.equals(newValue)) {
                oldValues.put(attrName, oldValue);
                newValues.put(attrName, newValue);
           // } else {
           //     return;
           // }   
        } else if(oldValues.get(attrName).equals(newValue)) {
            oldValues.remove(attrName);
            newValues.remove(attrName);
        } else {
            newValues.put(attrName, newValue);
        }
    
public java.util.SetgetAttributeSet()

        return oldValues.keySet();
    
public java.lang.StringgetConfigChangeType()

        return TYPE_UPDATE;
    
public java.lang.StringgetName()

        return null; //FIXME TBD
    
public java.lang.StringgetNewValue(java.lang.String attrName)

        return (String)newValues.get(attrName);
    
public java.lang.StringgetOldValue(java.lang.String attrName)

        return (String)oldValues.get(attrName);
    
public voidremoveAttribute(java.lang.String attrName)

        if (attrName == null) {
            throw new IllegalArgumentException("Attribute name is null");
        }
        if (oldValues.containsKey(attrName) && newValues.containsKey(attrName)) {
            oldValues.remove(attrName);
            newValues.remove(attrName);
        }
    
public java.lang.StringtoString()

        String ret = "update xpath=" +xpath +"\n";
        Set s = newValues.keySet();
        for(Iterator iter = s.iterator(); iter.hasNext();) {
            String next = (String) iter.next();
            ret+= "\t" + "attr=" + next + "   " + oldValues.get(next) + "-->" + newValues.get(next) + "\n";
        }
        return ret;