[java-support] 03/11: JSPT-95 Use non deprecated Constructor to EvaluableScript
Rod Widdowson
rdw at steadingsoftware.com
Mon May 4 14:38:21 UTC 2020
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch dev/JSPT-95
in repository java-support.
View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=fa070e222f45f0d6c0dc54adb5d96ae02f22140e
commit fa070e222f45f0d6c0dc54adb5d96ae02f22140e
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sat Mar 28 16:08:40 2020 +0000
JSPT-95 Use non deprecated Constructor to EvaluableScript
https://issues.shibboleth.net/jira/browse/JSPT-95
---
.../utilities/java/support/logic/ScriptedFunction.java | 18 +++++++++++++++---
.../java/support/logic/ScriptedPredicate.java | 18 +++++++++++++++---
2 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/src/main/java/net/shibboleth/utilities/java/support/logic/ScriptedFunction.java b/src/main/java/net/shibboleth/utilities/java/support/logic/ScriptedFunction.java
index 9b46376..763a2d2 100644
--- a/src/main/java/net/shibboleth/utilities/java/support/logic/ScriptedFunction.java
+++ b/src/main/java/net/shibboleth/utilities/java/support/logic/ScriptedFunction.java
@@ -110,6 +110,7 @@ public class ScriptedFunction<T, U> extends AbstractScriptEvaluator implements F
}
/** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
public U apply(@Nullable final T input) {
if (null != getInputType() && null != input && !getInputType().isInstance(input)) {
@@ -140,10 +141,14 @@ public class ScriptedFunction<T, U> extends AbstractScriptEvaluator implements F
* @throws ScriptException if the compile fails
* @throws IOException if the file doesn't exist.
*/
+ @SuppressWarnings("removal")
public static <T,U> ScriptedFunction<T,U> resourceScript(@Nonnull @NotEmpty final String engineName,
@Nonnull final Resource resource) throws ScriptException, IOException {
try (final InputStream is = resource.getInputStream()) {
- final EvaluableScript script = new EvaluableScript(engineName, is);
+ final EvaluableScript script = new EvaluableScript();
+ script.setScriptLanguage(engineName);
+ script.setScript(is);
+ script.initializeWithScriptException();
return new ScriptedFunction<>(script, resource.getDescription());
}
}
@@ -177,9 +182,13 @@ public class ScriptedFunction<T, U> extends AbstractScriptEvaluator implements F
*
* @throws ScriptException if the compile fails
*/
+ @SuppressWarnings("removal")
public static <T,U> ScriptedFunction<T,U> inlineScript(@Nonnull @NotEmpty final String engineName,
@Nonnull @NotEmpty final String scriptSource) throws ScriptException {
- final EvaluableScript script = new EvaluableScript(engineName, scriptSource);
+ final EvaluableScript script = new EvaluableScript();
+ script.setScriptLanguage(engineName);
+ script.setScript(scriptSource);
+ script.initializeWithScriptException();
return new ScriptedFunction<>(script, "Inline");
}
@@ -194,9 +203,12 @@ public class ScriptedFunction<T, U> extends AbstractScriptEvaluator implements F
*
* @throws ScriptException if the compile fails
*/
+ @SuppressWarnings("removal")
public static <T,U> ScriptedFunction<T,U> inlineScript(@Nonnull @NotEmpty final String scriptSource)
throws ScriptException {
- final EvaluableScript script = new EvaluableScript(DEFAULT_ENGINE, scriptSource);
+ final EvaluableScript script = new EvaluableScript();
+ script.setScript(scriptSource);
+ script.initializeWithScriptException();
return new ScriptedFunction<>(script, "Inline");
}
}
\ No newline at end of file
diff --git a/src/main/java/net/shibboleth/utilities/java/support/logic/ScriptedPredicate.java b/src/main/java/net/shibboleth/utilities/java/support/logic/ScriptedPredicate.java
index 2eb5136..bb0b70f 100644
--- a/src/main/java/net/shibboleth/utilities/java/support/logic/ScriptedPredicate.java
+++ b/src/main/java/net/shibboleth/utilities/java/support/logic/ScriptedPredicate.java
@@ -107,10 +107,14 @@ public class ScriptedPredicate<T> extends AbstractScriptEvaluator implements Pre
* @throws ScriptException if the compile fails
* @throws IOException if the file doesn't exist.
*/
+ @SuppressWarnings("removal")
public static <T> ScriptedPredicate<T> resourceScript(@Nonnull @NotEmpty final String engineName,
@Nonnull final Resource resource) throws ScriptException, IOException {
try (final InputStream is = resource.getInputStream()) {
- final EvaluableScript script = new EvaluableScript(engineName, is);
+ final EvaluableScript script = new EvaluableScript();
+ script.setScriptLanguage(engineName);
+ script.setScript(is);
+ script.initializeWithScriptException();
return new ScriptedPredicate<>(script, resource.getDescription());
}
}
@@ -141,9 +145,13 @@ public class ScriptedPredicate<T> extends AbstractScriptEvaluator implements Pre
*
* @throws ScriptException if the compile fails
*/
+ @SuppressWarnings("removal")
public static <T> ScriptedPredicate<T> inlineScript(@Nonnull @NotEmpty final String engineName,
@Nonnull @NotEmpty final String scriptSource) throws ScriptException {
- final EvaluableScript script = new EvaluableScript(engineName, scriptSource);
+ final EvaluableScript script = new EvaluableScript();
+ script.setScriptLanguage(engineName);
+ script.setScript(scriptSource);
+ script.initializeWithScriptException();
return new ScriptedPredicate<>(script, "Inline");
}
@@ -157,9 +165,13 @@ public class ScriptedPredicate<T> extends AbstractScriptEvaluator implements Pre
*
* @throws ScriptException if the compile fails
*/
+ @SuppressWarnings("removal")
public static <T> ScriptedPredicate<T> inlineScript(@Nonnull @NotEmpty final String scriptSource)
throws ScriptException {
- final EvaluableScript script = new EvaluableScript(DEFAULT_ENGINE, scriptSource);
+ final EvaluableScript script = new EvaluableScript();
+ script.setScriptLanguage(DEFAULT_ENGINE);
+ script.setScript(scriptSource);
+ script.initializeWithScriptException();
return new ScriptedPredicate<>(script, "Inline");
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list