aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/avcnmanager/message/processing/tokens
diff options
context:
space:
mode:
authorEdyta Krukowska <edyta.krukowska@nokia.com>2021-03-02 14:44:48 +0100
committerEdyta Krukowska <edyta.krukowska@nokia.com>2021-03-09 14:20:04 +0100
commite5ba738691cf34f0d58a47796d6e0d3da7641f33 (patch)
treef0df24345a1fa3a3a860c406866ef64ad34a824c /src/main/java/org/onap/avcnmanager/message/processing/tokens
parenta9292d1d05c313ba41a1401a3b5bcf3b8866b6aa (diff)
Move avcnsimulator to nf-simulator/avcn-manager
Issue-ID: INT-1869 Signed-off-by: Edyta Krukowska <edyta.krukowska@nokia.com> Change-Id: I5c0dcdf7bf67d0dac9ff7e77829890920f426b7d
Diffstat (limited to 'src/main/java/org/onap/avcnmanager/message/processing/tokens')
-rw-r--r--src/main/java/org/onap/avcnmanager/message/processing/tokens/BaseToken.java32
-rw-r--r--src/main/java/org/onap/avcnmanager/message/processing/tokens/ContainerToken.java49
-rw-r--r--src/main/java/org/onap/avcnmanager/message/processing/tokens/ListToken.java59
-rw-r--r--src/main/java/org/onap/avcnmanager/message/processing/tokens/Token.java31
-rw-r--r--src/main/java/org/onap/avcnmanager/message/processing/tokens/ValueToken.java60
5 files changed, 231 insertions, 0 deletions
diff --git a/src/main/java/org/onap/avcnmanager/message/processing/tokens/BaseToken.java b/src/main/java/org/onap/avcnmanager/message/processing/tokens/BaseToken.java
new file mode 100644
index 0000000..11e79bf
--- /dev/null
+++ b/src/main/java/org/onap/avcnmanager/message/processing/tokens/BaseToken.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Simulator
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.avcnmanager.message.processing.tokens;
+
+public abstract class BaseToken implements Token {
+ private final String value;
+ BaseToken(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
diff --git a/src/main/java/org/onap/avcnmanager/message/processing/tokens/ContainerToken.java b/src/main/java/org/onap/avcnmanager/message/processing/tokens/ContainerToken.java
new file mode 100644
index 0000000..1d56889
--- /dev/null
+++ b/src/main/java/org/onap/avcnmanager/message/processing/tokens/ContainerToken.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Simulator
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.avcnmanager.message.processing.tokens;
+
+import org.onap.avcnmanager.message.processing.targets.TargetContainer;
+
+import java.util.AbstractMap;
+import java.util.Map;
+
+public class ContainerToken extends BaseToken {
+ private static final Map.Entry<String,String> EMPTY_ENTRY = new AbstractMap.SimpleEntry<>("","");
+
+ public ContainerToken(String value) {
+ super(value);
+ }
+
+ @Override
+ public String stringValue() {
+ return getValue() + "= " + getValue();
+ }
+
+ @Override
+ public Map.Entry<String, String> pairValue() {
+ return EMPTY_ENTRY;
+ }
+
+ @Override
+ public void dump(TargetContainer<String> targetContainer) {
+ targetContainer.acceptOne(stringValue());
+ }
+}
diff --git a/src/main/java/org/onap/avcnmanager/message/processing/tokens/ListToken.java b/src/main/java/org/onap/avcnmanager/message/processing/tokens/ListToken.java
new file mode 100644
index 0000000..7046de7
--- /dev/null
+++ b/src/main/java/org/onap/avcnmanager/message/processing/tokens/ListToken.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Simulator
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.avcnmanager.message.processing.tokens;
+
+import org.onap.avcnmanager.message.processing.targets.TargetContainer;
+
+import java.util.AbstractMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class ListToken extends BaseToken {
+ private static final Map.Entry<String,String> EMPTY_ENTRY = new AbstractMap.SimpleEntry<>("","");
+ private static final Pattern PATTERN_LIST = Pattern.compile("(.*)?\\[(.*)?='(.*)?'\\]");
+
+ public ListToken(String value) {
+ super(value);
+ }
+
+ @Override
+ public String stringValue() {
+ StringBuilder sb = new StringBuilder();
+ Matcher m = PATTERN_LIST.matcher(getValue());
+ if (m.find()) {
+ String listName = m.group(1);
+ String value = m.group(3);
+ sb.append(listName).append("=").append(value);
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public Map.Entry<String, String> pairValue() {
+ return EMPTY_ENTRY;
+ }
+
+ @Override
+ public void dump(TargetContainer<String> targetContainer) {
+ targetContainer.acceptOne(stringValue());
+ }
+}
diff --git a/src/main/java/org/onap/avcnmanager/message/processing/tokens/Token.java b/src/main/java/org/onap/avcnmanager/message/processing/tokens/Token.java
new file mode 100644
index 0000000..26720e5
--- /dev/null
+++ b/src/main/java/org/onap/avcnmanager/message/processing/tokens/Token.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Simulator
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.avcnmanager.message.processing.tokens;
+
+import org.onap.avcnmanager.message.processing.targets.TargetContainer;
+
+import java.util.Map;
+
+public interface Token {
+ String stringValue();
+ Map.Entry<String,String> pairValue();
+ void dump(TargetContainer<String> targetContainer);
+}
diff --git a/src/main/java/org/onap/avcnmanager/message/processing/tokens/ValueToken.java b/src/main/java/org/onap/avcnmanager/message/processing/tokens/ValueToken.java
new file mode 100644
index 0000000..336de21
--- /dev/null
+++ b/src/main/java/org/onap/avcnmanager/message/processing/tokens/ValueToken.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Simulator
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.avcnmanager.message.processing.tokens;
+
+import org.onap.avcnmanager.message.processing.targets.TargetContainer;
+
+import java.util.AbstractMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class ValueToken extends BaseToken {
+ private static final Map.Entry<String,String> EMPTY_ENTRY = new AbstractMap.SimpleEntry<>("","");
+ private static final Pattern PATTERN_VALUE = Pattern.compile("(.*)=(.*)");
+
+ public ValueToken(String value) {
+ super(value);
+ }
+
+ @Override
+ public String stringValue() {
+ return "";
+ }
+
+ @Override
+ public Map.Entry<String, String> pairValue() {
+ Map.Entry<String,String> entry = EMPTY_ENTRY;
+ Matcher m = PATTERN_VALUE.matcher(getValue());
+ if (m.find()) {
+ String paramName = m.group(1).trim();
+ String paramValue = m.group(2).trim();
+ entry = new AbstractMap.SimpleEntry<>(paramName, paramValue);
+ }
+ return entry;
+ }
+
+ @Override
+ public void dump(TargetContainer<String> targetContainer) {
+ Map.Entry<String,String> entry = pairValue();
+ targetContainer.acceptPair(entry.getKey(), entry.getValue());
+ }
+}