View Javadoc

    1   /*
    2    * Copyright [2005] [University Corporation for Advanced Internet Development, Inc.]
    3    *
    4    * Licensed under the Apache License, Version 2.0 (the "License");
    5    * you may not use this file except in compliance with the License.
    6    * You may obtain a copy of the License at
    7    *
    8    * http://www.apache.org/licenses/LICENSE-2.0
    9    *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16
    17  package edu.internet2.middleware.ant.input;
    18
    19  import org.apache.tools.ant.input.InputRequest;
    20
    21  /**
    22   * Extended version of <code>org.apache.tools.ant.input.InputRequest</code>
    23   *
    24   */
    25  public class XInputRequest extends InputRequest {
    26
    27      private String prompt;
    28
    29      private String input;
    30
    31      /**
    32       * @param prompt The prompt to show to the user. Must not be null.
    33       */
    34      public XInputRequest(String prompt) {
    35
    36          super(prompt);
    37          if (prompt == null) {
    38              throw new IllegalArgumentException("prompt must not be null");
    39          }
    40
    41          this.prompt = prompt;
    42      }
    43
    44      /**
    45       * Retrieves the prompt text.
    46       */
    47      public String getPrompt() {
    48
    49          return prompt;
    50      }
    51
    52      /**
    53       * Sets the user provided input.
    54       */
    55      public void setInput(String input) {
    56
    57          this.input = input;
    58      }
    59
    60      /**
    61       * Is the user input valid?
    62       */
    63      public boolean isInputValid() {
    64
    65          return true;
    66      }
    67
    68      /**
    69       * Retrieves the user input.
    70       */
    71      public String getInput() {
    72
    73          return input;
    74      }
    75
    76  }