[
https://issues.apache.org/jira/browse/JENA-1461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16316089#comment-16316089
]
ASF GitHub Bot commented on JENA-1461:
--------------------------------------
Github user kinow commented on a diff in the pull request:
https://github.com/apache/jena/pull/340#discussion_r160113269
--- Diff:
jena-arq/src/main/java/org/apache/jena/sparql/function/js/EnvJavaScript.java ---
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.sparql.function.js;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Reader;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.NoSuchFileException;
+import java.nio.file.Paths;
+
+import javax.script.*;
+
+import org.apache.jena.atlas.io.IO;
+import org.apache.jena.query.ARQ;
+import org.apache.jena.riot.RiotNotFoundException;
+import org.apache.jena.sparql.ARQConstants;
+import org.apache.jena.sparql.ARQException;
+import org.apache.jena.sparql.SystemARQ;
+import org.apache.jena.sparql.sse.builders.ExprBuildException;
+import org.apache.jena.sparql.util.Context;
+import org.apache.jena.sparql.util.Symbol;
+
+/** Environment for executing a JavaScript function.
+ * <p>
+ * Functions are loaded from the file named in context setting
+ * {@link EnvJavaScript#symJavaScriptLibFile}.
+ * <p>
+ * Function are loaded from a string value in context setting
+ * {@link EnvJavaScript#symJavaScriptLib}.
+ * <p>
+ * If both are present, the file named by {@code
EnvJavaScript.symJavaScriptLibFile} is loaded
+ * then the string from {@code EnvJavaScript.symJavaScriptLib}.
+ */
--- End diff --
Worth mentioning the file is read with UTF-8 encoding, and not system
default?
> Allow ARQ custom functions to be written in JavaScript
> ------------------------------------------------------
>
> Key: JENA-1461
> URL: https://issues.apache.org/jira/browse/JENA-1461
> Project: Apache Jena
> Issue Type: Improvement
> Components: ARQ
> Affects Versions: Jena 3.6.0
> Reporter: Andy Seaborne
> Assignee: Andy Seaborne
>
> Provide execution of JavaScript for SPARQL extension functions.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)