/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.cli; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Properties; /** * Represents list of arguments parsed against a {@link Options} descriptor. *

* It allows querying of a boolean {@link #hasOption(String opt)}, in addition to retrieving the * {@link #getOptionValue(String opt)} for options requiring arguments. *

* Additionally, any left-over or unrecognized arguments, are available for further processing. * * @version $Id: CommandLine.java 1444365 2013-02-09 14:21:27Z tn $ */ public class CommandLine implements Serializable { /** The serial version UID. */ private static final long serialVersionUID = 1L; /** the unrecognised options/arguments */ private final List args = new LinkedList<>(); /** the processed options */ private final List

* Dump state, suitable for debugging. *

* * @return Stringified form of this object */ /* * public String toString() { StringBuilder buf = new StringBuilder(); * * buf.append("[ CommandLine: [ options: "); buf.append(options.toString()); buf.append(" ] [ args: "); * buf.append(args.toString()); buf.append(" ] ]"); * * return buf.toString(); } */ /** * Add left-over unrecognized option/argument. * * @param arg * the unrecognised option/argument. */ protected void addArg(final String arg) { args.add(arg); } /** * Add an option to the command line. The values of the option are stored. * * @param opt * the processed option */ protected void addOption(final Option opt) { options.add(opt); } /** * Returns an iterator over the Option members of CommandLine. * * @return an Iterator over the processed {@link Option} members of this {@link CommandLine} */ public Iterator