made app.properties-object readonly, plus formatting fixes.

This commit is contained in:
stefanp 2002-07-29 12:46:36 +00:00
parent e6cf8647cc
commit 1012b31a6a

View file

@ -2,7 +2,9 @@ package helma.scripting.fesi;
import java.util.Map; import java.util.Map;
import helma.framework.core.ApplicationBean;
import helma.objectmodel.INode; import helma.objectmodel.INode;
import helma.util.SystemProperties;
import FESI.Interpreter.Evaluator; import FESI.Interpreter.Evaluator;
import FESI.Exceptions.EcmaScriptException; import FESI.Exceptions.EcmaScriptException;
@ -24,16 +26,20 @@ public class ESBeanWrapper extends ESWrapper {
} }
/** /**
* Wrap getProperty, return ESNode if INode would be returned. * Wrap getProperty, return ESNode if INode would be returned,
* ESMapWrapper if Map would be returned.
*/ */
public ESValue getProperty(String propertyName, int hash) public ESValue getProperty(String propertyName, int hash) throws EcmaScriptException {
throws EcmaScriptException {
try { try {
ESValue val = super.getProperty (propertyName, hash); ESValue val = super.getProperty (propertyName, hash);
if (val instanceof ESWrapper && ((ESWrapper)val).getJavaObject() instanceof INode) { Object theObject = ((ESWrapper)val).getJavaObject ();
return eval.getNodeWrapper( (INode) ((ESWrapper)val).getJavaObject() ); if (val instanceof ESWrapper && theObject instanceof INode) {
} else if (val instanceof ESWrapper && ((ESWrapper)val).getJavaObject() instanceof Map) { return eval.getNodeWrapper ((INode) theObject);
return new ESMapWrapper(eval, (Map) ((ESWrapper)val).getJavaObject() ); } else if (val instanceof ESWrapper && theObject instanceof Map) {
ESMapWrapper wrapper = new ESMapWrapper(eval, (Map) theObject);
if (theObject instanceof SystemProperties && super.getJavaObject () instanceof ApplicationBean)
wrapper.setReadonly(true);
return wrapper;
} else { } else {
return val; return val;
} }
@ -42,8 +48,7 @@ public class ESBeanWrapper extends ESWrapper {
} }
} }
public void putProperty(String propertyName, ESValue propertyValue, int hash) public void putProperty(String propertyName, ESValue propertyValue, int hash) throws EcmaScriptException {
throws EcmaScriptException {
try { try {
super.putProperty (propertyName, propertyValue, hash); super.putProperty (propertyName, propertyValue, hash);
} catch (Exception rte) { } catch (Exception rte) {