This commit was manufactured by cvs2svn to create tag

'helma_1_2_pre4'.
This commit is contained in:
hns 2002-12-06 18:17:33 +00:00
parent 817395e8b0
commit c512ce3cbe
38 changed files with 346 additions and 710 deletions

View file

@ -78,11 +78,6 @@ class CompatibilityDescriptor {
}
}
}
// convert
} // convert
}
// class CompatibilityDescriptor
} // class CompatibilityDescriptor

View file

@ -185,15 +185,11 @@ public final class ESArguments extends ESObject {
ESValue[] argumentValues) {
ObjectPrototype op =
(ObjectPrototype) evaluator.getObjectPrototype();
// Get maximum number of arguments (formal or actual), as
// more than the number of formal arguments can be reached
// using the (old fashioned) arguments variable).
int maxArgs = Math.max(argumentValues.length, argumentNames.length);
ESArguments args = new ESArguments(op, evaluator, argumentNames,
maxArgs,
Math.max(argumentValues.length, argumentNames.length),
callee);
try {
for (int i=0; i<maxArgs; i++) {
for (int i=0; i<argumentValues.length; i++) {
ESValue val = (i<argumentValues.length) ? argumentValues[i] :
ESUndefined.theUndefined;
if (i<argumentNames.length) {

View file

@ -53,7 +53,7 @@ public class ESBeans extends ESLoader {
*/
public ESBeans(String packageName,
ESBeans previousPackage,
ClassLoader classLoader,
LocalClassLoader classLoader,
Evaluator evaluator) {
super(packageName,previousPackage,classLoader,evaluator);
}
@ -94,7 +94,7 @@ public class ESBeans extends ESLoader {
throw new EcmaScriptException("Missing class directory or jar file name");
}
String directoryOrJar = arguments[0].toString();
ClassLoader classLoader =
LocalClassLoader classLoader =
LocalClassLoader.makeLocalClassLoader(directoryOrJar);
return new ESBeans(null, null, classLoader, evaluator);
} else {
@ -146,4 +146,4 @@ public class ESBeans extends ESLoader {
}
}

View file

@ -56,7 +56,7 @@ public abstract class ESLoader extends ESObject {
// Incremental package name
protected String packageName = null;
protected ESLoader previousPackage = null;
protected ClassLoader classLoader = null;
protected LocalClassLoader classLoader = null;
// the non compatible flag
static private CompatibilityDescriptor nonCompatible =
@ -69,15 +69,7 @@ public abstract class ESLoader extends ESObject {
public ESLoader(Evaluator evaluator) {
super(null, evaluator);
}
/**
* To contruct the Bean or Package object with a specific class loader
*/
public ESLoader(Evaluator evaluator, ClassLoader loader) {
super(null, evaluator);
this.classLoader = loader;
}
/**
* To construct a bean or package sub-object (with a specific
* partial or complete package name
@ -88,7 +80,7 @@ public abstract class ESLoader extends ESObject {
*/
public ESLoader(String packageName,
ESLoader previousPackage,
ClassLoader classLoader,
LocalClassLoader classLoader,
Evaluator evaluator) {
super(null, evaluator);
this.packageName = packageName;

View file

@ -34,7 +34,7 @@ import java.util.zip.*;
* Implements the object loader
*/
public class ESPackages extends ESLoader {
/**
* Create the top level package loader (object Package)
* @param evaluator the evaluator
@ -42,14 +42,6 @@ public class ESPackages extends ESLoader {
public ESPackages(Evaluator evaluator) {
super(evaluator);
}
/**
* Create the top level package loader (object Package)
* @param evaluator the evaluator
*/
public ESPackages(Evaluator evaluator, ClassLoader loader) {
super(evaluator, loader);
}
/**
* Create a new package loader or package prefix
@ -60,7 +52,7 @@ public class ESPackages extends ESLoader {
*/
public ESPackages(String packageName,
ESPackages previousPackage,
ClassLoader classLoader,
LocalClassLoader classLoader,
Evaluator evaluator) {
super(packageName,previousPackage,classLoader,evaluator);
}
@ -125,7 +117,7 @@ public class ESPackages extends ESLoader {
throw new EcmaScriptException("Missing class directory or file name");
}
String directoryOrJar = arguments[0].toString();
ClassLoader classLoader =
LocalClassLoader classLoader =
LocalClassLoader.makeLocalClassLoader(directoryOrJar);
return new ESPackages(null, null, classLoader, evaluator);
} else {
@ -147,4 +139,4 @@ public class ESPackages extends ESLoader {
}
}

View file

@ -338,10 +338,10 @@ class ESRowSet extends ESObject {
this.statement = statement;
this.resultSet = resultSet;
if (sql==null) throw new NullPointerException("sql");
if (resultSet==null) throw new NullPointerException("resultSet");
if (statement==null) throw new NullPointerException("statement");
if (database==null) throw new NullPointerException("database");
if (sql==null) throw new NullPointerException();
if (resultSet==null) throw new NullPointerException();
if (statement==null) throw new NullPointerException();
if (database==null) throw new NullPointerException();
try {

View file

@ -168,13 +168,7 @@ public class ClassInfo {
if (indexedReadMethod != null && indexedReadMethod.getParameterTypes().length != 1) {
throw new ProgrammingError("Indexed getter of property ' " + propertyName + "' should have 1 parameter!");
}
// Work around reflection bug, Hannes Wallnoefer 11/2002
if (indexedReadMethod != null && Modifier.isPublic (indexedReadMethod.getModifiers ()))
indexedReadMethod.setAccessible (true);
if (indexedWriteMethod != null) {
// Work around reflection bug, Hannes Wallnoefer 11/2002
if (Modifier.isPublic (indexedWriteMethod.getModifiers ()))
indexedWriteMethod.setAccessible (true);
Class [] paramCls = indexedWriteMethod.getParameterTypes();
if (paramCls == null || paramCls.length != 2) {
throw new ProgrammingError("Indexed setter of property ' " + propertyName + "' should have 2 parameter!");
@ -194,13 +188,7 @@ public class ClassInfo {
if (readMethod != null && readMethod.getParameterTypes().length != 0) {
throw new ProgrammingError("Non indexed getter of indxed property ' " + propertyName + "' is not supposed to have a parameter!");
}
// Work around reflection bug, Hannes Wallnoefer 11/2002
if (readMethod != null && Modifier.isPublic (readMethod.getModifiers ()))
readMethod.setAccessible (true);
if (writeMethod != null) {
// Work around reflection bug, Hannes Wallnoefer 11/2002
if (Modifier.isPublic (writeMethod.getModifiers ()))
writeMethod.setAccessible (true);
Class [] paramCls = writeMethod.getParameterTypes();
if (paramCls == null || paramCls.length != 1) {
throw new ProgrammingError("Non indexed setter of indexed property ' " + propertyName + "' should have 1 parameter!");
@ -220,13 +208,7 @@ public class ClassInfo {
if (readMethod != null && readMethod.getParameterTypes().length != 0) {
throw new ProgrammingError("Non indexed getter of property ' " + propertyName + "' is not supposed to have a parameter!");
}
// Work around reflection bug, Hannes Wallnoefer 11/2002
if (readMethod != null && Modifier.isPublic (readMethod.getModifiers ()))
readMethod.setAccessible (true);
if (writeMethod != null) {
// Work around reflection bug, Hannes Wallnoefer 11/2002
if (Modifier.isPublic (writeMethod.getModifiers ()))
writeMethod.setAccessible (true);
Class [] paramCls = writeMethod.getParameterTypes();
if (paramCls == null || paramCls.length != 1) {
throw new ProgrammingError("Non indexed setter of property ' " + propertyName + "' should have 1 parameter!");
@ -236,8 +218,8 @@ public class ClassInfo {
}
}
}
// Add to cache
// Add to cache
if (debug) System.out.println("** property '" + propertyName + "' + found, add to cache");
if (beanProperties==null) {
beanProperties = new Hashtable();
@ -248,7 +230,7 @@ public class ClassInfo {
}
return descriptor;
}
/**
* Get the list of public method in this class or superclass, by name (the
@ -417,7 +399,6 @@ public class ClassInfo {
}
} // if class not public
// Work around reflection bug, Hannes Wallnoefer 11/2002
if (Modifier.isPublic (method.getModifiers ()))
method.setAccessible (true);
// save it
@ -537,7 +518,6 @@ public class ClassInfo {
}
} // for
} // if class not public
// Work around reflection bug, Hannes Wallnoefer 11/2002
if (Modifier.isPublic (method.getModifiers ()))
method.setAccessible (true);
// save it

View file

@ -247,14 +247,14 @@ public class EcmaScriptEvaluateVisitor
boolean b2 =v2.booleanValue();
return b1==b2;
}
// ESNode wrappers must be checked with equals() because
// it's possible that different wrappers wrap the same node!
if (v1 instanceof helma.scripting.fesi.ESNode ||
v1 instanceof helma.scripting.fesi.ESGenericObject) {
if (v1 instanceof helma.scripting.fesi.ESNode ||
v1 instanceof helma.scripting.fesi.ESGenericObject) {
return v1.equals (v2);
}
return v1 == v2;
}
@ -311,8 +311,8 @@ public class EcmaScriptEvaluateVisitor
public Object visit(ASTStatementList node, Object data) {
int n = node.jjtGetNumChildren();
// Return ESUndefined for empty statement lists (for
// example generated by calling 'function(){}')
// Accepts empty statement lists (for example generated
// by function(){}
Object result = ESUndefined.theUndefined;
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
if (completionCode != C_NORMAL) return result;
@ -344,11 +344,11 @@ public class EcmaScriptEvaluateVisitor
}
public Object visit(ASTVariableDeclaration node, Object data) {
Object result = null;
int nChildren = node.jjtGetNumChildren();
if (nChildren<1 || nChildren>2) {
throw new ProgrammingError("Bad AST in variable declaration");
}
Object result = null;
if (nChildren == 2) {
try {
Object lvo = node.jjtGetChild(0).jjtAccept(this,FOR_REFERENCE);
@ -376,7 +376,7 @@ public class EcmaScriptEvaluateVisitor
throw new ProgrammingError("Bad AST in IF statement");
}
try {
ESValue testValue = acceptNull(node.jjtGetChild(0).jjtAccept(this, FOR_VALUE));
ESValue testValue = (ESValue) node.jjtGetChild(0).jjtAccept(this, FOR_VALUE);
boolean test = testValue.booleanValue();
if (test) {
result = node.jjtGetChild(1).jjtAccept(this,FOR_VALUE);
@ -395,7 +395,7 @@ public class EcmaScriptEvaluateVisitor
Object result = null;
node.assertTwoChildren();
try {
ESValue testValue = acceptNull(node.jjtGetChild(0).jjtAccept(this,FOR_VALUE));
ESValue testValue = (ESValue) node.jjtGetChild(0).jjtAccept(this,FOR_VALUE);
while (testValue.booleanValue()) {
// Thread.yield ();
@ -406,13 +406,13 @@ public class EcmaScriptEvaluateVisitor
if (completionCode == C_RETURN) {
return result;
} else if (completionCode == C_BREAK) {
completionCode = C_NORMAL;
completionCode = C_NORMAL;
return result;
} else if (completionCode == C_CONTINUE) {
testValue = acceptNull(node.jjtGetChild(0).jjtAccept(this,FOR_VALUE));
testValue = (ESValue) node.jjtGetChild(0).jjtAccept(this,FOR_VALUE);
completionCode = C_NORMAL;
} else {
testValue = acceptNull(node.jjtGetChild(0).jjtAccept(this,FOR_VALUE));
testValue = (ESValue) node.jjtGetChild(0).jjtAccept(this,FOR_VALUE);
}
}
} catch (EcmaScriptException e) {
@ -433,7 +433,7 @@ public class EcmaScriptEvaluateVisitor
if (testNode instanceof ASTEmptyExpression) {
testValue = ESBoolean.makeBoolean(true);
} else {
testValue = acceptNull(testNode.jjtAccept(this,FOR_VALUE));
testValue = (ESValue) testNode.jjtAccept(this,FOR_VALUE);
}
while (testValue.booleanValue()) {
// Thread.yield ();
@ -452,7 +452,7 @@ public class EcmaScriptEvaluateVisitor
if (testNode instanceof ASTEmptyExpression) {
testValue = ESBoolean.makeBoolean(true);
} else {
testValue = acceptNull(testNode.jjtAccept(this,FOR_VALUE));
testValue = (ESValue) testNode.jjtAccept(this,FOR_VALUE);
}
completionCode = C_NORMAL;
} else {
@ -460,7 +460,7 @@ public class EcmaScriptEvaluateVisitor
if (testNode instanceof ASTEmptyExpression) {
testValue = ESBoolean.makeBoolean(true);
} else {
testValue = acceptNull(testNode.jjtAccept(this,FOR_VALUE));
testValue = (ESValue) testNode.jjtAccept(this,FOR_VALUE);
}
}
@ -483,7 +483,7 @@ public class EcmaScriptEvaluateVisitor
if (testNode instanceof ASTEmptyExpression) {
testValue = ESBoolean.makeBoolean(true);
} else {
testValue = acceptNull(testNode.jjtAccept(this,FOR_VALUE));
testValue = (ESValue) testNode.jjtAccept(this,FOR_VALUE);
}
while (testValue.booleanValue()) {
result = node.jjtGetChild(3).jjtAccept(this,FOR_VALUE);
@ -498,7 +498,7 @@ public class EcmaScriptEvaluateVisitor
if (testNode instanceof ASTEmptyExpression) {
testValue = ESBoolean.makeBoolean(true);
} else {
testValue = acceptNull(testNode.jjtAccept(this,FOR_VALUE));
testValue = (ESValue) testNode.jjtAccept(this,FOR_VALUE);
}
completionCode = C_NORMAL;
} else {
@ -506,18 +506,18 @@ public class EcmaScriptEvaluateVisitor
if (testNode instanceof ASTEmptyExpression) {
testValue = ESBoolean.makeBoolean(true);
} else {
testValue = acceptNull(testNode.jjtAccept(this,FOR_VALUE));
testValue = (ESValue) testNode.jjtAccept(this,FOR_VALUE);
}
}
// Thread.yield ();
if (evaluator.thread != Thread.currentThread())
throw new helma.framework.TimeoutException();
}
} catch (EcmaScriptException e) {
throw new PackagedException(e,node);
}
}
return result;
}
@ -525,7 +525,7 @@ public class EcmaScriptEvaluateVisitor
Object result = null; // No value by default
node.assertThreeChildren();
try {
ESValue ob = acceptNull(node.jjtGetChild(1).jjtAccept(this,FOR_VALUE));
ESValue ob = (ESValue) node.jjtGetChild(1).jjtAccept(this,FOR_VALUE);
ESObject obj = (ESObject) ob.toESObject(evaluator);
boolean directEnumeration = obj.isDirectEnumerator();
for (Enumeration e = obj.getProperties() ; e.hasMoreElements() ;) {
@ -576,10 +576,10 @@ public class EcmaScriptEvaluateVisitor
// Should not happen as it should be an identifier
throw new ProgrammingError("Value '"+lvo.toString()+"' is not a variable");
}
ESValue init = acceptNull(node.jjtGetChild(1).jjtAccept(this, FOR_VALUE));
ESValue init = (ESValue) node.jjtGetChild(1).jjtAccept(this, FOR_VALUE);
evaluator.putValue(lv, init);
ESValue ob = acceptNull(node.jjtGetChild(2).jjtAccept(this,FOR_VALUE));
ESValue ob = (ESValue) node.jjtGetChild(2).jjtAccept(this,FOR_VALUE);
ESObject obj = (ESObject) ob.toESObject(evaluator);
boolean directEnumeration = obj.isDirectEnumerator();
for (Enumeration e = obj.getProperties() ; e.hasMoreElements() ;) {
@ -635,7 +635,7 @@ public class EcmaScriptEvaluateVisitor
ESValue result = null;
try {
EvaluationSource es = (EvaluationSource) node.getEvaluationSource();
ESValue scopeValue = acceptNull(node.jjtGetChild(0).jjtAccept(this,FOR_VALUE));
ESValue scopeValue = (ESValue) node.jjtGetChild(0).jjtAccept(this,FOR_VALUE);
ASTStatement statementNode = (ASTStatement) (node.jjtGetChild(1));
ESObject scopeObject = (ESObject) scopeValue.toESObject(evaluator);
result = evaluator.evaluateWith(statementNode, scopeObject, es);
@ -679,7 +679,7 @@ public class EcmaScriptEvaluateVisitor
String id = ((ASTIdentifier)baseNode).getName();
currentProperty = new ESString(id);
} else {
lastResult = acceptNull(baseNode.jjtAccept(this,FOR_VALUE));
lastResult = (ESValue) baseNode.jjtAccept(this,FOR_VALUE);
currentProperty = null; // No reference so far
}
}
@ -811,10 +811,7 @@ public class EcmaScriptEvaluateVisitor
//System.out.println("--->Build value cp: " + currentProperty + " lr: " + lastResult + "<---"); // ********
if (currentProperty != null) {
// Must dereference value
if (lastResult == null) {
throw new EcmaScriptException("'undefined' is not an object with properties");
}
ESObject currentBase = (ESObject) lastResult.toESObject(evaluator);
ESObject currentBase = (ESObject) lastResult.toESObject(evaluator);
String propertyName = currentProperty.toString();
//System.out.println("--->getProperty in cb: " + currentBase + " pn: " + propertyName + "<---"); // *******
result = currentBase.getProperty(propertyName,propertyName.hashCode());
@ -825,9 +822,6 @@ public class EcmaScriptEvaluateVisitor
} else {
// We want a reference - therefore it cannot be just a value, it
// must be a delayed reference.
if (lastResult == null) {
throw new EcmaScriptException("'undefined' is not an assignable value");
}
if (currentProperty == null) {
throw new EcmaScriptException("'"+lastResult.toString()+"' is not an assignable value");
}
@ -856,7 +850,7 @@ public class EcmaScriptEvaluateVisitor
public Object visit(ASTPropertyValueReference node, Object data) {
node.assertOneChild();
return acceptNull(node.jjtGetChild(0).jjtAccept(this, FOR_VALUE));
return node.jjtGetChild(0).jjtAccept(this, FOR_VALUE);
}
public Object visit(ASTPropertyIdentifierReference node, Object data) {
@ -878,8 +872,7 @@ public class EcmaScriptEvaluateVisitor
try {
int nChildren=node.jjtGetNumChildren();
Node baseNode = node.jjtGetChild(0);
// Can be any expression (in fact a a.b.c sequence) [code bizare here]
ESValue constr = acceptNull(baseNode.jjtAccept(this, FOR_VALUE));
ESValue constr = (ESValue) baseNode.jjtAccept(this, FOR_VALUE); // Can be any expression (in fact a a.b.c sequence)
Node compositor = node.jjtGetChild(1);
if (compositor instanceof ASTFunctionCallParameters) {
ASTFunctionCallParameters fc = (ASTFunctionCallParameters) compositor;
@ -963,8 +956,7 @@ public class EcmaScriptEvaluateVisitor
if (n instanceof ASTIdentifier) {
// We need to get a reference, as an null based referenced is "undefined"
ESReference ref = (ESReference) n.jjtAccept(this,FOR_REFERENCE);
// If reference to nothing, consider undefined
if (ref == null || ref.getBase()==null) {
if (ref.getBase()==null) {
r = new ESString("undefined");
} else {
ESValue v = ref.getValue();
@ -972,7 +964,7 @@ public class EcmaScriptEvaluateVisitor
}
} else {
// It is a value, directly get its string
ESValue v = acceptNull(n.jjtAccept(this,FOR_VALUE));
ESValue v = (ESValue) n.jjtAccept(this,FOR_VALUE);
r = new ESString(v.getTypeofString());
}
}
@ -1043,9 +1035,9 @@ public class EcmaScriptEvaluateVisitor
public Object visit(ASTBinaryExpressionSequence node, Object data) {
ESValue result = null;
try {
ESValue v1 = acceptNull(node.jjtGetChild(0).jjtAccept(this,FOR_VALUE));
ESValue v1 = (ESValue) node.jjtGetChild(0).jjtAccept(this,FOR_VALUE);
for (int i = 0; i < node.jjtGetNumChildren()-1; i+=2) {
ESValue v2 = acceptNull(node.jjtGetChild(i+2).jjtAccept(this,FOR_VALUE));
ESValue v2 = (ESValue) node.jjtGetChild(i+2).jjtAccept(this,FOR_VALUE);
int operator = ((ASTOperator)(node.jjtGetChild(i+1))).getOperator();
// System.out.println("V1 = " + v1 + " v2 = " + v2);
switch (operator) {
@ -1176,10 +1168,10 @@ public class EcmaScriptEvaluateVisitor
ESValue result = null;
int nChildren = node.jjtGetNumChildren();
try {
result = acceptNull(node.jjtGetChild(0).jjtAccept(this,FOR_VALUE));
result = (ESValue) node.jjtGetChild(0).jjtAccept(this,FOR_VALUE);
int i = 1;
while (result.booleanValue() && (i<nChildren)) {
result = acceptNull(node.jjtGetChild(i).jjtAccept(this,FOR_VALUE));
result = (ESValue) node.jjtGetChild(i).jjtAccept(this,FOR_VALUE);
i ++;
}
// Normalize to primitive - could be optimized...
@ -1194,10 +1186,10 @@ public class EcmaScriptEvaluateVisitor
int nChildren = node.jjtGetNumChildren();
ESValue result = null;
try {
result = acceptNull(node.jjtGetChild(0).jjtAccept(this,FOR_VALUE));
result = (ESValue) node.jjtGetChild(0).jjtAccept(this,FOR_VALUE);
int i = 1;
while ((!result.booleanValue()) && (i<nChildren)) {
result = acceptNull(node.jjtGetChild(i).jjtAccept(this,FOR_VALUE));
result = (ESValue) node.jjtGetChild(i).jjtAccept(this,FOR_VALUE);
i ++;
}
// Normalize to primitive - could be optimized...
@ -1218,7 +1210,7 @@ public class EcmaScriptEvaluateVisitor
node.assertThreeChildren();
Object result = null;
try {
ESValue t = acceptNull(node.jjtGetChild(0).jjtAccept(this,FOR_VALUE));
ESValue t = (ESValue) node.jjtGetChild(0).jjtAccept(this,FOR_VALUE);
boolean test = t.booleanValue();
if (test) {
result = node.jjtGetChild(1).jjtAccept(this, FOR_VALUE);
@ -1236,6 +1228,7 @@ public class EcmaScriptEvaluateVisitor
ESValue result = null;
try {
// Get left hand side
Object lvo = node.jjtGetChild(0).jjtAccept(this,FOR_REFERENCE);
//System.out.println("REF: " + lvo);
ESReference lv;
@ -1245,7 +1238,8 @@ public class EcmaScriptEvaluateVisitor
throw new EcmaScriptException("Value '"+lvo.toString()+"' is not an assignable object or property");
}
ESValue v2 = acceptNull(node.jjtGetChild(2).jjtAccept(this,FOR_VALUE));
// get Right hand side
ESValue v2 = (ESValue) node.jjtGetChild(2).jjtAccept(this,FOR_VALUE);
// Case analysis based on assignement operator type
int operator = ((ASTOperator)(node.jjtGetChild(1))).getOperator();
@ -1254,7 +1248,7 @@ public class EcmaScriptEvaluateVisitor
evaluator.putValue(lv, v2);
result = v2;
} else {
// All composite assignement requires a current value
// All composite assignement requires a current value
ESValue v1 = lv.getValue();
switch (operator) {
case PLUSASSIGN: {
@ -1367,30 +1361,7 @@ public class EcmaScriptEvaluateVisitor
}
return result;
}
/**
* To transform a null (empty) result (but not an ESNull!)
* in 'ESUndefined'. null results may be returned if a
* statement as the empty statement, missing else clause of
* an if statement, loop not executed at all, etc.. is executed
* for value (for example as the last statement of a called function
* used in an assignement). This is a programming error, and it
* may be useful to modify this function to generate an exception
* during debugging. However other implementation seem to accept
* ESUndefined in these cases. The standard is not totally clear
* to me.
* <P>An alternative would be to return ESUndefined in all cases,
* but then we lose a useful distinction (at least for debugging...).
* <P>A couple of tests are done in visit(ASTCompositeReference node, ...
* too.
*/
static protected ESValue acceptNull(Object v) {
if (v == null) {
// Accept null (could generate an optional exception).
return ESUndefined.theUndefined;
} else {
// Take advantage to convert...
return (ESValue) v;
}
}
}

View file

@ -33,8 +33,6 @@ import java.util.StringTokenizer;
import java.io.*;
import java.util.zip.*;
import helma.scripting.fesi.FesiEngine;
/**
* Defines the evaluation interface and contains the evaluation context.
* <P><B>Important:</B> This object is also used as the synchronization
@ -43,11 +41,11 @@ import helma.scripting.fesi.FesiEngine;
* for speed reasons.
*/
public class Evaluator {
// used to stop thread, 06.12.99 Hannes Wallnoefer
public volatile Thread thread;
// used to retrieve wrappers with correct Prototype for path elements in ESLoader
public final FesiEngine engine;
public helma.scripting.fesi.FesiEngine engine;
private static String eol = System.getProperty("line.separator", "\n");
@ -55,7 +53,7 @@ public class Evaluator {
* Return the version identifier of the interpreter
*/
public static String getVersion() {
return "1.1.5 (29-July-2000)";
return "1.1.4 (30-Jan-2000)";
}
/**
@ -106,25 +104,16 @@ public class Evaluator {
varDeclarationVisitor = new EcmaScriptVariableVisitor(this);
// evaluationVisitor = new EcmaScriptEvaluateVisitor(this);
globalObject = GlobalObject.makeGlobalObject(this);
packageObject = engine == null ?
new ESPackages(this) :
new ESPackages(this, engine.getClassLoader ());
packageObject = new ESPackages(this);
extensions = new Hashtable(); // forget extensions
}
/**
* Create a new empty evaluator
*/
public Evaluator () {
this.engine = null;
reset();
}
/**
* Create a new empty evaluator
*/
public Evaluator (FesiEngine engine) {
this.engine = engine;
reset();
}
@ -294,7 +283,6 @@ public class Evaluator {
*/
public void setDatePrototype(ESObject o) {
datePrototype = o;
}
/**
* Get the Date prototype object
@ -312,6 +300,7 @@ public class Evaluator {
return packageObject;
}
//------------------------------------------------------------
// Extension support
//------------------------------------------------------------
@ -514,16 +503,11 @@ public class Evaluator {
*/
public ESValue evaluateEvalString(String theSource) throws EcmaScriptException {
ESValue theValue = ESUndefined.theUndefined;
ASTProgram programNode = null;
StringEvaluationSource es = new StringEvaluationSource(theSource, null);
// Hack - this ensures correct parsing of // comments
// even if no EOL is present (as in an eval('1//a'))
if (!theSource.endsWith("\n")) {
theSource += "\n";
}
java.io.StringReader is =
new java.io.StringReader(theSource);
EcmaScript parser = new EcmaScript(is);
ASTProgram programNode = null;
StringEvaluationSource es = new StringEvaluationSource(theSource, null);
try {
// ASTProgram n = parser.Program();
programNode = (ASTProgram)parser.Program();
@ -776,6 +760,7 @@ public class Evaluator {
// currentEvaluationSource = es;
try {
for (Enumeration e = localVariableNames.elements() ; e.hasMoreElements() ;) {
String variable =(String)(e.nextElement());
createVariable(variable, variable.hashCode());
}
@ -851,8 +836,6 @@ public class Evaluator {
EcmaScriptEvaluateVisitor evaluationVisitor = new EcmaScriptEvaluateVisitor(this);
try {
// Hannes Wallnoefer, 2002/11/29: Pass thisObject to EcmaScriptFunctionVisitor so that
// functions are assigned to the prototype instead of the global object
functionDeclarationVisitor.processFunctionDeclarations(node, program.getEvaluationSource(), thisObject);
Vector variables = program.getVariableNames();
for (Enumeration e = variables.elements() ; e.hasMoreElements() ;) {
@ -990,11 +973,6 @@ public class Evaluator {
ESValue v = null;
EvaluationSource es = new UserEvaluationSource(source, null);
try {
// Hack - this ensures correct parsing of // comments
// even if no EOL is present (as in an eveal command)/
if (!text.endsWith("\n")) {
text += "\n";
}
is = new java.io.StringReader(text);
v = evaluate(is, globalObject, es, false);
} finally {
@ -1026,6 +1004,7 @@ public class Evaluator {
synchronized public ESValue evaluate(File file, ESObject thisObject)
throws EcmaScriptException, IOException {
EvaluationSource es = new FileEvaluationSource(file.getPath(), null);
FileReader fr = null;
ESValue value = null;
try {
@ -1071,11 +1050,6 @@ public class Evaluator {
java.io.StringReader is = null;
ESValue v = null;
EvaluationSource es = new StringEvaluationSource(theSource, null);
// Hack - this ensures correct parsing of // comments
// even if no EOL is present (as in an eveal command)/
if (!theSource.endsWith("\n")) {
theSource += "\n";
}
try {
is = new java.io.StringReader(theSource);
v = evaluate(is, thisObject, es, returnAccepted);

View file

@ -349,7 +349,7 @@ class FesiHashtable implements Cloneable {
public ESValue put(String key, int hash, boolean hidden, boolean readonly, ESValue value) {
// Make sure the value is not null
if (value == null) {
throw new NullPointerException("value");
throw new NullPointerException();
}
// Makes sure the key is not already in the hashtable.

View file

@ -13,7 +13,6 @@ public final class ASCII_CharStream
int available;
int tokenBegin;
public int bufpos = -1;
boolean addedNewline = false;
private int bufline[];
private int bufcolumn[];
@ -108,14 +107,8 @@ public final class ASCII_CharStream
if ((i = inputStream.read(buffer, maxNextCharInd,
available - maxNextCharInd)) == -1)
{
if (!addedNewline) {
addedNewline = true;
buffer[maxNextCharInd] = '\n';
i = 1;
} else {
inputStream.close();
throw new java.io.IOException();
}
inputStream.close();
throw new java.io.IOException();
}
else
maxNextCharInd += i;
@ -272,7 +265,6 @@ public final class ASCII_CharStream
prevCharIsLF = prevCharIsCR = false;
tokenBegin = inBuf = maxNextCharInd = 0;
bufpos = -1;
addedNewline = false;
}
public void ReInit(java.io.Reader dstream, int startline,
@ -382,4 +374,4 @@ public final class ASCII_CharStream
column = bufcolumn[j];
}
}
}

View file

@ -3164,6 +3164,14 @@ public class EcmaScript/*@bgen(jjtree)*/implements EcmaScriptTreeConstants, Ecma
return false;
}
final private boolean jj_3R_60() {
if (jj_3R_64()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
if (jj_3R_59()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_24() {
if (jj_scan_token(FOR)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
@ -3174,14 +3182,6 @@ public class EcmaScript/*@bgen(jjtree)*/implements EcmaScriptTreeConstants, Ecma
return false;
}
final private boolean jj_3R_60() {
if (jj_3R_64()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
if (jj_3R_59()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_131() {
if (jj_3R_138()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;

View file

@ -1654,13 +1654,6 @@ final void SkipLexicalActions(Token matchedToken)
{
switch(jjmatchedKind)
{
case 8 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
input_stream.backup(1);
break;
default :
break;
}

View file

@ -53,6 +53,7 @@ public class DocFunction extends DocFileElement {
}
/**
* reads a function file and creates DocFunction objects of type FUNCTION
* connected to another DocElement.
@ -102,9 +103,7 @@ public class DocFunction extends DocFileElement {
func.parseSource (location, beginLine, beginColumn, endLine, endColumn);
vec.add (func);
}
if (tok.kind != EcmaScriptConstants.FUNCTION) {
tok = mgr.getNextToken();
}
tok = mgr.getNextToken();
}
return (DocFunction[]) vec.toArray (new DocFunction[0]);
}

View file

@ -45,19 +45,5 @@ public class DocProperties extends DocFileElement {
return props;
}
public Properties getMappings () {
Properties childProps = new Properties ();
for (Enumeration e = props.keys (); e.hasMoreElements (); ) {
String key = (String) e.nextElement ();
String value = props.getProperty (key);
if (value.startsWith ("collection") || value.startsWith ("object") || value.startsWith ("mountpoint")) {
String prototype = value.substring (value.indexOf("(")+1, value.indexOf(")")).trim ();
childProps.setProperty (key, prototype);
}
}
return childProps;
}
}

View file

@ -51,11 +51,7 @@ public final class DocTag {
String name = "";
if (tok.hasMoreTokens ())
name = tok.nextToken ();
String comment = "";
try {
comment = content.substring (name.length ()+1).trim ();
} catch (StringIndexOutOfBoundsException e) { }
return new DocTag (kind, name, comment);
return new DocTag (kind, name, content.substring (name.length ()+1).trim ());
} else {
return new DocTag (kind, "", content);
}

View file

@ -929,14 +929,6 @@ public final class Application implements IPathElement, Runnable {
}
return null;
}
/**
* Return the application's classloader
*/
public ClassLoader getClassLoader () {
return typemgr.loader;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// The following methods mimic the IPathElement interface. This allows us

View file

@ -72,9 +72,9 @@ public final class RequestEvaluator implements Runnable {
if (scriptingEngine == null) {
String engineClassName = app.getProperty (
"scriptingEngine",
"helma.scripting.fesi.PhantomEngine");
"helma.scripting.fesi.FesiEngine");
try {
Class clazz = app.getClassLoader().loadClass (engineClassName);
Class clazz = app.typemgr.loader.loadClass (engineClassName);
scriptingEngine = (ScriptingEngine) clazz.newInstance ();
scriptingEngine.init (app, this);
} catch (Exception x) {
@ -666,7 +666,6 @@ public final class RequestEvaluator implements Runnable {
if (rtx == null || !rtx.isAlive()) {
// app.logEvent ("Starting Thread");
rtx = new Transactor (this, app.threadgroup, app.nmgr);
rtx.setContextClassLoader (app.getClassLoader ());
rtx.start ();
} else {
notifyAll ();

View file

@ -10,7 +10,6 @@ import helma.util.*;
import java.util.*;
import java.io.*;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.MalformedURLException;
/**
@ -61,17 +60,7 @@ public final class TypeManager {
prototypes = new HashMap ();
zipfiles = new HashMap ();
jarfiles = new HashSet ();
URL[] urls = ((URLClassLoader) TypeManager.class.getClassLoader()).getURLs();
URL helmajar = null;
for (int i=0; i<urls.length; i++) {
String url = urls[i].toString().toLowerCase();
if (url.endsWith ("helma.jar")) {
helmajar = urls[i];
break;
}
}
if (helmajar == null)
throw new RuntimeException ("helma.jar not found in embedding classpath");
URL helmajar = new URL ("file:"+app.home.getAbsolutePath()+"/lib/helma.jar");
loader = new AppClassLoader(app.getName(), new URL[] { helmajar });
}

View file

@ -25,7 +25,7 @@ import org.apache.xmlrpc.*;
public class Server implements IPathElement, Runnable {
public static final String version = "1.2 RC2 2002/12/05";
public static final String version = "1.2pre4 2002/11/22";
public final long starttime;
// if true we only accept RMI and XML-RPC connections from
@ -222,15 +222,8 @@ import org.apache.xmlrpc.*;
} catch (IOException iox) {
System.err.println ("Error calling getCanonicalFile() on hopHome: "+iox);
}
// set the current working directory to the helma home dir.
// note that this is not a real cwd, which is not supported
// by java. It makes sure relative to absolute path name
// conversion is done right, so for Helma code, this should
// work.
System.setProperty ("user.dir", hopHome.getPath());
// from now on it's safe to call getLogger() because hopHome is set up
// from now on it's safe to call getLogger()
String startMessage = "Starting Helma "+version+
" on Java "+System.getProperty ("java.version");

View file

@ -29,7 +29,9 @@ public class FilteredClassLoader extends URLClassLoader {
* Mask classes that implement the scripting engine(s) contained in helma.jar
*/
protected Class findClass (String name) throws ClassNotFoundException {
if (name != null && "helma.scripting.fesi.PhantomEngine".equals (name))
if (name != null && (name.startsWith ("helma.scripting.fesi") ||
name.startsWith ("helma.doc") ||
name.startsWith ("FESI")))
throw new ClassNotFoundException (name);
return super.findClass (name);
}

View file

@ -27,38 +27,49 @@ public class Main {
// check if home directory is set via command line arg. If not,
// we'll get it from the location of the jar file this class
// has been loaded from.
String installDir = null;
String home = null;
// first, try to get helma home dir from command line options
for (int i=0; i<args.length; i++) {
if (args[i].equals ("-i") && i+1<args.length) {
installDir = args[i+1];
if (args[i].equals ("-h") && i+1<args.length) {
home = args[i+1];
}
}
URLClassLoader apploader = (URLClassLoader) ClassLoader.getSystemClassLoader();
// try to get Helma installation directory
if (installDir == null) {
if (home == null) {
try {
URL launcherUrl = apploader.findResource("helma/main/launcher/Main.class");
URL homeUrl = apploader.findResource("helma/main/launcher/Main.class");
// this is a JAR URL of the form
// jar:<url>!/{entry}
// we strip away the jar: prefix and the !/{entry} suffix
// to get the original jar file URL
installDir = launcherUrl.toString().substring(4);
int excl = installDir.indexOf ("!");
home = homeUrl.toString().substring(4);
int excl = home.indexOf ("!");
if (excl > -1) {
installDir = installDir.substring(0, excl);
launcherUrl = new URL (installDir);
File f = new File (launcherUrl.getPath());
installDir = f.getParentFile().getCanonicalPath();
home = home.substring(0, excl);
homeUrl = new URL (home);
File f = new File (homeUrl.getPath());
home = f.getParent();
// add home dir to the command line arguments
String[] newArgs = new String [args.length+2];
newArgs[0] = "-h";
newArgs[1] = home;
System.arraycopy (args, 0, newArgs, 2, args.length);
args = newArgs;
}
} catch (Exception x) {
// unable to get Helma installation dir from launcher jar
System.err.println ("Unable to get Helma installation directory: "+x);
} catch (Exception ignore) {
// unable to get Helma home dir from launcher jar
}
}
// set the current working directory to the helma home dir.
// note that this is not a real cwd, which is not supported
// by java. It makes sure relative to absolute path name
// conversion is done right, so for Helma code, this should
// work.
System.setProperty ("user.dir", home);
// set up the class path
File libdir = new File (installDir, "lib");
File libdir = new File (home, "lib");
ArrayList jarlist = new ArrayList ();
for (int i=0;i<jars.length;i++) {
File jar = new File (libdir, jars[i]);
@ -74,9 +85,9 @@ public class Main {
if (files != null)
for (int i=0;i<files.length; i++)
// WORKAROUND: add the files in lib/ext before
// lib/apache-dom.jar, since otherwise putting a full version
// of Xerces in lib/ext would cause a version conflict with the
// xerces classes in lib/apache-dom.jar. Generally, having some pieces
// lib/apache-dom.jar, since otherwise putting a full version
// of Xerces in lib/ext would cause a version conflict with the
// xerces classes in lib/apache-dom.jar. Generally, having some pieces
// of Xerces in lib/apache-dom.jar is kind of problematic.
jarlist.add (jars.length-3, new URL ("file:" + files[i].getAbsolutePath()));
URL[] urls = new URL[jarlist.size()];

View file

@ -1,46 +0,0 @@
// DbColumn.java
// Copyright 2002 Hannes Wallnoefer, Helma.org
package helma.objectmodel.db;
/**
* A class that encapsulates the Column name and data type of a
* column in a relational table.
*/
public final class DbColumn {
private final String name;
private final int type;
private final Relation relation;
/**
* Constructor
*/
public DbColumn (String name, int type, Relation rel) {
this.name = name;
this.type = type;
this.relation = rel;
}
/**
* Get the column name.
*/
public String getName() {
return name;
}
/**
* Get this columns SQL data type.
*/
public int getType() {
return type;
}
/**
* Return the relation associated with this column. May be null.
*/
public Relation getRelation() {
return relation;
}
}

View file

@ -13,8 +13,8 @@ import java.util.StringTokenizer;
import java.sql.*;
import com.workingdogs.village.*;
/**
* A DbMapping describes how a certain type of Nodes is to mapped to a
/**
* A DbMapping describes how a certain type of Nodes is to mapped to a
* relational database table. Basically it consists of a set of JavaScript property-to-
* Database row bindings which are represented by instances of the Relation class.
*/
@ -43,21 +43,15 @@ public final class DbMapping implements Updatable {
Relation subRelation;
Relation propRelation;
// if this defines a subnode mapping with groupby layer,
// we need a DbMapping for those groupby nodes
// if this defines a subnode mapping with groupby layer, we need a DbMapping for those groupby nodes
DbMapping groupbyMapping;
// Map of property names to Relations objects
HashMap prop2db;
// Map of db columns to Relations objects.
// Case insensitive, keys are stored in upper case so
// lookups must do a toUpperCase().
// Map of db columns to Relations objects
HashMap db2prop;
// list of columns to fetch from db
DbColumn[] columns = null;
// Map of db columns by name
HashMap columnMap;
String[] columns = null;
// pre-rendered select statement
String select = null;
@ -121,8 +115,6 @@ public final class DbMapping implements Updatable {
prop2db = new HashMap ();
db2prop = new HashMap ();
columnMap = new HashMap ();
parent = null;
@ -193,7 +185,6 @@ public final class DbMapping implements Updatable {
keydef = null;
// same with columns and select string
columns = null;
columnMap.clear();
select = null;
@ -220,8 +211,8 @@ public final class DbMapping implements Updatable {
rel.update (dbField, props);
p2d.put (propName, rel);
if (rel.columnName != null &&
(rel.reftype == Relation.PRIMITIVE ||
rel.reftype == Relation.REFERENCE))
(rel.reftype == Relation.PRIMITIVE ||
rel.reftype == Relation.REFERENCE))
d2p.put (rel.columnName.toUpperCase (), rel);
// app.logEvent ("Mapping "+propName+" -> "+dbField);
}
@ -240,7 +231,7 @@ public final class DbMapping implements Updatable {
if (subRelation == null)
subRelation = new Relation (subnodeMapping, "_children", this, props);
subRelation.update (subnodeMapping, props);
// if subnodes are accessed via access name or group name,
// if subnodes are accessed via access name or group name,
// the subnode relation is also the property relation.
if (subRelation.accessor != null || subRelation.groupby != null)
propRelation = subRelation;
@ -259,7 +250,7 @@ public final class DbMapping implements Updatable {
}
/**
/**
* Method in interface Updatable.
*/
public void remove () {
@ -488,7 +479,7 @@ public final class DbMapping implements Updatable {
groupbyMapping.typename = subRelation.groupbyPrototype;
}
public void setPropertyRelation (Relation rel) {
propRelation = rel;
}
@ -576,11 +567,11 @@ public final class DbMapping implements Updatable {
/**
* Return an array of DbColumns for the relational table mapped by this DbMapping.
* Return a Village Schema object for this DbMapping.
*/
public synchronized DbColumn[] getColumns() throws ClassNotFoundException, SQLException {
public synchronized String[] getColumns() throws ClassNotFoundException, SQLException {
if (!isRelational ())
throw new SQLException ("Can't get columns for non-relational data mapping "+this);
throw new SQLException ("Can't get Schema for non-relational data mapping");
if (source == null && parentMapping != null)
return parentMapping.getColumns ();
// Use local variable cols to avoid synchronization (schema may be nulled elsewhere)
@ -589,46 +580,25 @@ public final class DbMapping implements Updatable {
// and build a string of column names.
Connection con = getConnection ();
Statement stmt = con.createStatement ();
String t = getTableName();
if (t == null)
throw new SQLException ("Table name is null in getColumns() for "+this);
ResultSet rs = stmt.executeQuery (
new StringBuffer("SELECT * FROM ")
.append(t).append(" WHERE 1 = 0").toString());
ResultSet rs = stmt.executeQuery ("select * from "+getTableName()+" where 1 = 0");
if (rs == null)
throw new SQLException ("Error retrieving columns for "+this);
throw new SQLException ("Error retrieving DB scheme for "+this);
ResultSetMetaData meta = rs.getMetaData ();
// ok, we have the meta data, now loop through mapping...
int ncols = meta.getColumnCount ();
columns = new DbColumn[ncols];
columns = new String[ncols];
for (int i=0; i<ncols; i++) {
String colName = meta.getColumnName (i+1);
Relation rel = columnNameToRelation (colName);
columns[i] = new DbColumn (colName, meta.getColumnType (i+1), rel);
columns[i] = meta.getColumnName (i+1);
Relation rel = columnNameToRelation (columns[i]);
if (rel == null || (rel.reftype != Relation.PRIMITIVE &&
rel.reftype != Relation.REFERENCE))
continue;
rel.setColumnType (meta.getColumnType (i+1));
}
}
return columns;
}
public DbColumn getColumn (String columnName) throws ClassNotFoundException, SQLException {
DbColumn col = (DbColumn) columnMap.get(columnName);
if (col == null) {
DbColumn[] cols = columns;
if (cols == null)
cols = getColumns();
for (int i=0; i<cols.length; i++) {
if (columnName.equalsIgnoreCase (cols[i].getName())) {
col = cols[i];
break;
}
}
if (col == null)
throw new SQLException ("Column "+columnName+" not found in "+this);
columnMap.put (columnName, col);
}
return col;
}
public StringBuffer getSelect () throws SQLException, ClassNotFoundException {
String sel = select;
if (sel != null)
@ -649,8 +619,13 @@ public final class DbMapping implements Updatable {
if (table == null && parentMapping != null)
return parentMapping.needsQuotes (columnName);
try {
DbColumn col = getColumn (columnName);
switch (col.getType()) {
Relation rel = (Relation) db2prop.get (columnName.toUpperCase());
if (rel == null)
throw new SQLException ("Error retrieving relational schema for "+this);
// make sure columns are initialized and up to date
if (columns == null)
getColumns();
switch (rel.getColumnType()) {
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:

View file

@ -234,7 +234,7 @@ public final class Node implements INode, Serializable {
/**
* Constructor used for nodes being stored in a relational database table.
*/
public Node (DbMapping dbm, ResultSet rs, DbColumn[] columns, WrappedNodeManager nmgr)
public Node (DbMapping dbm, ResultSet rs, String[] columns, WrappedNodeManager nmgr)
throws SQLException {
this.nmgr = nmgr;
@ -265,35 +265,35 @@ public final class Node implements INode, Serializable {
for (int i=0; i<columns.length; i++) {
Relation rel = columns[i].getRelation();
Relation rel = dbm.columnNameToRelation (columns[i]);
if (rel == null || (rel.reftype != Relation.PRIMITIVE &&
rel.reftype != Relation.REFERENCE))
continue;
Property newprop = new Property (rel.propName, this);
switch (columns[i].getType()) {
switch (rel.getColumnType()) {
case Types.BIT:
newprop.setBooleanValue (rs.getBoolean(columns[i].getName()));
newprop.setBooleanValue (rs.getBoolean(columns[i]));
break;
case Types.TINYINT:
case Types.BIGINT:
case Types.SMALLINT:
case Types.INTEGER:
newprop.setIntegerValue (rs.getLong(columns[i].getName()));
newprop.setIntegerValue (rs.getLong(columns[i]));
break;
case Types.REAL:
case Types.FLOAT:
case Types.DOUBLE:
newprop.setFloatValue (rs.getDouble(columns[i].getName()));
newprop.setFloatValue (rs.getDouble(columns[i]));
break;
case Types.DECIMAL:
case Types.NUMERIC:
BigDecimal num = rs.getBigDecimal (columns[i].getName());
BigDecimal num = rs.getBigDecimal (columns[i]);
if (num == null)
break;
if (num.scale() > 0)
@ -305,20 +305,20 @@ public final class Node implements INode, Serializable {
case Types.LONGVARBINARY:
case Types.VARBINARY:
case Types.BINARY:
newprop.setStringValue (rs.getString(columns[i].getName()));
newprop.setStringValue (rs.getString(columns[i]));
break;
case Types.LONGVARCHAR:
case Types.CHAR:
case Types.VARCHAR:
case Types.OTHER:
newprop.setStringValue (rs.getString(columns[i].getName()));
newprop.setStringValue (rs.getString(columns[i]));
break;
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP:
newprop.setDateValue (rs.getTimestamp(columns[i].getName()));
newprop.setDateValue (rs.getTimestamp(columns[i]));
break;
case Types.NULL:
@ -327,7 +327,7 @@ public final class Node implements INode, Serializable {
// continue;
default:
newprop.setStringValue (rs.getString(columns[i].getName()));
newprop.setStringValue (rs.getString(columns[i]));
break;
}
@ -1837,7 +1837,7 @@ public final class Node implements INode, Serializable {
*/
public INode getNonVirtualParent () {
INode node = this;
for (int i=0; i<5; i++) {
for (int i=0; i<3; i++) {
if (node == null) break;
if (node.getState() != Node.VIRTUAL)
return node;

View file

@ -580,13 +580,7 @@ public final class NodeManager {
try {
Connection con = dbm.getConnection ();
st = con.createStatement ();
st.executeUpdate (new StringBuffer ("DELETE FROM ")
.append(dbm.getTableName ())
.append(" WHERE ")
.append(dbm.getIDField())
.append(" = ")
.append(node.getID())
.toString());
st.executeUpdate ("DELETE FROM "+dbm.getTableName ()+" WHERE "+dbm.getIDField ()+" = "+node.getID ());
} finally {
if (st != null) try {
st.close ();
@ -611,11 +605,7 @@ public final class NodeManager {
Statement stmt = null;
try {
Connection con = map.getConnection ();
String q = new StringBuffer("SELECT MAX(")
.append(map.getIDField())
.append(") FROM ")
.append(map.getTableName())
.toString();
String q = "SELECT MAX("+map.getIDField()+") FROM "+map.getTableName();
stmt = con.createStatement ();
ResultSet rs = stmt.executeQuery (q);
// check for empty table
@ -649,10 +639,7 @@ public final class NodeManager {
String retval = null;
try {
Connection con = map.getConnection ();
String q = new StringBuffer("SELECT ")
.append(map.getIDgen())
.append(".nextval FROM dual")
.toString();
String q = "SELECT "+map.getIDgen()+".nextval FROM dual";
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery (q);
if (!rs.next ())
@ -690,28 +677,15 @@ public final class NodeManager {
Statement stmt = null;
try {
String q = null;
if (home.getSubnodeRelation() != null) {
// subnode relation was explicitly set
q = new StringBuffer("SELECT ")
.append(idfield)
.append(" FROM ")
.append(table)
.append(" ")
.append(home.getSubnodeRelation())
.toString();
q = "SELECT "+idfield+" FROM "+table+" "+home.getSubnodeRelation();
} else {
// let relation object build the query
q = new StringBuffer("SELECT ")
.append(idfield)
.append(" FROM ")
.append(table)
.append(rel.buildQuery (home,
home.getNonVirtualParent (), null,
" WHERE ", true))
.toString();
q = "SELECT "+idfield+" FROM "+table + rel.buildQuery (home, home.getNonVirtualParent (), null, " WHERE ", true);
}
if (logSql)
@ -721,7 +695,7 @@ public final class NodeManager {
if (rel.maxSize > 0)
stmt.setMaxRows (rel.maxSize);
ResultSet result = stmt.executeQuery (q);
// problem: how do we derive a SyntheticKey from a not-yet-persistent Node?
Key k = rel.groupby != null ? home.getKey (): null;
while (result.next ()) {
@ -732,8 +706,8 @@ public final class NodeManager {
continue;
// make the proper key for the object, either a generic DB key or a groupby key
Key key = rel.groupby == null ?
(Key) new DbKey (rel.otherType, kstr) :
(Key) new SyntheticKey (k, kstr);
(Key) new DbKey (rel.otherType, kstr) :
(Key) new SyntheticKey (k, kstr);
retval.add (new NodeHandle (key));
// if these are groupby nodes, evict nullNode keys
if (rel.groupby != null) {
@ -776,7 +750,7 @@ public final class NodeManager {
Connection con = dbm.getConnection ();
Statement stmt = con.createStatement ();
DbColumn[] columns = dbm.getColumns ();
String[] columns = dbm.getColumns ();
StringBuffer q = dbm.getSelect ();
try {
if (home.getSubnodeRelation() != null) {
@ -834,7 +808,7 @@ public final class NodeManager {
if (missing > 0) {
Connection con = dbm.getConnection ();
Statement stmt = con.createStatement ();
DbColumn[] columns = dbm.getColumns ();
String[] columns = dbm.getColumns ();
StringBuffer q = dbm.getSelect ();
try {
String idfield = rel.groupby != null ? rel.groupby : dbm.getIDField ();
@ -861,10 +835,8 @@ public final class NodeManager {
q.append (") ");
if (rel.groupby != null) {
q.append (rel.renderConstraints (home, home.getNonVirtualParent ()));
if (rel.order != null) {
q.append (" ORDER BY ");
q.append (rel.order);
}
if (rel.order != null)
q.append (" ORDER BY "+rel.order);
}
if (logSql)
@ -965,27 +937,19 @@ public final class NodeManager {
Statement stmt = null;
try {
String q = null;
if (home.getSubnodeRelation() != null) {
// use the manually set subnoderelation of the home node
q = new StringBuffer("SELECT count(*) FROM ")
.append(table)
.append(" ")
.append(home.getSubnodeRelation())
.toString();
q = "SELECT count(*) FROM "+table+" "+home.getSubnodeRelation();
} else {
// let relation object build the query
q = new StringBuffer("SELECT count(*) FROM ")
.append(table)
.append(rel.buildQuery (home, home.getNonVirtualParent(),
null, " WHERE ", false))
.toString();
q = "SELECT count(*) FROM "+table + rel.buildQuery (home, home.getNonVirtualParent (), null, " WHERE ", false);
}
if (logSql)
app.logEvent ("### countNodes: "+q);
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery (q);
@ -1026,13 +990,7 @@ public final class NodeManager {
Statement stmt = null;
try {
String q = new StringBuffer("SELECT ")
.append(namefield)
.append(" FROM ")
.append(table)
.append(" ORDER BY ")
.append(namefield)
.toString();
String q = "SELECT "+namefield+" FROM "+table+" ORDER BY "+namefield;
stmt = con.createStatement ();
if (logSql)
@ -1079,7 +1037,7 @@ public final class NodeManager {
Connection con = dbm.getConnection ();
stmt = con.createStatement ();
DbColumn[] columns = dbm.getColumns ();
String[] columns = dbm.getColumns ();
StringBuffer q = dbm.getSelect ();
q.append ("WHERE ");
q.append (idfield);
@ -1141,7 +1099,7 @@ public final class NodeManager {
DbMapping dbm = rel.otherType;
Connection con = dbm.getConnection ();
DbColumn[] columns = dbm.getColumns ();
String[] columns = dbm.getColumns ();
StringBuffer q = dbm.getSelect ();
if (home.getSubnodeRelation () != null) {
// combine our key with the constraints in the manually set subnode relation
@ -1186,7 +1144,7 @@ public final class NodeManager {
}
/**
* Get a DbMapping for a given prototype name. This is just a proxy
* Get a DbMapping for a given prototype name. This is just a proxy
* method to the app's getDbMapping() method.
*/
public DbMapping getDbMapping (String protoname) {

View file

@ -25,7 +25,7 @@ import FESI.Exceptions.*;
/**
* This is the implementation of ScriptingEnvironment for the FESI EcmaScript interpreter.
*/
public class FesiEngine implements ScriptingEngine {
public final class FesiEngine implements ScriptingEngine {
// the application we're running in
Application app;
@ -80,7 +80,8 @@ public class FesiEngine implements ScriptingEngine {
wrappercache = new CacheMap (200, .75f);
prototypes = new Hashtable ();
try {
evaluator = new Evaluator(this);
evaluator = new Evaluator();
evaluator.engine = this;
global = evaluator.getGlobalObject();
for (int i=0; i<extensions.length; i++)
evaluator.addExtension (extensions[i]);
@ -752,13 +753,6 @@ public class FesiEngine implements ScriptingEngine {
wrappercache.put (n, esn);
}
/**
* Return the application's classloader
*/
public ClassLoader getClassLoader () {
return app.getClassLoader ();
}
/**
* Return the RequestEvaluator owning and driving this FESI evaluator.
*/

View file

@ -1,17 +0,0 @@
// PhantomEngine.java
// Copyright (c) Hannes Wallnöfer 2002
package helma.scripting.fesi;
import helma.scripting.ScriptingException;
public final class PhantomEngine extends FesiEngine {
/**
*
*/
public Object invoke (Object thisObject, String functionName, Object[] args, boolean xmlrpc) throws ScriptingException {
return super.invoke (thisObject, functionName, args, xmlrpc);
}
}