Return-Path: X-Original-To: apmail-commons-notifications-archive@minotaur.apache.org Delivered-To: apmail-commons-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2C7EC100AD for ; Sat, 9 May 2015 18:19:22 +0000 (UTC) Received: (qmail 36070 invoked by uid 500); 9 May 2015 18:19:22 -0000 Delivered-To: apmail-commons-notifications-archive@commons.apache.org Received: (qmail 36004 invoked by uid 500); 9 May 2015 18:19:22 -0000 Mailing-List: contact notifications-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list notifications@commons.apache.org Received: (qmail 35847 invoked by uid 99); 9 May 2015 18:19:21 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 May 2015 18:19:21 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id E06F9AC0FE5 for ; Sat, 9 May 2015 18:19:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r950741 [29/40] - in /websites/production/commons/content/proper/commons-cli: ./ apidocs/ apidocs/org/apache/commons/cli/ apidocs/org/apache/commons/cli/class-use/ apidocs/resources/ apidocs/src-html/org/apache/commons/cli/ cobertura/ jacoc... Date: Sat, 09 May 2015 18:19:17 -0000 To: notifications@commons.apache.org From: britter@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150509181921.E06F9AC0FE5@hades.apache.org> Added: websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionBuilder.html ============================================================================== --- websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionBuilder.html (added) +++ websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionBuilder.html Sat May 9 18:19:15 2015 @@ -0,0 +1 @@ +OptionBuilder

OptionBuilder

