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 2013/02/25 14:56:04 UTC
svn commit: r1449708 -
/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/
Author: kwright
Date: Mon Feb 25 13:56:04 2013
New Revision: 1449708
URL: http://svn.apache.org/r1449708
Log:
Add richer support for detecting variable capabilities. This is part of CONNECTORS-651.
Modified:
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/Variable.java
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableArray.java
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBase.java
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBoolean.java
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConnectionName.java
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableFloat.java
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableInt.java
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableResult.java
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableString.java
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableURL.java
Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/Variable.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/Variable.java?rev=1449708&r1=1449707&r2=1449708&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/Variable.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/Variable.java Mon Feb 25 13:56:04 2013
@@ -53,34 +53,78 @@ public interface Variable
/** CREATED status attribute */
public static String ATTRIBUTE_CREATEDSTATUS = "__CREATED__";
+ /** Check if the variable has a string value */
+ public boolean hasStringValue()
+ throws ScriptException;
+
/** Get the variable's value as a string */
public String getStringValue()
throws ScriptException;
+ /** Check if the variable has a script value */
+ public boolean hasScriptValue()
+ throws ScriptException;
+
/** Get the variable's script value */
public String getScriptValue()
throws ScriptException;
+ /** Check if the variable has a Configuration value */
+ public boolean hasConfigurationValue()
+ throws ScriptException;
+
/** Get the variable's value as a Configuration object */
public Configuration getConfigurationValue()
throws ScriptException;
-
+
+ /** Check if the variable has a ConfigurationNode value */
+ public boolean hasConfigurationNodeValue()
+ throws ScriptException;
+
/** Get the variable's value as a ConfigurationNode object */
public ConfigurationNode getConfigurationNodeValue()
throws ScriptException;
-
+
+ /** Check if the variable has a boolean value */
+ public boolean hasBooleanValue()
+ throws ScriptException;
+
/** Get the variable's value as a boolean */
public boolean getBooleanValue()
throws ScriptException;
+ /** Check if the variable has an int value */
+ public boolean hasIntValue()
+ throws ScriptException;
+
/** Get the variable's value as an integer */
public int getIntValue()
throws ScriptException;
+ /** Check if the variable has a double value */
+ public boolean hasDoubleValue()
+ throws ScriptException;
+
/** Get the variable's value as a double */
public double getDoubleValue()
throws ScriptException;
+
+ /** Check if the variable has a query argument value */
+ public boolean hasQueryArgumentValue()
+ throws ScriptException;
+
+ /** Get the variable's value as a properly-encoded query argument */
+ public String getQueryArgumentValue()
+ throws ScriptException;
+ /** Check if the variable has a URL path value */
+ public boolean hasURLPathValue()
+ throws ScriptException;
+
+ /** Get the variable's value as a URL path component */
+ public String getURLPathValue()
+ throws ScriptException;
+
// Arithmetic and comparison operators
public VariableReference plus(Variable v)
@@ -150,5 +194,5 @@ public interface Variable
/** Get an indexed property of the variable */
public VariableReference getIndexed(Variable index)
throws ScriptException;
-
+
}
Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableArray.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableArray.java?rev=1449708&r1=1449707&r2=1449708&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableArray.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableArray.java Mon Feb 25 13:56:04 2013
@@ -65,6 +65,14 @@ public class VariableArray extends Varia
return true;
}
+ /** Check if the variable has a script value */
+ @Override
+ public boolean hasScriptValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
/** Get the variable's script value */
@Override
public String getScriptValue()
Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBase.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBase.java?rev=1449708&r1=1449707&r2=1449708&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBase.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBase.java Mon Feb 25 13:56:04 2013
@@ -30,6 +30,78 @@ public class VariableBase implements Var
{
}
+ /** Check if the variable has a string value */
+ @Override
+ public boolean hasStringValue()
+ throws ScriptException
+ {
+ return false;
+ }
+
+ /** Check if the variable has a script value */
+ @Override
+ public boolean hasScriptValue()
+ throws ScriptException
+ {
+ return false;
+ }
+
+ /** Check if the variable has a Configuration value */
+ @Override
+ public boolean hasConfigurationValue()
+ throws ScriptException
+ {
+ return false;
+ }
+
+ /** Check if the variable has a ConfigurationNode value */
+ @Override
+ public boolean hasConfigurationNodeValue()
+ throws ScriptException
+ {
+ return false;
+ }
+
+ /** Check if the variable has a boolean value */
+ @Override
+ public boolean hasBooleanValue()
+ throws ScriptException
+ {
+ return false;
+ }
+
+ /** Check if the variable has an int value */
+ @Override
+ public boolean hasIntValue()
+ throws ScriptException
+ {
+ return false;
+ }
+
+ /** Check if the variable has a double value */
+ @Override
+ public boolean hasDoubleValue()
+ throws ScriptException
+ {
+ return false;
+ }
+
+ /** Check if the variable has a query argument value */
+ @Override
+ public boolean hasQueryArgumentValue()
+ throws ScriptException
+ {
+ return false;
+ }
+
+ /** Check if the variable has a URL path value */
+ @Override
+ public boolean hasURLPathValue()
+ throws ScriptException
+ {
+ return false;
+ }
+
/** Get the variable's script value */
@Override
@@ -87,6 +159,22 @@ public class VariableBase implements Var
throw new ScriptException(composeMessage("Cannot convert variable to float"));
}
+ /** Get the variable's value as a properly-encoded query argument */
+ @Override
+ public String getQueryArgumentValue()
+ throws ScriptException
+ {
+ throw new ScriptException(composeMessage("Cannot convert variable to query argument"));
+ }
+
+ /** Get the variable's value as a URL path component */
+ @Override
+ public String getURLPathValue()
+ throws ScriptException
+ {
+ throw new ScriptException(composeMessage("Cannot convert variable to URL path component"));
+ }
+
// Operations
@Override
Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBoolean.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBoolean.java?rev=1449708&r1=1449707&r2=1449708&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBoolean.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBoolean.java Mon Feb 25 13:56:04 2013
@@ -44,6 +44,14 @@ public class VariableBoolean extends Var
return ((VariableBoolean)o).value == value;
}
+ /** Check if the variable has a script value */
+ @Override
+ public boolean hasScriptValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
/** Get the variable's script value */
@Override
public String getScriptValue()
@@ -54,6 +62,14 @@ public class VariableBoolean extends Var
return "false";
}
+ /** Check if the variable has a boolean value */
+ @Override
+ public boolean hasBooleanValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
/** Get the variable's value as a boolean */
@Override
public boolean getBooleanValue()
Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java?rev=1449708&r1=1449707&r2=1449708&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java Mon Feb 25 13:56:04 2013
@@ -51,6 +51,14 @@ public class VariableConfiguration exten
}
}
+ /** Check if the variable has a script value */
+ @Override
+ public boolean hasScriptValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
/** Get the variable's script value */
@Override
public String getScriptValue()
@@ -70,6 +78,14 @@ public class VariableConfiguration exten
return sb.toString();
}
+ /** Check if the variable has a Configuration value */
+ @Override
+ public boolean hasConfigurationValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
/** Get the variable's value as a Configuration object */
@Override
public Configuration getConfigurationValue()
Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java?rev=1449708&r1=1449707&r2=1449708&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java Mon Feb 25 13:56:04 2013
@@ -38,6 +38,14 @@ public class VariableConfigurationNode e
configurationNode = node;
}
+ /** Check if the variable has a script value */
+ @Override
+ public boolean hasScriptValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
/** Get the variable's script value */
@Override
public String getScriptValue()
@@ -89,6 +97,14 @@ public class VariableConfigurationNode e
return sb.toString();
}
+ /** Check if the variable has a string value */
+ @Override
+ public boolean hasStringValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
/** Convert to a value */
@Override
public String getStringValue()
Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConnectionName.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConnectionName.java?rev=1449708&r1=1449707&r2=1449708&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConnectionName.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConnectionName.java Mon Feb 25 13:56:04 2013
@@ -49,6 +49,14 @@ public class VariableConnectionName exte
return ((VariableConnectionName)o).connectionName.equals(connectionName);
}
+ /** Check if the variable has a script value */
+ @Override
+ public boolean hasScriptValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
/** Get the variable's script value */
@Override
public String getScriptValue()
@@ -68,6 +76,14 @@ public class VariableConnectionName exte
return sb.toString();
}
+ /** Check if the variable has a string value */
+ @Override
+ public boolean hasStringValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
/** Get the variable's value as a string */
@Override
public String getStringValue()
Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableFloat.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableFloat.java?rev=1449708&r1=1449707&r2=1449708&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableFloat.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableFloat.java Mon Feb 25 13:56:04 2013
@@ -44,6 +44,38 @@ public class VariableFloat extends Varia
return ((VariableFloat)o).value == value;
}
+ /** Check if the variable has a string value */
+ @Override
+ public boolean hasStringValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
+ /** Check if the variable has a script value */
+ @Override
+ public boolean hasScriptValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
+ /** Check if the variable has an int value */
+ @Override
+ public boolean hasIntValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
+ /** Check if the variable has a double value */
+ @Override
+ public boolean hasDoubleValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
/** Get the variable's script value */
@Override
public String getScriptValue()
Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableInt.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableInt.java?rev=1449708&r1=1449707&r2=1449708&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableInt.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableInt.java Mon Feb 25 13:56:04 2013
@@ -44,6 +44,38 @@ public class VariableInt extends Variabl
return ((VariableInt)o).value == value;
}
+ /** Check if the variable has a string value */
+ @Override
+ public boolean hasStringValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
+ /** Check if the variable has a script value */
+ @Override
+ public boolean hasScriptValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
+ /** Check if the variable has an int value */
+ @Override
+ public boolean hasIntValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
+ /** Check if the variable has a double value */
+ @Override
+ public boolean hasDoubleValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
/** Get the variable's script value */
@Override
public String getScriptValue()
Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableResult.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableResult.java?rev=1449708&r1=1449707&r2=1449708&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableResult.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableResult.java Mon Feb 25 13:56:04 2013
@@ -34,6 +34,22 @@ public class VariableResult extends Vari
this.result = new VariableConfiguration(json);
}
+ /** Check if the variable has a script value */
+ @Override
+ public boolean hasScriptValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
+ /** Check if the variable has an int value */
+ @Override
+ public boolean hasIntValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
/** Get the variable's script value */
@Override
public String getScriptValue()
Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableString.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableString.java?rev=1449708&r1=1449707&r2=1449708&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableString.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableString.java Mon Feb 25 13:56:04 2013
@@ -44,6 +44,38 @@ public class VariableString extends Vari
return ((VariableString)o).value.equals(value);
}
+ /** Check if the variable has a string value */
+ @Override
+ public boolean hasStringValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
+ /** Check if the variable has a script value */
+ @Override
+ public boolean hasScriptValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
+ /** Check if the variable has an int value */
+ @Override
+ public boolean hasIntValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
+ /** Check if the variable has a double value */
+ @Override
+ public boolean hasDoubleValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
/** Get the variable's script value */
@Override
public String getScriptValue()
Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableURL.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableURL.java?rev=1449708&r1=1449707&r2=1449708&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableURL.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableURL.java Mon Feb 25 13:56:04 2013
@@ -50,6 +50,22 @@ public class VariableURL extends Variabl
return ((VariableURL)o).encodedURL.equals(encodedURL);
}
+ /** Check if the variable has a string value */
+ @Override
+ public boolean hasStringValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
+ /** Check if the variable has a script value */
+ @Override
+ public boolean hasScriptValue()
+ throws ScriptException
+ {
+ return true;
+ }
+
/** Get the variable's script value */
@Override
public String getScriptValue()