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.auth.clicodegen;
23 import org.stringtemplate.v4.STErrorListener;
24 import org.stringtemplate.v4.misc.STMessage;
27 * Customized ST error listener.
29 * @author Sven van der Meer (sven.van.der.meer@ericsson.com)
31 public class DummyStErrorListener implements STErrorListener {
33 /** Counts errors of the listener. */
34 private int errorCount;
40 public void IOError(final STMessage msg) {
43 this.registerErrors(msg);
51 public void compileTimeError(final STMessage msg) {
54 this.registerErrors(msg);
62 public void internalError(final STMessage msg) {
65 this.registerErrors(msg);
73 public void runTimeError(final STMessage msg) {
75 case NO_SUCH_PROPERTY:
76 case ARGUMENT_COUNT_MISMATCH:
77 case ANON_ARGUMENT_MISMATCH:
80 this.registerErrors(msg);
85 * Registers an error with the local error listener and increases the error count.
87 * @param msg error message
89 protected void registerErrors(final STMessage msg) {
90 setErrorCount(getErrorCount() + 1);
91 System.err.println("STG/ST (" + msg.error + ") " + msg.arg + " -> " + msg.cause);
95 * Gets the error count.
97 * @return the error count
99 protected int getErrorCount() {
104 * Sets the error count.
106 * @param errorCount the new error count
108 protected void setErrorCount(final int errorCount) {
109 this.errorCount = errorCount;