1
ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total8 of 15495%0 of 4100%224366222
isRequired(boolean)40%n/a112211
withType(Object)40%n/a1111< /td>11
create(String)37100%n/a0101201
reset()17100%n/a010901
create()11100%2100%020401
hasArg(boolean)8100%2100 %020201
static {...}8100%n/a010401
hasOptionalArg()6100%n/a010301
hasOptionalArgs()6100%n/a010301
hasOptionalArgs(int)6100%n/a0< /td>10301
withLongOpt(String)4100%n/a010201
hasArg()4100%n/a010201
withArgName(String)4100%n/a010201
isRequired()4100%n/a00201
withValueSeparator(char)4100%n/a010201
withValueSeparator()4100%n/a010201
hasArgs()4100%n/a010201
hasArgs(int)4100%n/a010201
withType(Class)4100%n/a010201
withDescription(String)4100%n/a010201
create(char)4100%n/a010101
OptionBuilder()3100%n/a010201
\ No newline at end of file Propchange: websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionBuilder.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionBuilder.java.html ============================================================================== --- websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionBuilder.java.html (added) +++ websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionBuilder.java.html Sat May 9 18:19:15 2015 @@ -0,0 +1,397 @@ +OptionBuilder.javaOptionBuilder.java
/**
+ * 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;
+
+/**
+ * OptionBuilder allows the user to create Options using descriptive methods.
+ * <p>
+ * Details on the Builder pattern can be found at
+ * <a href="http://c2.com/cgi-bin/wiki?BuilderPattern">http://c2.com/cgi-bin/wiki?BuilderPattern</a>.
+ * <p>
+ * This class is NOT thread safe. See <a href="https://issues.apache.org/jira/browse/CLI-209">CLI-209</a>
+ * 
+ * @version $Id: OptionBuilder.java 1677400 2015-05-03 13:46:08Z britter $
+ * @since 1.0
+ * @deprecated since 1.3, use {@link Option#builder(String)} instead
+ */
+@Deprecated
+public final class OptionBuilder
+{
+    /** long option */
+    private static String longopt;
+
+    /** option description */
+    private static String description;
+
+    /** argument name */
+    private static String argName;
+
+    /** is required? */
+    private static boolean required;
+
+    /** the number of arguments */
+    private static int numberOfArgs = Option.UNINITIALIZED;
+
+    /** option type */
+    private static Class<?> type;
+
+    /** option can have an optional argument value */
+    private static boolean optionalArg;
+
+    /** value separator for argument value */
+    private static char valuesep;
+
+    /** option builder instance */
+    private static final OptionBuilder INSTANCE = new OptionBuilder();
+
+    static
+    {
+        // ensure the consistency of the initial values
+        reset();
+    }
+
+    /**
+     * private constructor to prevent instances being created
+     */
+    private OptionBuilder()
+    {
+        // hide the constructor
+    }
+
+    /**
+     * Resets the member variables to their default values.
+     */
+    private static void reset()
+    {
+        description = null;
+        argName = null;
+        longopt = null;
+        type = String.class;
+        required = false;
+        numberOfArgs = Option.UNINITIALIZED;
+        optionalArg = false;
+        valuesep = (char) 0;
+    }
+
+    /**
+     * The next Option created will have the following long option value.
+     *
+     * @param newLongopt the long option value
+     * @return the OptionBuilder instance
+     */
+    public static OptionBuilder withLongOpt(String newLongopt)
+    {
+        OptionBuilder.longopt = newLongopt;
+
+        return INSTANCE;
+    }
+
+    /**
+     * The next Option created will require an argument value.
+     *
+     * @return the OptionBuilder instance
+     */
+    public static OptionBuilder hasArg()
+    {
+        OptionBuilder.numberOfArgs = 1;
+
+        return INSTANCE;
+    }
+
+    /**
+     * The next Option created will require an argument value if
+     * <code>hasArg</code> is true.
+     *
+     * @param hasArg if true then the Option has an argument value
+     * @return the OptionBuilder instance
+     */
+    public static OptionBuilder hasArg(boolean hasArg)
+    {
+        OptionBuilder.numberOfArgs = hasArg ? 1 : Option.UNINITIALIZED;
+
+        return INSTANCE;
+    }
+
+    /**
+     * The next Option created will have the specified argument value name.
+     *
+     * @param name the name for the argument value
+     * @return the OptionBuilder instance
+     */
+    public static OptionBuilder withArgName(String name)
+    {
+        OptionBuilder.argName = name;
+
+        return INSTANCE;
+    }
+
+    /**
+     * The next Option created will be required.
+     *
+     * @return the OptionBuilder instance
+     */
+    public static OptionBuilder isRequired()
+    {
+        OptionBuilder.required = true;
+
+        return INSTANCE;
+    }
+
+    /**
+     * The next Option created uses <code>sep</code> as a means to
+     * separate argument values.
+     * <p>
+     * <b>Example:</b>
+     * <pre>
+     * Option opt = OptionBuilder.withValueSeparator('=')
+     *                           .create('D');
+     *
+     * String args = "-Dkey=value";
+     * CommandLine line = parser.parse(args);
+     * String propertyName = opt.getValue(0);  // will be "key"
+     * String propertyValue = opt.getValue(1); // will be "value"
+     * </pre>
+     *
+     * @param sep The value separator to be used for the argument values.
+     *
+     * @return the OptionBuilder instance
+     */
+    public static OptionBuilder withValueSeparator(char sep)
+    {
+        OptionBuilder.valuesep = sep;
+
+        return INSTANCE;
+    }
+
+    /**
+     * The next Option created uses '<code>=</code>' as a means to
+     * separate argument values.
+     *
+     * <b>Example:</b>
+     * <pre>
+     * Option opt = OptionBuilder.withValueSeparator()
+     *                           .create('D');
+     *
+     * CommandLine line = parser.parse(args);
+     * String propertyName = opt.getValue(0);
+     * String propertyValue = opt.getValue(1);
+     * </pre>
+     *
+     * @return the OptionBuilder instance
+     */
+    public static OptionBuilder withValueSeparator()
+    {
+        OptionBuilder.valuesep = '=';
+
+        return INSTANCE;
+    }
+
+    /**
+     * The next Option created will be required if <code>required</code>
+     * is true.
+     *
+     * @param newRequired if true then the Option is required
+     * @return the OptionBuilder instance
+     */
+    public static OptionBuilder isRequired(boolean newRequired)
+    {
+        OptionBuilder.required = newRequired;
+
+        return INSTANCE;
+    }
+
+    /**
+     * The next Option created can have unlimited argument values.
+     *
+     * @return the OptionBuilder instance
+     */
+    public static OptionBuilder hasArgs()
+    {
+        OptionBuilder.numberOfArgs = Option.UNLIMITED_VALUES;
+
+        return INSTANCE;
+    }
+
+    /**
+     * The next Option created can have <code>num</code> argument values.
+     *
+     * @param num the number of args that the option can have
+     * @return the OptionBuilder instance
+     */
+    public static OptionBuilder hasArgs(int num)
+    {
+        OptionBuilder.numberOfArgs = num;
+
+        return INSTANCE;
+    }
+
+    /**
+     * The next Option can have an optional argument.
+     *
+     * @return the OptionBuilder instance
+     */
+    public static OptionBuilder hasOptionalArg()
+    {
+        OptionBuilder.numberOfArgs = 1;
+        OptionBuilder.optionalArg = true;
+
+        return INSTANCE;
+    }
+
+    /**
+     * The next Option can have an unlimited number of optional arguments.
+     *
+     * @return the OptionBuilder instance
+     */
+    public static OptionBuilder hasOptionalArgs()
+    {
+        OptionBuilder.numberOfArgs = Option.UNLIMITED_VALUES;
+        OptionBuilder.optionalArg = true;
+
+        return INSTANCE;
+    }
+
+    /**
+     * The next Option can have the specified number of optional arguments.
+     *
+     * @param numArgs - the maximum number of optional arguments
+     * the next Option created can have.
+     * @return the OptionBuilder instance
+     */
+    public static OptionBuilder hasOptionalArgs(int numArgs)
+    {
+        OptionBuilder.numberOfArgs = numArgs;
+        OptionBuilder.optionalArg = true;
+
+        return INSTANCE;
+    }
+
+    /**
+     * The next Option created will have a value that will be an instance
+     * of <code>type</code>.
+     * <p>
+     * <b>Note:</b> this method is kept for binary compatibility and the
+     * input type is supposed to be a {@link Class} object. 
+     *
+     * @param newType the type of the Options argument value
+     * @return the OptionBuilder instance
+     * @deprecated since 1.3, use {@link #withType(Class)} instead
+     */
+    @Deprecated
+    public static OptionBuilder withType(Object newType)
+    {
+        return withType((Class<?>) newType);
+    }
+
+    /**
+     * The next Option created will have a value that will be an instance
+     * of <code>type</code>.
+     *
+     * @param newType the type of the Options argument value
+     * @return the OptionBuilder instance
+     * @since 1.3
+     */
+    public static OptionBuilder withType(Class<?> newType)
+    {
+        OptionBuilder.type = newType;
+
+        return INSTANCE;
+    }
+
+    /**
+     * The next Option created will have the specified description
+     *
+     * @param newDescription a description of the Option's purpose
+     * @return the OptionBuilder instance
+     */
+    public static OptionBuilder withDescription(String newDescription)
+    {
+        OptionBuilder.description = newDescription;
+
+        return INSTANCE;
+    }
+
+    /**
+     * Create an Option using the current settings and with
+     * the specified Option <code>char</code>.
+     *
+     * @param opt the character representation of the Option
+     * @return the Option instance
+     * @throws IllegalArgumentException if <code>opt</code> is not
+     * a valid character.  See Option.
+     */
+    public static Option create(char opt) throws IllegalArgumentException
+    {
+        return create(String.valueOf(opt));
+    }
+
+    /**
+     * Create an Option using the current settings
+     *
+     * @return the Option instance
+     * @throws IllegalArgumentException if <code>longOpt</code> has not been set.
+     */
+    public static Option create() throws IllegalArgumentException
+    {
+        if (longopt == null)
+        {
+            OptionBuilder.reset();
+            throw new IllegalArgumentException("must specify longopt");
+        }
+
+        return create(null);
+    }
+
+    /**
+     * Create an Option using the current settings and with
+     * the specified Option <code>char</code>.
+     *
+     * @param opt the <code>java.lang.String</code> representation
+     * of the Option
+     * @return the Option instance
+     * @throws IllegalArgumentException if <code>opt</code> is not
+     * a valid character.  See Option.
+     */
+    public static Option create(String opt) throws IllegalArgumentException
+    {
+        Option option = null;
+        try
+        {
+            // create the option
+            option = new Option(opt, description);
+
+            // set the option properties
+            option.setLongOpt(longopt);
+            option.setRequired(required);
+            option.setOptionalArg(optionalArg);
+            option.setArgs(numberOfArgs);
+            option.setType(type);
+            option.setValueSeparator(valuesep);
+            option.setArgName(argName);
+        }
+        finally
+        {
+            // reset the OptionBuilder properties
+            OptionBuilder.reset();
+        }
+
+        // return the Option instance
+        return option;
+    }
+}
+
\ No newline at end of file Propchange: websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionBuilder.java.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionGroup.html ============================================================================== --- websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionGroup.html (added) +++ websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionGroup.html Sat May 9 18:19:15 2015 @@ -0,0 +1 @@ +OptionGroup

