2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2018 IBM.
7 * ===========================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END====================================================
23 package org.onap.aaf.auth.batch.helpers;
25 import java.io.BufferedReader;
26 import java.io.IOException;
27 import java.io.PrintStream;
28 import java.util.Iterator;
29 import java.util.NoSuchElementException;
30 import org.onap.aaf.auth.env.AuthzTrans;
33 public class InputIterator implements Iterable<String> {
34 private BufferedReader in;
35 private final PrintStream out;
36 private final String prompt;
37 private final String instructions;
38 private static AuthzTrans trans;
40 public InputIterator(BufferedReader in, PrintStream out, String prompt, String instructions) {
44 this.instructions = instructions;
48 public Iterator<String> iterator() {
49 out.println(instructions);
50 return new Iterator<String>() {
53 public boolean hasNext() {
56 input = in.readLine();
57 } catch (IOException e) {
58 trans.error().log("IO Exception",e.getMessage());
62 return input.length()>0;
66 public String next() {
68 throw new NoSuchElementException();
74 public void remove() {