KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > input > InputRequest


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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 JavaDoc prompt;
28     private String JavaDoc input;
29     private String JavaDoc 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 JavaDoc prompt) {
36         if (prompt == null) {
37             throw new IllegalArgumentException JavaDoc("prompt must not be null");
38         }
39
40         this.prompt = prompt;
41     }
42
43     /**
44      * Retrieves the prompt text.
45      * @return the prompt.
46      */

47     public String JavaDoc getPrompt() {
48         return prompt;
49     }
50
51     /**
52      * Sets the user provided input.
53      * @param input the string to be used for input.
54      */

55     public void setInput(String JavaDoc input) {
56         this.input = input;
57     }
58
59     /**
60      * Is the user input valid?
61      * @return true if it is.
62      */

63     public boolean isInputValid() {
64         return true;
65     }
66
67     /**
68      * Retrieves the user input.
69      * @return the user input.
70      */

71     public String JavaDoc getInput() {
72         return input;
73     }
74
75     /**
76      * Gets a configured default value.
77      * @return the default value.
78      * @since Ant 1.7.0
79      */

80     public String JavaDoc getDefaultValue() {
81         return defaultValue;
82     }
83
84     /**
85      * Configures a default value.
86      * @param d the value to set.
87      * @since Ant 1.7.0
88      */

89     public void setDefaultValue(String JavaDoc d) {
90         defaultValue = d;
91     }
92
93 }
94
Popular Tags