1. /*
  2. * Copyright 2002,2004 The Apache Software Foundation
  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 org.apache.tools.ant.input;
  18. import java.util.Vector;
  19. /**
  20. * Encapsulates an input request.
  21. *
  22. * @version $Revision: 1.3.2.4 $
  23. * @since Ant 1.5
  24. */
  25. public class MultipleChoiceInputRequest extends InputRequest {
  26. private Vector choices = new Vector();
  27. /**
  28. * @param prompt The prompt to show to the user. Must not be null.
  29. * @param choices holds all input values that are allowed.
  30. * Must not be null.
  31. */
  32. public MultipleChoiceInputRequest(String prompt, Vector choices) {
  33. super(prompt);
  34. if (choices == null) {
  35. throw new IllegalArgumentException("choices must not be null");
  36. }
  37. this.choices = choices;
  38. }
  39. /**
  40. * @return The possible values.
  41. */
  42. public Vector getChoices() {
  43. return choices;
  44. }
  45. /**
  46. * @return true if the input is one of the allowed values.
  47. */
  48. public boolean isInputValid() {
  49. return choices.contains(getInput());
  50. }
  51. }