
com.republicate.stillness.WrappedContext Maven / Gradle / Ivy
package com.republicate.stillness;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.ArrayList;
import org.apache.velocity.context.Context;
import org.apache.velocity.VelocityContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by IntelliJ IDEA.
* User: Demo
* Date: 20 oct. 2006
* Time: 10:35:38
* To change this template use File | Settings | File Templates.
*/
public class WrappedContext implements Context {
protected static Logger logger = LoggerFactory.getLogger("stillness");
protected Context _savedContext = null; // original context whithout any modification
protected Context _wrappedContext = null; // Context used for put/get methods call
protected Hashtable _localData = new Hashtable(); // used in macro to store parameters (avoid name conflict on reference name)
protected ArrayList _removedList = new ArrayList(); // list of removed elements to be removed from _savedContext on next commit
public WrappedContext(Context c) {
_savedContext = c;
_wrappedContext = new VelocityContext();
saveContext(_savedContext, _wrappedContext);
}
// commit modification from the _wrappedContext to the _savedContext
public void commitChange() {
saveContext(_wrappedContext, _savedContext);
}
protected void saveContext(Context src, Context dest) {
while(_removedList.size()!=0)
dest.remove((String)_removedList.remove(0));
Object[] listKeys = src.getKeys();
for (int i=0;i '"+ _savedContext.get(""+sctxt[i]) +"'");
}
logger.debug("_wrappedContext contains :");
Object []wctxt = _wrappedContext.getKeys();
for (int i=0; i '"+ _wrappedContext.get(""+wctxt[i]) +"'");
}
logger.debug("_localData contains :");
for (Enumeration e = _localData.keys(); e.hasMoreElements();) {
Object key = e.nextElement();
logger.debug(key + " -> '"+ _localData.get(key) +"'");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy