From 2a038aedc5cf6c963ce415508826f1496efad451 Mon Sep 17 00:00:00 2001 From: TobiasNx Date: Wed, 18 Sep 2024 09:21:55 +0200 Subject: [PATCH] Add draft for stringVariable #533 --- .../metafacture/strings/StringVariable.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 metafacture-strings/src/main/java/org/metafacture/strings/StringVariable.java diff --git a/metafacture-strings/src/main/java/org/metafacture/strings/StringVariable.java b/metafacture-strings/src/main/java/org/metafacture/strings/StringVariable.java new file mode 100644 index 00000000..333178f4 --- /dev/null +++ b/metafacture-strings/src/main/java/org/metafacture/strings/StringVariable.java @@ -0,0 +1,52 @@ +/* +* Copyright 2024 hbz +* +* Licensed 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.metafacture.strings; + +import org.metafacture.framework.FluxCommand; +import org.metafacture.framework.ObjectReceiver; +import org.metafacture.framework.annotations.Description; +import org.metafacture.framework.annotations.In; +import org.metafacture.framework.annotations.Out; +import org.metafacture.framework.helpers.DefaultObjectPipe; + +/** + * Creates a variable for the supplied string and continues the process. +* +* @author Tobias Bülte +*/ +@Description("Creates a variable for the supplied string and continues the process.") +@In(String.class) +@Out(String.class) +@FluxCommand("string-to-variable") +public final class StringReader extends DefaultObjectPipe> { + + private final Map vars = new HashMap(); + public static final String variableName = "inputString"; + + /** + * Creates an instance of {@link StringVariable}. + */ + public StringVariable() { + } + + @Override + public void process(final String str) { + vars.put(variableName,str); + getReceiver().process(str); + } + +}