OptionGroup

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total0 of 130100%1 of 1493%11603509
toString()68100%8100%0501801
setSelected(Option)27100%1583%140701
addOption(Option)9100%n/a010201
OptionGroup()8100%n/a010201
getNames()4100%n/a010101
getOptions()4100%n/a010101
setRequired(boolean)4100%n/a010201
getSelected()3100%n/a010101
isRequired()3100%n/a010101
\ No newline at end of file Propchange: websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionGroup.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionGroup.java.html ============================================================================== --- websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionGroup.java.html (added) +++ websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionGroup.java.html Sat May 9 18:19:15 2015 @@ -0,0 +1,180 @@ +OptionGroup.java

Op tionGroup.java

/**
+ * 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.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * A group of mutually exclusive options.
+ *
+ * @version $Id: OptionGroup.java 1669814 2015-03-28 18:09:26Z britter $
+ */
+public class OptionGroup implements Serializable
+{
+    /** The serial version UID. */
+    private static final long serialVersionUID = 1L;
+    
+    /** hold the options */
+    private final Map<String, Option> optionMap = new HashMap<String, Option>();
+
+    /** the name of the selected option */
+    private String selected;
+
+    /** specified whether this group is required */
+    private boolean required;
+
+    /**
+     * Add the specified <code>Option</code> to this group.
+     *
+     * @param option the option to add to this group
+     * @return this option group with the option added
+     */
+    public OptionGroup addOption(Option option)
+    {
+        // key   - option name
+        // value - the option
+        optionMap.put(option.getKey(), option);
+
+        return this;
+    }
+
+    /**
+     * @return the names of the options in this group as a 
+     * <code>Collection</code>
+     */
+    public Collection<String> getNames()
+    {
+        // the key set is the collection of names
+        return optionMap.keySet();
+    }
+
+    /**
+     * @return the options in this group as a <code>Collection</code>
+     */
+    public Collection<Option> getOptions()
+    {
+        // the values are the collection of options
+        return optionMap.values();
+    }
+
+    /**
+     * Set the selected option of this group to <code>name</code>.
+     *
+     * @param option the option that is selected
+     * @throws AlreadySelectedException if an option from this group has 
+     * already been selected.
+     */
+    public void setSelected(Option option) throws AlreadySelectedException
+    {
+        if (option == null)
+        {
+            // reset the option previously selected
+            selected = null;
+            return;
+        }
+        
+        // if no option has already been selected or the 
+        // same option is being reselected then set the
+        // selected member variable
+        if (selected == null || selected.equals(option.getKey()))
+        {
+            selected = option.getKey();
+        }
+        else
+        {
+            throw new AlreadySelectedException(this, option);
+        }
+    }
+
+    /**
+     * @return the selected option name
+     */
+    public String getSelected()
+    {
+        return selected;
+    }
+
+    /**
+     * @param required specifies if this group is required
+     */
+    public void setRequired(boolean required)
+    {
+        this.required = required;
+    }
+
+    /**
+     * Returns whether this option group is required.
+     *
+     * @return whether this option group is required
+     */
+    public boolean isRequired()
+    {
+        return required;
+    }
+
+    /**
+     * Returns the stringified version of this OptionGroup.
+     * 
+     * @return the stringified representation of this group
+     */
+    @Override
+    public String toString()
+    {
+        StringBuilder buff = new StringBuilder();
+        
+        Iterator<Option> iter = getOptions().iterator();
+
+        buff.append("[");
+
+        while (iter.hasNext())
+        {
+            Option option = iter.next();
+
+            if (option.getOpt() != null)
+            {
+                buff.append("-");
+                buff.append(option.getOpt());
+            }
+            else
+            {
+                buff.append("--");
+                buff.append(option.getLongOpt());
+            }
+            
+            if (option.getDescription() != null)
+            {
+                buff.append(" ");
+                buff.append(option.getDescription());
+            }
+            
+            if (iter.hasNext())
+            {
+                buff.append(", ");
+            }
+        }
+
+        buff.append("]");
+
+        return buff.toString();
+    }
+}
+
\ No newline at end of file Propchange: websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionGroup.java.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionValidator.html ============================================================================== --- websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionValidator.html (added) +++ websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionValidator.html Sat May 9 18:19:15 2015 @@ -0,0 +1 @@ +OptionValidator

OptionValidator

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total3 of 8997%0 of 16100%11211414
OptionValidator()30%n/a111111
validateOption(String)70100%10100%0601101
isValidOpt(char)13100%6100%040101
isValidChar(char)3100%n/a010101
\ No newline at end of file Propchange: websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionValidator.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionValidator.java.html ============================================================================== --- websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionValidator.java.html (added) +++ websites/production/commons/content/proper/commons-cli/jacoco/org.apache.commons.cli/OptionValidator.java.html Sat May 9 18:19:15 2015 @@ -0,0 +1,100 @@ +OptionValidator.java