You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2011/08/31 19:11:12 UTC
svn commit: r1163706 -
/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/
Author: kwright
Date: Wed Aug 31 17:11:11 2011
New Revision: 1163706
URL: http://svn.apache.org/viewvc?rev=1163706&view=rev
Log:
Revamp error handling to provide more information about context of errors.
Modified:
incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableArray.java
incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBase.java
incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBoolean.java
incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java
incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java
incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConnectionName.java
incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableDict.java
incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableFloat.java
incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableInt.java
incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableString.java
incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableURL.java
Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java?rev=1163706&r1=1163705&r2=1163706&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java (original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java Wed Aug 31 17:11:11 2011
@@ -75,7 +75,7 @@ public class ScriptParser
localError(currentStream,"Break command must be inside a loop");
Token t = currentStream.peek();
if (t != null)
- t.throwException("Characters after end of script");
+ localError(currentStream,"Characters after end of script");
}
// Statement return codes
@@ -681,12 +681,12 @@ public class ScriptParser
VariableReference expression = evaluateExpression(currentStream);
if (expression == null)
syntaxError(currentStream,"Missing expression after '['");
- Variable indexValue = resolveMustExist(currentStream,expression);
- vr = resolveMustExist(currentStream,vr).getIndexed(indexValue);
+ Variable v = resolveMustExist(currentStream,vr);
t = currentStream.peek();
if (t == null || t.getPunctuation() == null || !t.getPunctuation().equals("]"))
syntaxError(currentStream,"Missing ']'");
currentStream.skip();
+ vr = v.getIndexed(expression.resolve());
}
else if (t != null && t.getPunctuation() != null && t.getPunctuation().equals("."))
{
@@ -694,8 +694,9 @@ public class ScriptParser
t = currentStream.peek();
if (t == null || t.getToken() == null)
syntaxError(currentStream,"Need attribute name");
- vr = resolveMustExist(currentStream,vr).getAttribute(t.getToken());
+ Variable v = resolveMustExist(currentStream,vr);
currentStream.skip();
+ vr = v.getAttribute(t.getToken());
}
else
break;
@@ -1127,7 +1128,7 @@ public class ScriptParser
if (t == null)
throw new ScriptException(message+", at end of file");
else
- t.throwException(message+": "+t);
+ t.throwException(message + ": "+t);
}
Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableArray.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableArray.java?rev=1163706&r1=1163705&r2=1163706&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableArray.java (original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableArray.java Wed Aug 31 17:11:11 2011
@@ -98,11 +98,11 @@ public class VariableArray extends Varia
throws ScriptException
{
if (index == null)
- throw new ScriptException("Subscript cannot be null for array");
+ throw new ScriptException(composeMessage("Subscript cannot be null"));
int indexValue = index.getIntValue();
- if (indexValue < array.size())
+ if (indexValue >= 0 && indexValue < array.size())
return new ElementReference(indexValue);
- return super.getIndexed(index);
+ throw new ScriptException(composeMessage("Index out of bounds: "+indexValue));
}
/** Insert an object into this variable at a position. */
@@ -114,8 +114,8 @@ public class VariableArray extends Varia
else
{
int indexValue = index.getIntValue();
- if (indexValue > array.size())
- throw new ScriptException("Array insert out of bounds");
+ if (indexValue < 0 || indexValue > array.size())
+ throw new ScriptException(composeMessage("Insert index out of bounds: "+indexValue));
array.add(indexValue,v);
}
}
@@ -125,10 +125,10 @@ public class VariableArray extends Varia
throws ScriptException
{
if (index == null)
- throw new ScriptException("Array remove cannot be null.");
+ throw new ScriptException(composeMessage("Array remove index cannot be null"));
int indexValue = index.getIntValue();
if (indexValue < 0 || indexValue >= array.size())
- throw new ScriptException("Array remove out of bounds: "+indexValue);
+ throw new ScriptException(composeMessage("Array remove index out of bounds: "+indexValue));
array.remove(indexValue);
}
@@ -145,23 +145,23 @@ public class VariableArray extends Varia
public void setReference(Variable v)
throws ScriptException
{
- if (index >= array.size())
- throw new ScriptException("Index out of range for array children");
+ if (index < 0 || index >= array.size())
+ throw new ScriptException(composeMessage("Index out of range for array children: "+index));
array.set(index,v);
}
public Variable resolve()
throws ScriptException
{
- if (index >= array.size())
- throw new ScriptException("Index out of range for array children");
+ if (index < 0 || index >= array.size())
+ throw new ScriptException(composeMessage("Index out of range for array children: "+index));
return array.get(index);
}
/** Check if this reference is null */
public boolean isNull()
{
- return index >= array.size() || array.get(index) == null;
+ return index < 0 || index >= array.size() || array.get(index) == null;
}
}
Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBase.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBase.java?rev=1163706&r1=1163705&r2=1163706&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBase.java (original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBase.java Wed Aug 31 17:11:11 2011
@@ -30,53 +30,54 @@ public class VariableBase implements Var
{
}
- /** Get the variable's value as a string */
- public String getStringValue()
+
+ /** Get the variable's script value */
+ public String getScriptValue()
throws ScriptException
{
- throw new ScriptException("Cannot convert variable to string");
+ throw new ScriptException(composeMessage("Variable has no script value"));
}
- /** Get the variable's script value */
- public String getScriptValue()
+ /** Get the variable's value as a string */
+ public String getStringValue()
throws ScriptException
{
- throw new ScriptException("Variable has no script value");
+ throw new ScriptException(composeMessage("Cannot convert variable to string"));
}
/** Get the variable's value as a Configuration object */
public Configuration getConfigurationValue()
throws ScriptException
{
- throw new ScriptException("Cannot convert variable to Configuration object");
+ throw new ScriptException(composeMessage("Cannot convert variable to Configuration object"));
}
/** Get the variable's value as a ConfigurationNode object */
public ConfigurationNode getConfigurationNodeValue()
throws ScriptException
{
- throw new ScriptException("Cannot convert variable to ConfigurationNode object");
+ throw new ScriptException(composeMessage("Cannot convert variable to ConfigurationNode object"));
}
/** Get the variable's value as a boolean */
public boolean getBooleanValue()
throws ScriptException
{
- throw new ScriptException("Cannot convert variable to boolean");
+ throw new ScriptException(composeMessage("Cannot convert variable to boolean"));
}
/** Get the variable's value as an integer */
public int getIntValue()
throws ScriptException
{
- throw new ScriptException("Cannot convert variable to int");
+ throw new ScriptException(composeMessage("Cannot convert variable to int"));
}
/** Get the variable's value as a double */
public double getDoubleValue()
throws ScriptException
{
- throw new ScriptException("Cannot convert variable to float");
+ throw new ScriptException(composeMessage("Cannot convert variable to float"));
}
// Operations
@@ -84,97 +85,97 @@ public class VariableBase implements Var
public VariableReference plus(Variable v)
throws ScriptException
{
- throw new ScriptException("+ operator illegal for this type");
+ throw new ScriptException(composeMessage("Binary '+' operator illegal for this type"));
}
public VariableReference minus(Variable v)
throws ScriptException
{
- throw new ScriptException("- operator illegal for this type");
+ throw new ScriptException(composeMessage("Binary '-' operator illegal for this type"));
}
public VariableReference asterisk(Variable v)
throws ScriptException
{
- throw new ScriptException("* operator illegal for this type");
+ throw new ScriptException(composeMessage("Binary '*' operator illegal for this type"));
}
public VariableReference slash(Variable v)
throws ScriptException
{
- throw new ScriptException("/ operator illegal for this type");
+ throw new ScriptException(composeMessage("Binary '/' operator illegal for this type"));
}
public VariableReference unaryMinus()
throws ScriptException
{
- throw new ScriptException("Unary - operator illegal for this type");
+ throw new ScriptException(composeMessage("Unary '-' operator illegal for this type"));
}
public VariableReference greaterAngle(Variable v)
throws ScriptException
{
- throw new ScriptException("> operator illegal for this type");
+ throw new ScriptException(composeMessage("Binary '>' operator illegal for this type"));
}
public VariableReference lesserAngle(Variable v)
throws ScriptException
{
- throw new ScriptException("< operator illegal for this type");
+ throw new ScriptException(composeMessage("Binary '<' operator illegal for this type"));
}
public VariableReference doubleEquals(Variable v)
throws ScriptException
{
- throw new ScriptException("= operator illegal for this type");
+ throw new ScriptException(composeMessage("Binary '==' operator illegal for this type"));
}
public VariableReference greaterAngleEquals(Variable v)
throws ScriptException
{
- throw new ScriptException(">= operator illegal for this type");
+ throw new ScriptException(composeMessage("Binary '>=' operator illegal for this type"));
}
public VariableReference lesserAngleEquals(Variable v)
throws ScriptException
{
- throw new ScriptException("<= operator illegal for this type");
+ throw new ScriptException(composeMessage("Binary '<=' operator illegal for this type"));
}
public VariableReference exclamationEquals(Variable v)
throws ScriptException
{
- throw new ScriptException("!= operator illegal for this type");
+ throw new ScriptException(composeMessage("Binary '!=' operator illegal for this type"));
}
public VariableReference ampersand(Variable v)
throws ScriptException
{
- throw new ScriptException("& operator illegal for this type");
+ throw new ScriptException(composeMessage("Binary '&' operator illegal for this type"));
}
public VariableReference pipe(Variable v)
throws ScriptException
{
- throw new ScriptException("| operator illegal for this type");
+ throw new ScriptException(composeMessage("Binary '|' operator illegal for this type"));
}
public VariableReference doubleAmpersand(Variable v)
throws ScriptException
{
- throw new ScriptException("&& operator illegal for this type");
+ throw new ScriptException(composeMessage("Binary '&&' operator illegal for this type"));
}
public VariableReference doublePipe(Variable v)
throws ScriptException
{
- throw new ScriptException("|| operator illegal for this type");
+ throw new ScriptException(composeMessage("Binary '||' operator illegal for this type"));
}
public VariableReference unaryExclamation()
throws ScriptException
{
- throw new ScriptException("! operator illegal for this type");
+ throw new ScriptException(composeMessage("Unary '!' operator illegal for this type"));
}
// The following operations allow manipulation of a Configuration structure
@@ -194,21 +195,21 @@ public class VariableBase implements Var
else if (attributeName.equals(ATTRIBUTE_SCRIPT))
return new VariableString(getScriptValue());
else
- throw new ScriptException("Variable has no attribute called '"+attributeName+"'");
+ throw new ScriptException(composeMessage("Variable has no attribute called '"+attributeName+"'"));
}
/** Insert an object into this variable at a position. */
public void insertAt(Variable v, Variable index)
throws ScriptException
{
- throw new ScriptException("Can't insert into variable");
+ throw new ScriptException(composeMessage("Variable does not support 'insert' operation"));
}
/** Delete an object from this variable at a position. */
public void removeAt(Variable index)
throws ScriptException
{
- throw new ScriptException("Can't remove from variable");
+ throw new ScriptException(composeMessage("Variable does not support 'remove' operation"));
}
@@ -218,7 +219,7 @@ public class VariableBase implements Var
public VariableReference getIndexed(Variable index)
throws ScriptException
{
- throw new ScriptException("Variable does not support subscripts");
+ throw new ScriptException(composeMessage("Variable does not support subscripts"));
}
// As a variable reference, refer to self
@@ -227,7 +228,7 @@ public class VariableBase implements Var
public void setReference(Variable object)
throws ScriptException
{
- throw new ScriptException("Cannot set reference of this kind");
+ throw new ScriptException(composeMessage("Cannot set reference"));
}
/** Resolve the reference */
@@ -243,4 +244,11 @@ public class VariableBase implements Var
return false;
}
+ // Protected methods
+
+ /** Compose a message which includes the current class name, so we can see what type of variable it is. */
+ protected String composeMessage(String input)
+ {
+ return "Variable of type '"+getClass().getName()+"': "+input;
+ }
}
Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBoolean.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBoolean.java?rev=1163706&r1=1163705&r2=1163706&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBoolean.java (original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBoolean.java Wed Aug 31 17:11:11 2011
@@ -62,7 +62,7 @@ public class VariableBoolean extends Var
throws ScriptException
{
if (v == null)
- throw new ScriptException("== operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '==' operand cannot be null"));
return new VariableBoolean(value == v.getBooleanValue());
}
@@ -70,7 +70,7 @@ public class VariableBoolean extends Var
throws ScriptException
{
if (v == null)
- throw new ScriptException("!= operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '!=' operand cannot be null"));
return new VariableBoolean(value != v.getBooleanValue());
}
@@ -78,7 +78,7 @@ public class VariableBoolean extends Var
throws ScriptException
{
if (v == null)
- throw new ScriptException("&& operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '&&' operand cannot be null"));
return new VariableBoolean(value && v.getBooleanValue());
}
@@ -86,7 +86,7 @@ public class VariableBoolean extends Var
throws ScriptException
{
if (v == null)
- throw new ScriptException("|| operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '||' operand cannot be null"));
return new VariableBoolean(value || v.getBooleanValue());
}
@@ -94,7 +94,7 @@ public class VariableBoolean extends Var
throws ScriptException
{
if (v == null)
- throw new ScriptException("& operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '&' operand cannot be null"));
return new VariableBoolean(value && v.getBooleanValue());
}
@@ -102,7 +102,7 @@ public class VariableBoolean extends Var
throws ScriptException
{
if (v == null)
- throw new ScriptException("| operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '|' operand cannot be null"));
return new VariableBoolean(value || v.getBooleanValue());
}
Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java?rev=1163706&r1=1163705&r2=1163706&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java (original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java Wed Aug 31 17:11:11 2011
@@ -103,11 +103,11 @@ public class VariableConfiguration exten
throws ScriptException
{
if (index == null)
- throw new ScriptException("Subscript cannot be null for configuration");
+ throw new ScriptException(composeMessage("Subscript cannot be null"));
int indexValue = index.getIntValue();
- if (indexValue < configuration.getChildCount())
+ if (indexValue >= 0 && indexValue < configuration.getChildCount())
return new NodeReference(indexValue);
- throw new ScriptException("Subscript "+indexValue+" is out of bounds");
+ throw new ScriptException(composeMessage("Subscript is out of bounds: "+indexValue));
}
/** Insert an object into this variable at a position. */
@@ -115,14 +115,14 @@ public class VariableConfiguration exten
throws ScriptException
{
if (v == null)
- throw new ScriptException("Can't insert a null object into a configuration");
+ throw new ScriptException(composeMessage("Can't insert a null object into a configuration"));
if (index == null)
configuration.addChild(configuration.getChildCount(),v.getConfigurationNodeValue());
else
{
int indexValue = index.getIntValue();
if (indexValue < 0 || indexValue > configuration.getChildCount())
- throw new ScriptException("Configuration insert out of bounds");
+ throw new ScriptException(composeMessage("Configuration insert out of bounds: "+indexValue));
configuration.addChild(indexValue,v.getConfigurationNodeValue());
}
}
@@ -132,10 +132,10 @@ public class VariableConfiguration exten
throws ScriptException
{
if (index == null)
- throw new ScriptException("Configuration remove index cannot be null");
+ throw new ScriptException(composeMessage("Configuration remove index cannot be null"));
int indexValue = index.getIntValue();
if (indexValue < 0 || indexValue >= configuration.getChildCount())
- throw new ScriptException("Configuration remove out of bounds");
+ throw new ScriptException(composeMessage("Configuration remove index out of bounds"));
configuration.removeChild(indexValue);
}
@@ -143,7 +143,7 @@ public class VariableConfiguration exten
throws ScriptException
{
if (v == null)
- throw new ScriptException("Can't add a null object");
+ throw new ScriptException(composeMessage("Binary '+' can't add a null object"));
ConfigurationNode node = v.getConfigurationNodeValue();
Configuration c = new Configuration();
int i = 0;
@@ -170,8 +170,8 @@ public class VariableConfiguration exten
public void setReference(Variable v)
throws ScriptException
{
- if (index >= configuration.getChildCount())
- throw new ScriptException("Index out of range for Configuration children");
+ if (index < 0 || index >= configuration.getChildCount())
+ throw new ScriptException(composeMessage("Index out of range for Configuration children: "+index));
ConfigurationNode confNode = v.getConfigurationNodeValue();
configuration.removeChild(index);
configuration.addChild(index,confNode);
@@ -180,15 +180,15 @@ public class VariableConfiguration exten
public Variable resolve()
throws ScriptException
{
- if (index >= configuration.getChildCount())
- throw new ScriptException("Index out of range for Configuration children");
+ if (index < 0 || index >= configuration.getChildCount())
+ throw new ScriptException(composeMessage("Index out of range for Configuration children: "+index));
return new VariableConfigurationNode(configuration.findChild(index));
}
/** Check if this reference is null */
public boolean isNull()
{
- return index >= configuration.getChildCount();
+ return index < 0 || index >= configuration.getChildCount();
}
}
Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java?rev=1163706&r1=1163705&r2=1163706&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java (original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java Wed Aug 31 17:11:11 2011
@@ -135,11 +135,11 @@ public class VariableConfigurationNode e
throws ScriptException
{
if (index == null)
- throw new ScriptException("Subscript cannot be null for configurationnode");
+ throw new ScriptException(composeMessage("Subscript cannot be null"));
int indexValue = index.getIntValue();
if (indexValue >= 0 && indexValue < configurationNode.getChildCount())
return new NodeReference(indexValue);
- throw new ScriptException("Subscript "+indexValue+" is out of bounds");
+ throw new ScriptException(composeMessage("Subscript is out of bounds: "+indexValue));
}
/** Insert an object into this variable at a position. */
@@ -147,14 +147,14 @@ public class VariableConfigurationNode e
throws ScriptException
{
if (v == null)
- throw new ScriptException("Can't insert a null object into a configurationnode");
+ throw new ScriptException(composeMessage("Can't insert a null object"));
if (index == null)
configurationNode.addChild(configurationNode.getChildCount(),v.getConfigurationNodeValue());
else
{
int indexValue = index.getIntValue();
if (indexValue < 0 || indexValue > configurationNode.getChildCount())
- throw new ScriptException("Configurationnode insert out of bounds");
+ throw new ScriptException(composeMessage("Insert out of bounds: "+indexValue));
configurationNode.addChild(indexValue,v.getConfigurationNodeValue());
}
}
@@ -164,10 +164,10 @@ public class VariableConfigurationNode e
throws ScriptException
{
if (index == null)
- throw new ScriptException("Configurationnode remove index cannot be null");
+ throw new ScriptException(composeMessage("Remove index cannot be null"));
int indexValue = index.getIntValue();
if (indexValue < 0 || indexValue >= configurationNode.getChildCount())
- throw new ScriptException("Configurationnode remove out of bounds");
+ throw new ScriptException(composeMessage("Remove index out of bounds: "+indexValue));
configurationNode.removeChild(indexValue);
}
@@ -176,7 +176,7 @@ public class VariableConfigurationNode e
throws ScriptException
{
if (v == null)
- throw new ScriptException("Can't add a null object");
+ throw new ScriptException(composeMessage("Can't add a null object"));
ConfigurationNode node = v.getConfigurationNodeValue();
ConfigurationNode cn = new ConfigurationNode(configurationNode.getType());
cn.setValue(configurationNode.getValue());
@@ -258,7 +258,7 @@ public class VariableConfigurationNode e
{
String attrValue = configurationNode.getAttributeValue(attributeName);
if (attrValue == null)
- throw new ScriptException("ConfigurationNode has no attribute named '"+attributeName+"'");
+ throw new ScriptException(composeMessage("No attribute named '"+attributeName+"'"));
return new VariableString(attrValue);
}
@@ -281,8 +281,8 @@ public class VariableConfigurationNode e
public void setReference(Variable v)
throws ScriptException
{
- if (index >= configurationNode.getChildCount())
- throw new ScriptException("Index out of range for ConfigurationNode children");
+ if (index < 0 || index >= configurationNode.getChildCount())
+ throw new ScriptException(composeMessage("Index out of range: "+index));
ConfigurationNode confNode = v.getConfigurationNodeValue();
configurationNode.removeChild(index);
configurationNode.addChild(index,confNode);
@@ -291,15 +291,15 @@ public class VariableConfigurationNode e
public Variable resolve()
throws ScriptException
{
- if (index >= configurationNode.getChildCount())
- throw new ScriptException("Index out of range for ConfigurationNode children");
+ if (index < 0 || index >= configurationNode.getChildCount())
+ throw new ScriptException(composeMessage("Index out of range: "+index));
return new VariableConfigurationNode(configurationNode.findChild(index));
}
/** Check if this reference is null */
public boolean isNull()
{
- return index >= configurationNode.getChildCount();
+ return index < 0 || index >= configurationNode.getChildCount();
}
}
Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConnectionName.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConnectionName.java?rev=1163706&r1=1163705&r2=1163706&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConnectionName.java (original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConnectionName.java Wed Aug 31 17:11:11 2011
@@ -76,7 +76,7 @@ public class VariableConnectionName exte
throws ScriptException
{
if (v == null)
- throw new ScriptException("== operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '==' operand cannot be null"));
return new VariableBoolean(encodedConnectionName.equals(v.getStringValue()));
}
@@ -84,7 +84,7 @@ public class VariableConnectionName exte
throws ScriptException
{
if (v == null)
- throw new ScriptException("!= operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '!=' operand cannot be null"));
return new VariableBoolean(!encodedConnectionName.equals(v.getStringValue()));
}
Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableDict.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableDict.java?rev=1163706&r1=1163705&r2=1163706&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableDict.java (original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableDict.java Wed Aug 31 17:11:11 2011
@@ -47,7 +47,7 @@ public class VariableDict extends Variab
throws ScriptException
{
if (index == null)
- throw new ScriptException("Dictionary subscript cannot be null");
+ throw new ScriptException(composeMessage("Subscript cannot be null"));
VariableReference rval = dict.get(index);
if (rval == null)
{
Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableFloat.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableFloat.java?rev=1163706&r1=1163705&r2=1163706&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableFloat.java (original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableFloat.java Wed Aug 31 17:11:11 2011
@@ -74,7 +74,7 @@ public class VariableFloat extends Varia
throws ScriptException
{
if (v == null)
- throw new ScriptException("+ operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '+' operand cannot be null"));
return new VariableFloat(value + v.getDoubleValue());
}
@@ -82,7 +82,7 @@ public class VariableFloat extends Varia
throws ScriptException
{
if (v == null)
- throw new ScriptException("- operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '-' operand cannot be null"));
return new VariableFloat(value - v.getDoubleValue());
}
@@ -90,7 +90,7 @@ public class VariableFloat extends Varia
throws ScriptException
{
if (v == null)
- throw new ScriptException("* operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '*' operand cannot be null"));
return new VariableFloat(value * v.getDoubleValue());
}
@@ -98,7 +98,7 @@ public class VariableFloat extends Varia
throws ScriptException
{
if (v == null)
- throw new ScriptException("/ operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '/' operand cannot be null"));
return new VariableFloat(value / v.getDoubleValue());
}
@@ -112,7 +112,7 @@ public class VariableFloat extends Varia
throws ScriptException
{
if (v == null)
- throw new ScriptException("> operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '>' operand cannot be null"));
return new VariableBoolean(value > v.getDoubleValue());
}
@@ -120,7 +120,7 @@ public class VariableFloat extends Varia
throws ScriptException
{
if (v == null)
- throw new ScriptException("< operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '<' operand cannot be null"));
return new VariableBoolean(value < v.getDoubleValue());
}
@@ -128,7 +128,7 @@ public class VariableFloat extends Varia
throws ScriptException
{
if (v == null)
- throw new ScriptException("== operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '==' operand cannot be null"));
return new VariableBoolean(value == v.getDoubleValue());
}
@@ -136,7 +136,7 @@ public class VariableFloat extends Varia
throws ScriptException
{
if (v == null)
- throw new ScriptException(">= operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '>=' operand cannot be null"));
return new VariableBoolean(value >= v.getDoubleValue());
}
@@ -144,7 +144,7 @@ public class VariableFloat extends Varia
throws ScriptException
{
if (v == null)
- throw new ScriptException("<= operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '<=' operand cannot be null"));
return new VariableBoolean(value <= v.getDoubleValue());
}
@@ -152,7 +152,7 @@ public class VariableFloat extends Varia
throws ScriptException
{
if (v == null)
- throw new ScriptException("!= operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '!=' operand cannot be null"));
return new VariableBoolean(value != v.getDoubleValue());
}
Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableInt.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableInt.java?rev=1163706&r1=1163705&r2=1163706&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableInt.java (original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableInt.java Wed Aug 31 17:11:11 2011
@@ -74,7 +74,7 @@ public class VariableInt extends Variabl
throws ScriptException
{
if (v == null)
- throw new ScriptException("+ operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '+' operand cannot be null"));
return new VariableInt(value + v.getIntValue());
}
@@ -82,7 +82,7 @@ public class VariableInt extends Variabl
throws ScriptException
{
if (v == null)
- throw new ScriptException("- operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '-' operand cannot be null"));
return new VariableInt(value - v.getIntValue());
}
@@ -91,7 +91,7 @@ public class VariableInt extends Variabl
throws ScriptException
{
if (v == null)
- throw new ScriptException("* operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '*' operand cannot be null"));
return new VariableInt(value * v.getIntValue());
}
@@ -99,7 +99,7 @@ public class VariableInt extends Variabl
throws ScriptException
{
if (v == null)
- throw new ScriptException("/ operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '/' operand cannot be null"));
return new VariableInt(value / v.getIntValue());
}
@@ -113,7 +113,7 @@ public class VariableInt extends Variabl
throws ScriptException
{
if (v == null)
- throw new ScriptException("> operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '>' operand cannot be null"));
return new VariableBoolean(value > v.getIntValue());
}
@@ -121,7 +121,7 @@ public class VariableInt extends Variabl
throws ScriptException
{
if (v == null)
- throw new ScriptException("< operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '<' operand cannot be null"));
return new VariableBoolean(value < v.getIntValue());
}
@@ -129,7 +129,7 @@ public class VariableInt extends Variabl
throws ScriptException
{
if (v == null)
- throw new ScriptException("== operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '==' operand cannot be null"));
return new VariableBoolean(value == v.getIntValue());
}
@@ -137,7 +137,7 @@ public class VariableInt extends Variabl
throws ScriptException
{
if (v == null)
- throw new ScriptException(">= operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '>=' operand cannot be null"));
return new VariableBoolean(value >= v.getIntValue());
}
@@ -145,7 +145,7 @@ public class VariableInt extends Variabl
throws ScriptException
{
if (v == null)
- throw new ScriptException("<= operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '<=' operand cannot be null"));
return new VariableBoolean(value <= v.getIntValue());
}
@@ -153,7 +153,7 @@ public class VariableInt extends Variabl
throws ScriptException
{
if (v == null)
- throw new ScriptException("!= operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '!=' operand cannot be null"));
return new VariableBoolean(value != v.getIntValue());
}
@@ -161,7 +161,7 @@ public class VariableInt extends Variabl
throws ScriptException
{
if (v == null)
- throw new ScriptException("& operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '&' operand cannot be null"));
return new VariableInt(value & v.getIntValue());
}
@@ -169,7 +169,7 @@ public class VariableInt extends Variabl
throws ScriptException
{
if (v == null)
- throw new ScriptException("| operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '|' operand cannot be null"));
return new VariableInt(value | v.getIntValue());
}
Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableString.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableString.java?rev=1163706&r1=1163705&r2=1163706&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableString.java (original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableString.java Wed Aug 31 17:11:11 2011
@@ -92,7 +92,7 @@ public class VariableString extends Vari
throws ScriptException
{
if (v == null)
- throw new ScriptException("+ operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '+' operand cannot be null"));
return new VariableString(value + v.getStringValue());
}
@@ -100,7 +100,7 @@ public class VariableString extends Vari
throws ScriptException
{
if (v == null)
- throw new ScriptException("== operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '==' operand cannot be null"));
return new VariableBoolean(value.equals(v.getStringValue()));
}
@@ -108,7 +108,7 @@ public class VariableString extends Vari
throws ScriptException
{
if (v == null)
- throw new ScriptException("!= operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '!=' operand cannot be null"));
return new VariableBoolean(!value.equals(v.getStringValue()));
}
Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableURL.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableURL.java?rev=1163706&r1=1163705&r2=1163706&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableURL.java (original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableURL.java Wed Aug 31 17:11:11 2011
@@ -77,14 +77,14 @@ public class VariableURL extends Variabl
throws ScriptException
{
if (v == null)
- throw new ScriptException("+ operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '+' operand cannot be null"));
try
{
return new VariableURL(encodedURL + "/" + URLEncoder.encode(v.getStringValue(),"utf-8").replace("+","%20"));
}
catch (UnsupportedEncodingException e)
{
- throw new ScriptException(e.getMessage(),e);
+ throw new ScriptException(composeMessage(e.getMessage()),e);
}
}
@@ -92,7 +92,7 @@ public class VariableURL extends Variabl
throws ScriptException
{
if (v == null)
- throw new ScriptException("== operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '==' operand cannot be null"));
return new VariableBoolean(encodedURL.equals(v.getStringValue()));
}
@@ -100,7 +100,7 @@ public class VariableURL extends Variabl
throws ScriptException
{
if (v == null)
- throw new ScriptException("!= operand cannot be null");
+ throw new ScriptException(composeMessage("Binary '!=' operand cannot be null"));
return new VariableBoolean(!encodedURL.equals(v.getStringValue()));
}