| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Argument |
|
| 1.0;1 |
| 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 | package org.apache.commons.cli2; | |
| 18 | ||
| 19 | import java.util.ListIterator; | |
| 20 | ||
| 21 | /** | |
| 22 | * An Option that can process values passed on the command line in the form | |
| 23 | * "--file README". | |
| 24 | */ | |
| 25 | public interface Argument extends Option { | |
| 26 | ||
| 27 | /** | |
| 28 | * Returns the initial separator character or | |
| 29 | * '\0' if no character has been set. | |
| 30 | * | |
| 31 | * @return char the initial separator character | |
| 32 | */ | |
| 33 | char getInitialSeparator(); | |
| 34 | ||
| 35 | /** | |
| 36 | * Processes the "README" style element of the argument. | |
| 37 | * | |
| 38 | * Values identified should be added to the CommandLine object in | |
| 39 | * association with this Argument. | |
| 40 | * | |
| 41 | * @see WriteableCommandLine#addValue(Option,Object) | |
| 42 | * | |
| 43 | * @param commandLine The CommandLine object to store results in. | |
| 44 | * @param args The arguments to process. | |
| 45 | * @param option The option to register value against. | |
| 46 | * @throws OptionException if any problems occur. | |
| 47 | */ | |
| 48 | void processValues( | |
| 49 | final WriteableCommandLine commandLine, | |
| 50 | final ListIterator args, | |
| 51 | final Option option) | |
| 52 | throws OptionException; | |
| 53 | ||
| 54 | /** | |
| 55 | * Adds defaults to a CommandLine. | |
| 56 | * | |
| 57 | * @param commandLine | |
| 58 | * The CommandLine object to store defaults in. | |
| 59 | * @param option | |
| 60 | * The Option to store the defaults against. | |
| 61 | */ | |
| 62 | void defaultValues(final WriteableCommandLine commandLine, final Option option); | |
| 63 | ||
| 64 | /** | |
| 65 | * Performs any necessary validation on the values added to the | |
| 66 | * CommandLine. | |
| 67 | * | |
| 68 | * Validation will typically involve using the | |
| 69 | * CommandLine.getValues(option) method to retrieve the values | |
| 70 | * and then either checking each value. Optionally the String | |
| 71 | * value can be replaced by another Object such as a Number | |
| 72 | * instance or a File instance. | |
| 73 | * | |
| 74 | * @see CommandLine#getValues(Option) | |
| 75 | * | |
| 76 | * @param commandLine The CommandLine object to query. | |
| 77 | * @param option The option to lookup values with. | |
| 78 | * @throws OptionException if any problems occur. | |
| 79 | */ | |
| 80 | void validate(final WriteableCommandLine commandLine, final Option option) | |
| 81 | throws OptionException; | |
| 82 | ||
| 83 | /** | |
| 84 | * Indicates whether argument values must be present for the CommandLine to | |
| 85 | * be valid. | |
| 86 | * | |
| 87 | * @see #getMinimum() | |
| 88 | * @see #getMaximum() | |
| 89 | * @return true iff the CommandLine will be invalid without at least one | |
| 90 | * value | |
| 91 | */ | |
| 92 | boolean isRequired(); | |
| 93 | ||
| 94 | /** | |
| 95 | * Retrieves the minimum number of values required for a valid Argument | |
| 96 | * | |
| 97 | * @return the minimum number of values | |
| 98 | */ | |
| 99 | int getMinimum(); | |
| 100 | ||
| 101 | /** | |
| 102 | * Retrieves the maximum number of values acceptable for a valid Argument | |
| 103 | * | |
| 104 | * @return the maximum number of values | |
| 105 | */ | |
| 106 | int getMaximum(); | |
| 107 | } |