01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
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.
16: *
17: */
18:
19: package org.apache.tools.ant.input;
20:
21: /**
22: * Encapsulates an input request.
23: *
24: * @since Ant 1.5
25: */
26: public class InputRequest {
27: private String prompt;
28: private String input;
29: private String defaultValue;
30:
31: /**
32: * Construct an InputRequest.
33: * @param prompt The prompt to show to the user. Must not be null.
34: */
35: public InputRequest(String prompt) {
36: if (prompt == null) {
37: throw new IllegalArgumentException(
38: "prompt must not be null");
39: }
40:
41: this .prompt = prompt;
42: }
43:
44: /**
45: * Retrieves the prompt text.
46: * @return the prompt.
47: */
48: public String getPrompt() {
49: return prompt;
50: }
51:
52: /**
53: * Sets the user provided input.
54: * @param input the string to be used for input.
55: */
56: public void setInput(String input) {
57: this .input = input;
58: }
59:
60: /**
61: * Is the user input valid?
62: * @return true if it is.
63: */
64: public boolean isInputValid() {
65: return true;
66: }
67:
68: /**
69: * Retrieves the user input.
70: * @return the user input.
71: */
72: public String getInput() {
73: return input;
74: }
75:
76: /**
77: * Gets a configured default value.
78: * @return the default value.
79: * @since Ant 1.7.0
80: */
81: public String getDefaultValue() {
82: return defaultValue;
83: }
84:
85: /**
86: * Configures a default value.
87: * @param d the value to set.
88: * @since Ant 1.7.0
89: */
90: public void setDefaultValue(String d) {
91: defaultValue = d;
92: }
93:
94: }
|