Return-Path: X-Original-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BF2468468 for ; Sun, 28 Aug 2011 10:45:29 +0000 (UTC) Received: (qmail 71823 invoked by uid 500); 28 Aug 2011 10:45:27 -0000 Delivered-To: apmail-incubator-connectors-commits-archive@incubator.apache.org Received: (qmail 71760 invoked by uid 500); 28 Aug 2011 10:45:12 -0000 Mailing-List: contact connectors-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: connectors-dev@incubator.apache.org Delivered-To: mailing list connectors-commits@incubator.apache.org Received: (qmail 71739 invoked by uid 99); 28 Aug 2011 10:45:09 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Aug 2011 10:45:09 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Aug 2011 10:45:05 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7807A238889B; Sun, 28 Aug 2011 10:44:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1162494 - in /incubator/lcf/trunk: framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ site/src/documentation/content/xdocs/ Date: Sun, 28 Aug 2011 10:44:44 -0000 To: connectors-commits@incubator.apache.org From: kwright@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110828104444.7807A238889B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kwright Date: Sun Aug 28 10:44:43 2011 New Revision: 1162494 URL: http://svn.apache.org/viewvc?rev=1162494&view=rev Log: More work on scripting language documentation, and also make the + operator work consistently across types. Modified: 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/site/src/documentation/content/xdocs/script.xml 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=1162494&r1=1162493&r2=1162494&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 Sun Aug 28 10:44:43 2011 @@ -31,6 +31,11 @@ public class VariableConfiguration exten { configuration = new Configuration(); } + + public VariableConfiguration(Configuration c) + { + configuration = c; + } public VariableConfiguration(String json) throws ScriptException @@ -112,8 +117,18 @@ public class VariableConfiguration exten public VariableReference plus(Variable v) throws ScriptException { - insert(v); - return this; + if (v == null) + throw new ScriptException("Can't add a null object"); + ConfigurationNode node = v.getConfigurationNodeValue(); + Configuration c = new Configuration(); + int i = 0; + while (i < configuration.getChildCount()) + { + ConfigurationNode child = configuration.findChild(i++); + c.addChild(c.getChildCount(),child); + } + c.addChild(c.getChildCount(),node); + return new VariableConfiguration(c); } /** Delete an object from this variable at a position. */ 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=1162494&r1=1162493&r2=1162494&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 Sun Aug 28 10:44:43 2011 @@ -47,9 +47,8 @@ public class VariableConfigurationNode e sb.append(" : "); String valueField = configurationNode.getValue(); if (valueField == null) - sb.append("null"); - else - sb.append(new VariableString(valueField).toString()); + valueField = ""; + sb.append(new VariableString(valueField).toString()); sb.append(" : "); boolean needComma = false; Iterator iter = configurationNode.getAttributes(); @@ -83,7 +82,7 @@ public class VariableConfigurationNode e throws ScriptException { if (configurationNode.getValue() == null) - return super.getStringValue(); + return ""; return configurationNode.getValue(); } @@ -106,9 +105,7 @@ public class VariableConfigurationNode e return new VariableString(configurationNode.getType()); // And the __value__ attribute if (attributeName.equals(ATTRIBUTE_VALUE)) - { return new ValueReference(); - } // All others are presumed to be attributes of the configuration node, which can be set or cleared. return new AttributeReference(attributeName); } @@ -146,8 +143,26 @@ public class VariableConfigurationNode e public VariableReference plus(Variable v) throws ScriptException { - insert(v); - return this; + if (v == null) + throw new ScriptException("Can't add a null object"); + ConfigurationNode node = v.getConfigurationNodeValue(); + ConfigurationNode cn = new ConfigurationNode(configurationNode.getType()); + cn.setValue(configurationNode.getValue()); + Iterator attIter = configurationNode.getAttributes(); + while (attIter.hasNext()) + { + String attrName = attIter.next(); + String attrValue = configurationNode.getAttributeValue(attrName); + cn.setAttribute(attrName,attrValue); + } + int i = 0; + while (i < configurationNode.getChildCount()) + { + ConfigurationNode child = configurationNode.findChild(i++); + cn.addChild(cn.getChildCount(),child); + } + cn.addChild(cn.getChildCount(),node); + return new VariableConfigurationNode(cn); } /** Delete an object from this variable at a position. */ @@ -183,14 +198,13 @@ public class VariableConfigurationNode e { String value = configurationNode.getValue(); if (value == null) - throw new ScriptException("ConfigurationNode value is null"); - else - return new VariableString(value); + value = ""; + return new VariableString(value); } public boolean isNull() { - return configurationNode.getValue() == null; + return false; } } Modified: incubator/lcf/trunk/site/src/documentation/content/xdocs/script.xml URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/site/src/documentation/content/xdocs/script.xml?rev=1162494&r1=1162493&r2=1162494&view=diff ============================================================================== --- incubator/lcf/trunk/site/src/documentation/content/xdocs/script.xml (original) +++ incubator/lcf/trunk/site/src/documentation/content/xdocs/script.xml Sun Aug 28 10:44:43 2011 @@ -280,7 +280,7 @@ print "3".__int__+7;
Arrays -

Array variable types are created by an initializer of the form '[' expression ',' ... expression ']'. For example, the code '[3, 4]' will create an array +

Array variable types are created by an initializer of the form '[' expression ',' ... expression ']'. For example, the script code '[3, 4]' will create an array variable type with two values, the integer "3" and the integer "4".

The operations supported for this variable type, and their meanings, are listed in the table below:

@@ -289,10 +289,22 @@ print "3".__int__+7;
subscript []Find the specified subscript variable, yielding the variable[3,4] [0]

In addition, the standard attributes __script__ and __size__ are supported - by array types.

+ by array types, as well as the insert and remove statements.

Configurations +

Configuration variables contain the equivalent of the JSON used to communicate with the ManifoldCF API. They can be created using an initializer + of the form '{' expression ',' ... expression '}'. For example, the script code '{ < "outputconnector" : "" : : , < "description" : "Solr" : : >, < "class_name" : "org.apache.manifoldcf.agents.output.solr.SolrConnector" : : > > }' + would create a configuration variable equivalent to one that might be returned from the ManifoldCF API if it was queried for the output connectors registered by the system.

+

The operations supported for this variable type, and their meanings are listed in the table below:

+ + + + + +
Configuration operations
OperationMeaningExample
subscript []Find the specified child configuration node variable, yielding the variablemyconfig [0]
binary +Append a configuration child node variable to the listmyconfig + < "something" : "somethingvalue" : : >
+

In addition, the standard attributes __script__ and __size__ are supported + by configuration variable types, as well as the insert and remove statements.

Configuration nodes