2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.service.parameters.eventprotocol;
23 import org.onap.policy.common.parameters.GroupValidationResult;
24 import org.onap.policy.common.parameters.ValidationStatus;
27 * An event protocol parameter class for token delimited textual event protocols that may be specialized by event
28 * protocol plugins that require plugin specific parameters.
30 * <p>The following parameters are defined:
32 * <li>startDelimiterToken: the token string that delimits the start of text blocks that contain events.
33 * <li>endDelimiterToken: the token string that delimits the end of text blocks that contain events, this parameter is
34 * optional and defaults to null.
35 * <li>delimiterAtStart: indicates if the first text block should have a delimiter at the start (true), or whether
36 * processing of the first block should begin at the start of the text (false). The parameter is optional and defaults
40 * @author Liam Fallon (liam.fallon@ericsson.com)
42 public abstract class EventProtocolTextTokenDelimitedParameters extends EventProtocolParameters {
43 // The delimiter token for text blocks
44 private String startDelimiterToken = null;
45 private String endDelimiterToken = null;
46 private boolean delimiterAtStart = true;
49 * Constructor to create an event protocol parameters instance with the name of a sub class of this class.
51 * @param parameterClassName
52 * the class name of a sub class of this class
54 public EventProtocolTextTokenDelimitedParameters(final String parameterClassName) {
55 super(parameterClassName);
59 * Gets the start delimiter token that delimits events in the text.
61 * @return the start delimiter token
63 public String getStartDelimiterToken() {
64 return startDelimiterToken;
68 * Sets the start delimiter token that delimits events in the text.
70 * @param startDelimiterToken
71 * delimiterToken the delimiter token
73 public void setStartDelimiterToken(final String startDelimiterToken) {
74 this.startDelimiterToken = startDelimiterToken;
78 * Gets the end delimiter token that delimits events in the text.
80 * @return the end delimiter token
82 public String getEndDelimiterToken() {
83 return endDelimiterToken;
87 * Sets the end delimiter token that delimits events in the text.
89 * @param endDelimiterToken
90 * delimiterToken the delimiter token
92 public void setEndDelimiterToken(final String endDelimiterToken) {
93 this.endDelimiterToken = endDelimiterToken;
97 * Check if there must be a delimiter at the start of the first text block.
99 * @return true if there must be a delimiter at the start of the text block
101 public boolean isDelimiterAtStart() {
102 return delimiterAtStart;
106 * Sets if there has to be a delimiter at the start of the first text block.
108 * @param delimiterAtStart
109 * true if there must be a delimiter at the start of the text block
111 public void setDelimiterAtStart(boolean delimiterAtStart) {
112 this.delimiterAtStart = delimiterAtStart;
116 public String toString() {
117 return "EventProtocolTextTokenDelimitedParameters [startDelimiterToken=" + startDelimiterToken
118 + ", endDelimiterToken=" + endDelimiterToken + ", delimiterAtStart=" + delimiterAtStart + "]";
124 * @see org.onap.policy.apex.service.parameters.ApexParameterValidator#validate()
127 public GroupValidationResult validate() {
128 final GroupValidationResult result = super.validate();
130 if (startDelimiterToken == null || startDelimiterToken.length() == 0) {
131 result.setResult("startDelimiterToken", ValidationStatus.INVALID,
132 "text start delimiter token not specified or is blank\n");