You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/06/16 18:11:40 UTC
[3/5] incubator-geode git commit: GEODE-835: replace geode-joptsimple
with jopt-simple dependency
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1c5ba141/geode-joptsimple/src/main/java/joptsimple/ArgumentAcceptingOptionSpec.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/ArgumentAcceptingOptionSpec.java b/geode-joptsimple/src/main/java/joptsimple/ArgumentAcceptingOptionSpec.java
deleted file mode 100644
index deea27f..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/ArgumentAcceptingOptionSpec.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- The MIT License
-
- Copyright (c) 2004-2011 Paul R. Holser, Jr.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-package joptsimple;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import joptsimple.internal.ReflectionException;
-
-import static java.util.Collections.*;
-
-import static joptsimple.internal.Objects.*;
-import static joptsimple.internal.Reflection.*;
-import static joptsimple.internal.Strings.*;
-
-
-
-/**
- * <p>Specification of an option that accepts an argument.</p>
- *
- * <p>Instances are returned from {@link OptionSpecBuilder} methods to allow the formation of parser directives as
- * sentences in a "fluent interface" language. For example:</p>
- *
- * <pre>
- * <code>
- * OptionParser parser = new OptionParser();
- * parser.accepts( "c" ).withRequiredArg().<strong>ofType( Integer.class )</strong>;
- * </code>
- * </pre>
- *
- * <p>If no methods are invoked on an instance of this class, then that instance's option will treat its argument as
- * a {@link String}.</p>
- *
- * @param <V> represents the type of the arguments this option accepts
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-public abstract class ArgumentAcceptingOptionSpec<V> extends AbstractOptionSpec<V> {
- private static final char NIL_VALUE_SEPARATOR = '\u0000';
-
- private boolean optionRequired;
- private final boolean argumentRequired;
- private ValueConverter<V> converter;
- private String argumentDescription = "";
- private String valueSeparator = String.valueOf( NIL_VALUE_SEPARATOR );
- private final List<V> defaultValues = new ArrayList<V>();
-
- ArgumentAcceptingOptionSpec( String option, boolean argumentRequired ) {
- super( option );
-
- this.argumentRequired = argumentRequired;
- }
-
- ArgumentAcceptingOptionSpec( Collection<String> options, boolean argumentRequired, String description ) {
- super( options, description );
-
- this.argumentRequired = argumentRequired;
- }
-
- /**
- * <p>Specifies a type to which arguments of this spec's option are to be converted.</p>
- *
- * <p>JOpt Simple accepts types that have either:</p>
- *
- * <ol>
- * <li>a public static method called {@code valueOf} which accepts a single argument of type {@link String}
- * and whose return type is the same as the class on which the method is declared. The {@code java.lang}
- * primitive wrapper classes have such methods.</li>
- *
- * <li>a public constructor which accepts a single argument of type {@link String}.</li>
- * </ol>
- *
- * <p>This class converts arguments using those methods in that order; that is, {@code valueOf} would be invoked
- * before a one-{@link String}-arg constructor would.</p>
- *
- * <p>Invoking this method will trump any previous calls to this method or to
- * {@link #withValuesConvertedBy(ValueConverter)}.
- *
- * @param <T> represents the runtime class of the desired option argument type
- * @param argumentType desired type of arguments to this spec's option
- * @return self, so that the caller can add clauses to the fluent interface sentence
- * @throws NullPointerException if the type is {@code null}
- * @throws IllegalArgumentException if the type does not have the standard conversion methods
- */
- public final <T> ArgumentAcceptingOptionSpec<T> ofType( Class<T> argumentType ) {
- return withValuesConvertedBy( findConverter( argumentType ) );
- }
-
- /**
- * <p>Specifies a converter to use to translate arguments of this spec's option into Java objects. This is useful
- * when converting to types that do not have the requisite factory method or constructor for
- * {@link #ofType(Class)}.</p>
- *
- * <p>Invoking this method will trump any previous calls to this method or to {@link #ofType(Class)}.
- *
- * @param <T> represents the runtime class of the desired option argument type
- * @param aConverter the converter to use
- * @return self, so that the caller can add clauses to the fluent interface sentence
- * @throws NullPointerException if the converter is {@code null}
- */
- @SuppressWarnings( "unchecked" )
- public final <T> ArgumentAcceptingOptionSpec<T> withValuesConvertedBy( ValueConverter<T> aConverter ) {
- if ( aConverter == null )
- throw new NullPointerException( "illegal null converter" );
-
- converter = (ValueConverter<V>) aConverter;
- return (ArgumentAcceptingOptionSpec<T>) this;
- }
-
- /**
- * <p>Specifies a description for the argument of the option that this spec represents. This description is used
- * when generating help information about the parser.</p>
- *
- * @param description describes the nature of the argument of this spec's option
- * @return self, so that the caller can add clauses to the fluent interface sentence
- */
- public final ArgumentAcceptingOptionSpec<V> describedAs( String description ) {
- argumentDescription = description;
- return this;
- }
-
- /**
- * <p>Specifies a value separator for the argument of the option that this spec represents. This allows a single
- * option argument to represent multiple values for the option. For example:</p>
- *
- * <pre>
- * <code>
- * parser.accepts( "z" ).withRequiredArg()
- * .<strong>withValuesSeparatedBy( ',' )</strong>;
- * OptionSet options = parser.parse( new String[] { "-z", "foo,bar,baz", "-z",
- * "fizz", "-z", "buzz" } );
- * </code>
- * </pre>
- *
- * <p>Then {@code options.valuesOf( "z" )} would yield the list {@code [foo, bar, baz, fizz, buzz]}.</p>
- *
- * <p>You cannot use Unicode U+0000 as the separator.</p>
- *
- * @param separator a character separator
- * @return self, so that the caller can add clauses to the fluent interface sentence
- * @throws IllegalArgumentException if the separator is Unicode U+0000
- */
- public final ArgumentAcceptingOptionSpec<V> withValuesSeparatedBy( char separator ) {
- if ( separator == NIL_VALUE_SEPARATOR )
- throw new IllegalArgumentException( "cannot use U+0000 as separator" );
-
- valueSeparator = String.valueOf( separator );
- return this;
- }
-
- /**
- * <p>Specifies a value separator for the argument of the option that this spec represents. This allows a single
- * option argument to represent multiple values for the option. For example:</p>
- *
- * <pre>
- * <code>
- * parser.accepts( "z" ).withRequiredArg()
- * .<strong>withValuesSeparatedBy( ":::" )</strong>;
- * OptionSet options = parser.parse( new String[] { "-z", "foo:::bar:::baz", "-z",
- * "fizz", "-z", "buzz" } );
- * </code>
- * </pre>
- *
- * <p>Then {@code options.valuesOf( "z" )} would yield the list {@code [foo, bar, baz, fizz, buzz]}.</p>
- *
- * <p>You cannot use Unicode U+0000 in the separator.</p>
- *
- * @param separator a string separator
- * @return self, so that the caller can add clauses to the fluent interface sentence
- * @throws IllegalArgumentException if the separator contains Unicode U+0000
- */
- public final ArgumentAcceptingOptionSpec<V> withValuesSeparatedBy( String separator ) {
- if ( separator.indexOf( NIL_VALUE_SEPARATOR ) != -1 )
- throw new IllegalArgumentException( "cannot use U+0000 in separator" );
-
- valueSeparator = separator;
- return this;
- }
-
- /**
- * Specifies a set of default values for the argument of the option that this spec represents.
- *
- * @param value the first in the set of default argument values for this spec's option
- * @param values the (optional) remainder of the set of default argument values for this spec's option
- * @return self, so that the caller can add clauses to the fluent interface sentence
- * @throws NullPointerException if {@code value}, {@code values}, or any elements of {@code values} are
- * {@code null}
- */
- public ArgumentAcceptingOptionSpec<V> defaultsTo( V value, V... values ) {
- addDefaultValue( value );
- defaultsTo( values );
-
- return this;
- }
-
- /**
- * Specifies a set of default values for the argument of the option that this spec represents.
- *
- * @param values the set of default argument values for this spec's option
- * @return self, so that the caller can add clauses to the fluent interface sentence
- * @throws NullPointerException if {@code values} or any elements of {@code values} are {@code null}
- */
- public ArgumentAcceptingOptionSpec<V> defaultsTo( V[] values ) {
- for ( V each : values )
- addDefaultValue( each );
-
- return this;
- }
-
- /**
- * Marks this option as required. An {@link OptionException} will be thrown when
- * {@link OptionParser#parse(java.lang.String...)} is called, if an option is marked as required and not specified
- * on the command line.
- *
- * @return self, so that the caller can add clauses to the fluent interface sentence
- */
- public ArgumentAcceptingOptionSpec<V> required() {
- optionRequired = true;
- return this;
- }
-
- public boolean isRequired() {
- return optionRequired;
- }
-
- private void addDefaultValue( V value ) {
- ensureNotNull( value );
- defaultValues.add( value );
- }
-
- @Override
- final void handleOption( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions,
- String detectedArgument ) {
-
- if ( isNullOrEmpty( detectedArgument ) )
- detectOptionArgument( parser, arguments, detectedOptions );
- else
- addArguments( detectedOptions, detectedArgument );
- }
-
- protected void addArguments( OptionSet detectedOptions, String detectedArgument ) {
- StringTokenizer lexer = new StringTokenizer( detectedArgument, valueSeparator );
- if ( !lexer.hasMoreTokens() )
- detectedOptions.addWithArgument( this, detectedArgument );
- else {
- while ( lexer.hasMoreTokens() )
- detectedOptions.addWithArgument( this, lexer.nextToken() );
- }
- }
-
- protected abstract void detectOptionArgument( OptionParser parser, ArgumentList arguments,
- OptionSet detectedOptions );
-
- @SuppressWarnings( "unchecked" )
- @Override
- protected final V convert( String argument ) {
- if ( converter == null )
- return (V) argument;
-
- try {
- return converter.convert( argument );
- }
- catch ( ReflectionException ex ) {
- throw new OptionArgumentConversionException( options(), argument, converter.valueType(), ex );
- }
- catch ( ValueConversionException ex ) {
- throw new OptionArgumentConversionException( options(), argument, converter.valueType(), ex );
- }
- }
-
- protected boolean canConvertArgument( String argument ) {
- StringTokenizer lexer = new StringTokenizer( argument, valueSeparator );
-
- try {
- while ( lexer.hasMoreTokens() )
- convert( lexer.nextToken() );
- return true;
- }
- catch ( OptionException ignored ) {
- return false;
- }
- }
-
- protected boolean isArgumentOfNumberType() {
- return converter != null && Number.class.isAssignableFrom( converter.valueType() );
- }
-
- public boolean acceptsArguments() {
- return true;
- }
-
- public boolean requiresArgument() {
- return argumentRequired;
- }
-
- public String argumentDescription() {
- return argumentDescription;
- }
-
- public String argumentTypeIndicator() {
- if ( converter == null )
- return null;
-
- String pattern = converter.valuePattern();
- return pattern == null ? converter.valueType().getName() : pattern;
- }
-
- public List<V> defaultValues() {
- return unmodifiableList( defaultValues );
- }
-
- @Override
- public boolean equals( Object that ) {
- if ( !super.equals( that ) )
- return false;
-
- ArgumentAcceptingOptionSpec<?> other = (ArgumentAcceptingOptionSpec<?>) that;
- return requiresArgument() == other.requiresArgument();
- }
-
- @Override
- public int hashCode() {
- return super.hashCode() ^ ( argumentRequired ? 0 : 1 );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1c5ba141/geode-joptsimple/src/main/java/joptsimple/ArgumentList.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/ArgumentList.java b/geode-joptsimple/src/main/java/joptsimple/ArgumentList.java
deleted file mode 100644
index 3e7c547..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/ArgumentList.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- The MIT License
-
- Copyright (c) 2004-2011 Paul R. Holser, Jr.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-package joptsimple;
-
-import static joptsimple.ParserRules.*;
-
-/**
- * <p>Wrapper for an array of command line arguments.</p>
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-class ArgumentList {
- private final String[] arguments;
- private int currentIndex;
-
- ArgumentList( String... arguments ) {
- this.arguments = arguments.clone();
- }
-
- boolean hasMore() {
- return currentIndex < arguments.length;
- }
-
- String next() {
- return arguments[ currentIndex++ ];
- }
-
- String peek() {
- return arguments[ currentIndex ];
- }
-
- void treatNextAsLongOption() {
- if ( HYPHEN_CHAR != arguments[ currentIndex ].charAt( 0 ) )
- arguments[ currentIndex ] = DOUBLE_HYPHEN + arguments[ currentIndex ];
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1c5ba141/geode-joptsimple/src/main/java/joptsimple/BuiltinHelpFormatter.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/BuiltinHelpFormatter.java b/geode-joptsimple/src/main/java/joptsimple/BuiltinHelpFormatter.java
deleted file mode 100644
index 134d6e0..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/BuiltinHelpFormatter.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- The MIT License
-
- Copyright (c) 2004-2011 Paul R. Holser, Jr.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-package joptsimple;
-
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-import joptsimple.internal.ColumnarData;
-
-import static joptsimple.ParserRules.*;
-import static joptsimple.internal.Classes.*;
-import static joptsimple.internal.Strings.*;
-
-
-
-/**
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-class BuiltinHelpFormatter implements HelpFormatter {
- private ColumnarData grid;
-
- public String format( Map<String, ? extends OptionDescriptor> options ) {
- if ( options.isEmpty() )
- return "No options specified";
-
- grid = new ColumnarData( optionHeader( options ), "Description" );
-
- Comparator<OptionDescriptor> comparator =
- new Comparator<OptionDescriptor>() {
- public int compare( OptionDescriptor first, OptionDescriptor second ) {
- return first.options().iterator().next().compareTo( second.options().iterator().next() );
- }
- };
-
- Set<OptionDescriptor> sorted = new TreeSet<OptionDescriptor>( comparator );
- sorted.addAll( options.values() );
-
- for ( OptionDescriptor each : sorted )
- addHelpLineFor( each );
-
- return grid.format();
- }
-
- private String optionHeader( Map<String, ? extends OptionDescriptor> options ) {
- for ( OptionDescriptor each : options.values() ) {
- if ( each.isRequired() )
- return "Option (* = required)";
- }
-
- return "Option";
- }
-
- private void addHelpLineFor( OptionDescriptor descriptor ) {
- if ( descriptor.acceptsArguments() ) {
- if ( descriptor.requiresArgument() )
- addHelpLineWithArgument( descriptor, '<', '>' );
- else
- addHelpLineWithArgument( descriptor, '[', ']' );
- } else {
- addHelpLineFor( descriptor, "" );
- }
- }
-
- void addHelpLineFor( OptionDescriptor descriptor, String additionalInfo ) {
- grid.addRow( createOptionDisplay( descriptor ) + additionalInfo, createDescriptionDisplay( descriptor ) );
- }
-
- private void addHelpLineWithArgument( OptionDescriptor descriptor, char begin, char end ) {
- String argDescription = descriptor.argumentDescription();
- String typeIndicator = typeIndicator( descriptor );
- StringBuilder collector = new StringBuilder();
-
- if ( typeIndicator.length() > 0 ) {
- collector.append( typeIndicator );
-
- if ( argDescription.length() > 0 )
- collector.append( ": " ).append( argDescription );
- }
- else if ( argDescription.length() > 0 )
- collector.append( argDescription );
-
- String helpLine = collector.length() == 0
- ? ""
- : ' ' + surround( collector.toString(), begin, end );
- addHelpLineFor( descriptor, helpLine );
- }
-
- private String createOptionDisplay( OptionDescriptor descriptor ) {
- StringBuilder buffer = new StringBuilder( descriptor.isRequired() ? "* " : "" );
-
- for ( Iterator<String> iter = descriptor.options().iterator(); iter.hasNext(); ) {
- String option = iter.next();
- buffer.append( option.length() > 1 ? DOUBLE_HYPHEN : HYPHEN );
- buffer.append( option );
-
- if ( iter.hasNext() )
- buffer.append( ", " );
- }
-
- return buffer.toString();
- }
-
- private String createDescriptionDisplay( OptionDescriptor descriptor ) {
- List<?> defaultValues = descriptor.defaultValues();
- if ( defaultValues.isEmpty() )
- return descriptor.description();
-
- String defaultValuesDisplay = createDefaultValuesDisplay( defaultValues );
- return descriptor.description() + ' ' + surround( "default: " + defaultValuesDisplay, '(', ')' );
- }
-
- private String createDefaultValuesDisplay( List<?> defaultValues ) {
- return defaultValues.size() == 1 ? defaultValues.get( 0 ).toString() : defaultValues.toString();
- }
-
- private static String typeIndicator( OptionDescriptor descriptor ) {
- String indicator = descriptor.argumentTypeIndicator();
- return indicator == null || String.class.getName().equals( indicator )
- ? ""
- : shortNameOf( indicator );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1c5ba141/geode-joptsimple/src/main/java/joptsimple/HelpFormatter.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/HelpFormatter.java b/geode-joptsimple/src/main/java/joptsimple/HelpFormatter.java
deleted file mode 100644
index e685ddc..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/HelpFormatter.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- The MIT License
-
- Copyright (c) 2004-2011 Paul R. Holser, Jr.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-package joptsimple;
-
-import java.util.Map;
-
-/**
- * <p>Represents objects charged with taking a set of option descriptions and producing some help text from them.</p>
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-public interface HelpFormatter {
- /**
- * Produces help text, given a set of option descriptors.
- *
- * @param options descriptors for the configured options of a parser
- * @return text to be used as help
- * @see OptionParser#printHelpOn(java.io.Writer)
- * @see OptionParser#formatHelpWith(HelpFormatter)
- */
- String format( Map<String, ? extends OptionDescriptor> options );
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1c5ba141/geode-joptsimple/src/main/java/joptsimple/IllegalOptionSpecificationException.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/IllegalOptionSpecificationException.java b/geode-joptsimple/src/main/java/joptsimple/IllegalOptionSpecificationException.java
deleted file mode 100644
index 2568e25..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/IllegalOptionSpecificationException.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- The MIT License
-
- Copyright (c) 2004-2011 Paul R. Holser, Jr.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-package joptsimple;
-
-import static java.util.Collections.*;
-
-/**
- * Thrown when the option parser is asked to recognize an option with illegal characters in it.
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- * @author Nikhil Jadhav
- */
-public class IllegalOptionSpecificationException extends OptionException {
- private static final long serialVersionUID = -1L;
-
- IllegalOptionSpecificationException( String option ) {
- super( singletonList( option ) );
- }
-
- // GemFire Addition: Added to include OptionSet
- IllegalOptionSpecificationException( String option, OptionSet detected ) {
- super( singletonList( option ), detected );
- }
-
- @Override
- public String getMessage() {
- return singleOptionMessage() + " is not a legal option character";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1c5ba141/geode-joptsimple/src/main/java/joptsimple/MissingRequiredOptionException.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/MissingRequiredOptionException.java b/geode-joptsimple/src/main/java/joptsimple/MissingRequiredOptionException.java
deleted file mode 100644
index eb3cc04..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/MissingRequiredOptionException.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- The MIT License
-
- Copyright (c) 2004-2011 Paul R. Holser, Jr.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-package joptsimple;
-
-import java.util.Collection;
-
-/**
- * Thrown when an option is marked as required, but not specified on the command line.
- *
- * @author <a href="https://github.com/TC1">Emils Solmanis</a>
- * @author Nikhil Jadhav
- */
-public class MissingRequiredOptionException extends OptionException {
- private static final long serialVersionUID = -1L;
-
- protected MissingRequiredOptionException( Collection<String> options ) {
- super( options );
- }
-
- // GemFire Addition: Added to include OptionSet
- MissingRequiredOptionException( Collection<String> options, OptionSet detected ) {
- super( options, detected );
- }
-
- @Override
- public String getMessage() {
- return "Missing required option " + multipleOptionMessage();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1c5ba141/geode-joptsimple/src/main/java/joptsimple/MultipleArgumentsForOptionException.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/MultipleArgumentsForOptionException.java b/geode-joptsimple/src/main/java/joptsimple/MultipleArgumentsForOptionException.java
deleted file mode 100644
index 0aae386..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/MultipleArgumentsForOptionException.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- The MIT License
-
- Copyright (c) 2004-2011 Paul R. Holser, Jr.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-package joptsimple;
-
-import java.util.Collection;
-
-/**
- * Thrown when asking an {@link OptionSet} for a single argument of an option when many have been specified.
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- * @author Nikhil Jadhav
- */
-public class MultipleArgumentsForOptionException extends OptionException {
- private static final long serialVersionUID = -1L;
-
- MultipleArgumentsForOptionException( Collection<String> options ) {
- super( options );
- }
-
- // GemFire Addition: Added to include OptionSet
- public MultipleArgumentsForOptionException( Collection<String> options, OptionSet detected ) {
- super( options, detected );
- }
-
- @Override
- public String getMessage() {
- return "Found multiple arguments for option " + multipleOptionMessage() + ", but you asked for only one";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1c5ba141/geode-joptsimple/src/main/java/joptsimple/NoArgumentOptionSpec.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/NoArgumentOptionSpec.java b/geode-joptsimple/src/main/java/joptsimple/NoArgumentOptionSpec.java
deleted file mode 100644
index 0d443e5..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/NoArgumentOptionSpec.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- The MIT License
-
- Copyright (c) 2004-2011 Paul R. Holser, Jr.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-package joptsimple;
-
-import java.util.Collection;
-import java.util.List;
-
-import static java.util.Collections.*;
-
-/**
- * A specification for an option that does not accept arguments.
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-class NoArgumentOptionSpec extends AbstractOptionSpec<Void> {
- NoArgumentOptionSpec( String option ) {
- this( singletonList( option ), "" );
- }
-
- NoArgumentOptionSpec( Collection<String> options, String description ) {
- super( options, description );
- }
-
- @Override
- void handleOption( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions,
- String detectedArgument ) {
-
- detectedOptions.add( this );
- }
-
- public boolean acceptsArguments() {
- return false;
- }
-
- public boolean requiresArgument() {
- return false;
- }
-
- public boolean isRequired() {
- return false;
- }
-
- public String argumentDescription() {
- return "";
- }
-
- public String argumentTypeIndicator() {
- return "";
- }
-
- @Override
- protected Void convert( String argument ) {
- return null;
- }
-
- public List<Void> defaultValues() {
- return emptyList();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1c5ba141/geode-joptsimple/src/main/java/joptsimple/OptionArgumentConversionException.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/OptionArgumentConversionException.java b/geode-joptsimple/src/main/java/joptsimple/OptionArgumentConversionException.java
deleted file mode 100644
index bcc6dcd..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/OptionArgumentConversionException.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- The MIT License
-
- Copyright (c) 2004-2011 Paul R. Holser, Jr.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-package joptsimple;
-
-import java.util.Collection;
-
-/**
- * Thrown when a problem occurs converting an argument of an option from {@link String} to another type.
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- * @author Nikhil Jadhav
- */
-public class OptionArgumentConversionException extends OptionException {
- private static final long serialVersionUID = -1L;
-
- private final String argument;
- private final Class<?> valueType;
-
- OptionArgumentConversionException( Collection<String> options, String argument, Class<?> valueType,
- Throwable cause ) {
-
- super( options, cause );
-
- this.argument = argument;
- this.valueType = valueType;
- }
-
- // GemFire Addition: Added to include OptionSet
- public OptionArgumentConversionException( Collection<String> options, String argument, Class<?> valueType,
- OptionSet detected, Throwable cause ) {
- super( options, detected );
- this.argument = argument;
- this.valueType = valueType;
- }
-
- @Override
- public String getMessage() {
- return "Cannot convert argument '" + argument + "' of option " + multipleOptionMessage() + " to " + valueType;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1c5ba141/geode-joptsimple/src/main/java/joptsimple/OptionDescriptor.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/OptionDescriptor.java b/geode-joptsimple/src/main/java/joptsimple/OptionDescriptor.java
deleted file mode 100644
index 98a39b1..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/OptionDescriptor.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- The MIT License
-
- Copyright (c) 2004-2011 Paul R. Holser, Jr.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-package joptsimple;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Describes options that an option parser recognizes, in ways that might be useful to {@linkplain HelpFormatter
- * help screens}.
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-public interface OptionDescriptor {
- /**
- * A set of options that are mutually synonymous.
- *
- * @return synonymous options
- */
- Collection<String> options();
-
- /**
- * Description of this option's purpose.
- *
- * @return a description for the option
- */
- String description();
-
- /**
- * What values will the option take if none are specified on the command line?
- *
- * @return any default values for the option
- */
- List<?> defaultValues();
-
- /**
- * Is this option {@linkplain ArgumentAcceptingOptionSpec#required() required} on a command line?
- *
- * @return whether the option is required
- */
- boolean isRequired();
-
- /**
- * Does this option {@linkplain ArgumentAcceptingOptionSpec accept arguments}?
- *
- * @return whether the option accepts arguments
- */
- boolean acceptsArguments();
-
- /**
- * Does this option {@linkplain OptionSpecBuilder#withRequiredArg() require an argument}?
- *
- * @return whether the option requires an argument
- */
- boolean requiresArgument();
-
- /**
- * Gives a short {@linkplain ArgumentAcceptingOptionSpec#describedAs(String) description} of the option's argument.
- *
- * @return a description for the option's argument
- */
- String argumentDescription();
-
- /**
- * Gives an indication of the {@linkplain ArgumentAcceptingOptionSpec#ofType(Class) expected type} of the option's
- * argument.
- *
- * @return a description for the option's argument type
- */
- String argumentTypeIndicator();
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1c5ba141/geode-joptsimple/src/main/java/joptsimple/OptionException.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/OptionException.java b/geode-joptsimple/src/main/java/joptsimple/OptionException.java
deleted file mode 100644
index 1937fd4..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/OptionException.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- The MIT License
-
- Copyright (c) 2004-2011 Paul R. Holser, Jr.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-package joptsimple;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import static java.util.Collections.*;
-
-import static joptsimple.internal.Strings.*;
-
-
-/**
- * Thrown when a problem occurs during option parsing.
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- * @author Nikhil Jadhav
- */
-public abstract class OptionException extends RuntimeException {
- private static final long serialVersionUID = -1L;
-
- // GemFire Addition: To store detected option before OptionException
- private OptionSet detected;
-
- private final List<String> options = new ArrayList<String>();
-
- protected OptionException( Collection<String> options ) {
- this.options.addAll( options );
- }
-
- protected OptionException( Collection<String> options, Throwable cause ) {
- super( cause );
-
- this.options.addAll( options );
- }
-
- // GemFire Addition: Added setting OptionSet detected so far
- protected OptionException(Collection<String> options, OptionSet detected) {
- this.options.addAll(options);
- this.detected = detected;
- }
-
- /**
- * Gives the option being considered when the exception was created.
- *
- * @return the option being considered when the exception was created
- */
- public Collection<String> options() {
- return unmodifiableCollection( options );
- }
-
- protected final String singleOptionMessage() {
- return singleOptionMessage( options.get( 0 ) );
- }
-
- protected final String singleOptionMessage( String option ) {
- return SINGLE_QUOTE + option + SINGLE_QUOTE;
- }
-
- protected final String multipleOptionMessage() {
- StringBuilder buffer = new StringBuilder( "[" );
-
- for ( Iterator<String> iter = options.iterator(); iter.hasNext(); ) {
- buffer.append( singleOptionMessage( iter.next() ) );
- if ( iter.hasNext() )
- buffer.append( ", " );
- }
-
- buffer.append( ']' );
-
- return buffer.toString();
- }
-
- // GemFire Addition: Added to include OptionSet
- public static OptionException createUnrecognizedOptionException( String option, OptionSet detected ) {
- return new UnrecognizedOptionException( option, detected );
- }
-
- // GemFire Addition: Added to get the detected OptionSet
- /**
- * @return the detected OptionSet
- */
- public OptionSet getDetected() {
- return detected;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1c5ba141/geode-joptsimple/src/main/java/joptsimple/OptionMissingRequiredArgumentException.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/OptionMissingRequiredArgumentException.java b/geode-joptsimple/src/main/java/joptsimple/OptionMissingRequiredArgumentException.java
deleted file mode 100644
index 556536f..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/OptionMissingRequiredArgumentException.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- The MIT License
-
- Copyright (c) 2004-2011 Paul R. Holser, Jr.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-package joptsimple;
-
-import java.util.Collection;
-
-/**
- * Thrown when the option parser discovers an option that requires an argument, but that argument is missing.
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- * @author Nikhil Jadhav
- */
-public class OptionMissingRequiredArgumentException extends OptionException {
- private static final long serialVersionUID = -1L;
-
- OptionMissingRequiredArgumentException( Collection<String> options ) {
- super( options );
- }
-
- // GemFire Addition: Added to include OptionSet
- OptionMissingRequiredArgumentException( Collection<String> options, OptionSet detected ) {
- super( options, detected );
- }
-
- @Override
- public String getMessage() {
- return "Option " + multipleOptionMessage() + " requires an argument";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1c5ba141/geode-joptsimple/src/main/java/joptsimple/OptionParser.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/OptionParser.java b/geode-joptsimple/src/main/java/joptsimple/OptionParser.java
deleted file mode 100644
index 24165b8..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/OptionParser.java
+++ /dev/null
@@ -1,568 +0,0 @@
-/*
- The MIT License
-
- Copyright (c) 2004-2011 Paul R. Holser, Jr.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-package joptsimple;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
-import joptsimple.internal.AbbreviationMap;
-import joptsimple.util.KeyValuePair;
-
-import static java.util.Collections.*;
-
-import static joptsimple.OptionException.*;
-import static joptsimple.OptionParserState.*;
-import static joptsimple.ParserRules.*;
-
-
-
-/**
- * <p>Parses command line arguments, using a syntax that attempts to take from the best of POSIX {@code getopt()}
- * and GNU {@code getopt_long()}.</p>
- *
- * <p>This parser supports short options and long options.</p>
- *
- * <ul>
- * <li><dfn>Short options</dfn> begin with a single hyphen ("<kbd>-</kbd>") followed by a single letter or digit,
- * or question mark ("<kbd>?</kbd>"), or dot ("<kbd>.</kbd>").</li>
- *
- * <li>Short options can accept single arguments. The argument can be made required or optional. The option's
- * argument can occur:
- * <ul>
- * <li>in the slot after the option, as in <kbd>-d /tmp</kbd></li>
- * <li>right up against the option, as in <kbd>-d/tmp</kbd></li>
- * <li>right up against the option separated by an equals sign (<kbd>"="</kbd>), as in <kbd>-d=/tmp</kbd></li>
- * </ul>
- * To specify <em>n</em> arguments for an option, specify the option <em>n</em> times, once for each argument,
- * as in <kbd>-d /tmp -d /var -d /opt</kbd>; or, when using the
- * {@linkplain ArgumentAcceptingOptionSpec#withValuesSeparatedBy(char) "separated values"} clause of the "fluent
- * interface" (see below), give multiple values separated by a given character as a single argument to the
- * option.</li>
- *
- * <li>Short options can be clustered, so that <kbd>-abc</kbd> is treated as <kbd>-a -b -c</kbd>. If a short option
- * in the cluster can accept an argument, the remaining characters are interpreted as the argument for that
- * option.</li>
- *
- * <li>An argument consisting only of two hyphens (<kbd>"--"</kbd>) signals that the remaining arguments are to be
- * treated as non-options.</li>
- *
- * <li>An argument consisting only of a single hyphen is considered a non-option argument (though it can be an
- * argument of an option). Many Unix programs treat single hyphens as stand-ins for the standard input or standard
- * output streams.</li>
- *
- * <li><dfn>Long options</dfn> begin with two hyphens (<kbd>"--"</kbd>), followed by multiple letters, digits,
- * hyphens, question marks, or dots. A hyphen cannot be the first character of a long option specification when
- * configuring the parser.</li>
- *
- * <li>You can abbreviate long options, so long as the abbreviation is unique.</li>
- *
- * <li>Long options can accept single arguments. The argument can be made required or optional. The option's
- * argument can occur:
- * <ul>
- * <li>in the slot after the option, as in <kbd>--directory /tmp</kbd></li>
- * <li>right up against the option separated by an equals sign (<kbd>"="</kbd>), as in
- * <kbd>--directory=/tmp</kbd>
- * </ul>
- * Specify multiple arguments for a long option in the same manner as for short options (see above).</li>
- *
- * <li>You can use a single hyphen (<kbd>"-"</kbd>) instead of a double hyphen (<kbd>"--"</kbd>) for a long
- * option.</li>
- *
- * <li>The option <kbd>-W</kbd> is reserved. If you tell the parser to {@linkplain
- * #recognizeAlternativeLongOptions(boolean) recognize alternative long options}, then it will treat, for example,
- * <kbd>-W foo=bar</kbd> as the long option <kbd>foo</kbd> with argument <kbd>bar</kbd>, as though you had written
- * <kbd>--foo=bar</kbd>.</li>
- *
- * <li>You can specify <kbd>-W</kbd> as a valid short option, or use it as an abbreviation for a long option, but
- * {@linkplain #recognizeAlternativeLongOptions(boolean) recognizing alternative long options} will always supersede
- * this behavior.</li>
- *
- * <li>You can specify a given short or long option multiple times on a single command line. The parser collects
- * any arguments specified for those options as a list.</li>
- *
- * <li>If the parser detects an option whose argument is optional, and the next argument "looks like" an option,
- * that argument is not treated as the argument to the option, but as a potentially valid option. If, on the other
- * hand, the optional argument is typed as a derivative of {@link Number}, then that argument is treated as the
- * negative number argument of the option, even if the parser recognizes the corresponding numeric option.
- * For example:
- * <pre><code>
- * OptionParser parser = new OptionParser();
- * parser.accepts( "a" ).withOptionalArg().ofType( Integer.class );
- * parser.accepts( "2" );
- * OptionSet options = parser.parse( "-a", "-2" );
- * </code></pre>
- * In this case, the option set contains <kbd>"a"</kbd> with argument <kbd>-2</kbd>, not both <kbd>"a"</kbd> and
- * <kbd>"2"</kbd>. Swapping the elements in the <em>args</em> array gives the latter.</li>
- * </ul>
- *
- * <p>There are two ways to tell the parser what options to recognize:</p>
- *
- * <ol>
- * <li>A "fluent interface"-style API for specifying options, available since version 2. Sentences in this fluent
- * interface language begin with a call to {@link #accepts(String) accepts} or {@link #acceptsAll(Collection)
- * acceptsAll} methods; calls on the ensuing chain of objects describe whether the options can take an argument,
- * whether the argument is required or optional, to what type arguments of the options should be converted if any,
- * etc. Since version 3, these calls return an instance of {@link OptionSpec}, which can subsequently be used to
- * retrieve the arguments of the associated option in a type-safe manner.</li>
- *
- * <li>Since version 1, a more concise way of specifying short options has been to use the special {@linkplain
- * #OptionParser(String) constructor}. Arguments of options specified in this manner will be of type {@link String}.
- * Here are the rules for the format of the specification strings this constructor accepts:
- *
- * <ul>
- * <li>Any letter or digit is treated as an option character.</li>
- *
- * <li>An option character can be immediately followed by an asterisk (*) to indicate that the option is a
- * "help" option.</li>
- *
- * <li>If an option character (with possible trailing asterisk) is followed by a single colon (<kbd>":"</kbd>),
- * then the option requires an argument.</li>
- *
- * <li>If an option character (with possible trailing asterisk) is followed by two colons (<kbd>"::"</kbd>),
- * then the option accepts an optional argument.</li>
- *
- * <li>Otherwise, the option character accepts no argument.</li>
- *
- * <li>If the option specification string begins with a plus sign (<kbd>"+"</kbd>), the parser will behave
- * "POSIX-ly correct".</li>
- *
- * <li>If the option specification string contains the sequence <kbd>"W;"</kbd> (capital W followed by a
- * semicolon), the parser will recognize the alternative form of long options.</li>
- * </ul>
- * </li>
- * </ol>
- *
- * <p>Each of the options in a list of options given to {@link #acceptsAll(Collection) acceptsAll} is treated as a
- * synonym of the others. For example:
- * <pre>
- * <code>
- * OptionParser parser = new OptionParser();
- * parser.acceptsAll( asList( "w", "interactive", "confirmation" ) );
- * OptionSet options = parser.parse( "-w" );
- * </code>
- * </pre>
- * In this case, <code>options.{@link OptionSet#has(String) has}</code> would answer {@code true} when given arguments
- * <kbd>"w"</kbd>, <kbd>"interactive"</kbd>, and <kbd>"confirmation"</kbd>. The {@link OptionSet} would give the same
- * responses to these arguments for its other methods as well.</p>
- *
- * <p>By default, as with GNU {@code getopt()}, the parser allows intermixing of options and non-options. If, however,
- * the parser has been created to be "POSIX-ly correct", then the first argument that does not look lexically like an
- * option, and is not a required argument of a preceding option, signals the end of options. You can still bind
- * optional arguments to their options using the abutting (for short options) or <kbd>=</kbd> syntax.</p>
- *
- * <p>Unlike GNU {@code getopt()}, this parser does not honor the environment variable {@code POSIXLY_CORRECT}.
- * "POSIX-ly correct" parsers are configured by either:</p>
- *
- * <ol>
- * <li>using the method {@link #posixlyCorrect(boolean)}, or</li>
- *
- * <li>using the {@linkplain #OptionParser(String) constructor} with an argument whose first character is a plus sign
- * (<kbd>"+"</kbd>)</li>
- * </ol>
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- * @author Nikhil Jadhav
- * @see <a href="http://www.gnu.org/software/libc/manual">The GNU C Library</a>
- */
-public class OptionParser {
-
- // GemFire Addition: to disable short option support
- private boolean isShortOptionDisabled = false;
-
- private final AbbreviationMap<AbstractOptionSpec<?>> recognizedOptions;
- private OptionParserState state;
- private boolean posixlyCorrect;
- private HelpFormatter helpFormatter = new BuiltinHelpFormatter();
-
- /**
- * Creates an option parser that initially recognizes no options, and does not exhibit "POSIX-ly correct"
- * behavior.
- */
- public OptionParser() {
- recognizedOptions = new AbbreviationMap<AbstractOptionSpec<?>>();
- state = moreOptions( false );
- }
-
- /**
- * Creates an option parser and configures it to recognize the short options specified in the given string.
- *
- * Arguments of options specified this way will be of type {@link String}.
- *
- * @param optionSpecification an option specification
- * @throws NullPointerException if {@code optionSpecification} is {@code null}
- * @throws OptionException if the option specification contains illegal characters or otherwise cannot be
- * recognized
- */
- public OptionParser( String optionSpecification ) {
- this();
-
- new OptionSpecTokenizer( optionSpecification ).configure( this );
- }
-
- /**
- * Creates an option parser that initially recognizes no options, and does not exhibit "POSIX-ly correct"
- * behavior.
- *
- * Short options can be enabled with setting disableShortOption to <code>false</code>.
- *
- * @param disableShortOption <code>true</code> to disable short options, <code>false</code> to enable
- */
- public OptionParser( boolean disableShortOption ) {
- this();
- this.isShortOptionDisabled = disableShortOption;
- }
-
- /**
- * Creates an option parser and configures it to recognize the short options specified in the given string.
- *
- * Arguments of options specified this way will be of type {@link String}.
- *
- * Short options can be enabled with setting disableShortOption to <code>false</code>.
- *
- * @param optionSpecification an option specification
- * @param disableShortOption <code>true</code> to disable short options, <code>false</code> to enable those.
- * @throws NullPointerException if {@code optionSpecification} is {@code null}
- * @throws OptionException if the option specification contains illegal characters or otherwise cannot be
- * recognized
- */
- public OptionParser( String optionSpecification, boolean disableShortOption ) {
- this();
-
- new OptionSpecTokenizer( optionSpecification ).configure( this );
- this.isShortOptionDisabled = disableShortOption;
- }
-
- /**
- * <p>Tells the parser to recognize the given option.</p>
- *
- * <p>This method returns an instance of {@link OptionSpecBuilder} to allow the formation of parser directives
- * as sentences in a fluent interface language. For example:</p>
- *
- * <pre><code>
- * OptionParser parser = new OptionParser();
- * parser.<strong>accepts( "c" )</strong>.withRequiredArg().ofType( Integer.class );
- * </code></pre>
- *
- * <p>If no methods are invoked on the returned {@link OptionSpecBuilder}, then the parser treats the option as
- * accepting no argument.</p>
- *
- * @param option the option to recognize
- * @return an object that can be used to flesh out more detail about the option
- * @throws OptionException if the option contains illegal characters
- * @throws NullPointerException if the option is {@code null}
- */
- public OptionSpecBuilder accepts( String option ) {
- return acceptsAll( singletonList( option ) );
- }
-
- /**
- * Tells the parser to recognize the given option.
- *
- * @see #accepts(String)
- * @param option the option to recognize
- * @param description a string that describes the purpose of the option. This is used when generating help
- * information about the parser.
- * @return an object that can be used to flesh out more detail about the option
- * @throws OptionException if the option contains illegal characters
- * @throws NullPointerException if the option is {@code null}
- */
- public OptionSpecBuilder accepts( String option, String description ) {
- return acceptsAll( singletonList( option ), description );
- }
-
- /**
- * Tells the parser to recognize the given options, and treat them as synonymous.
- *
- * @see #accepts(String)
- * @param options the options to recognize and treat as synonymous
- * @return an object that can be used to flesh out more detail about the options
- * @throws OptionException if any of the options contain illegal characters
- * @throws NullPointerException if the option list or any of its elements are {@code null}
- */
- public OptionSpecBuilder acceptsAll( Collection<String> options ) {
- return acceptsAll( options, "" );
- }
-
- /**
- * Tells the parser to recognize the given options, and treat them as synonymous.
- *
- * @see #acceptsAll(Collection)
- * @param options the options to recognize and treat as synonymous
- * @param description a string that describes the purpose of the option. This is used when generating help
- * information about the parser.
- * @return an object that can be used to flesh out more detail about the options
- * @throws OptionException if any of the options contain illegal characters
- * @throws NullPointerException if the option list or any of its elements are {@code null}
- * @throws IllegalArgumentException if the option list is empty
- */
- public OptionSpecBuilder acceptsAll( Collection<String> options, String description ) {
- if ( options.isEmpty() )
- throw new IllegalArgumentException( "need at least one option" );
-
- ensureLegalOptions( options );
-
- return new OptionSpecBuilder( this, options, description );
- }
-
- /**
- * Tells the parser whether or not to behave "POSIX-ly correct"-ly.
- *
- * @param setting {@code true} if the parser should behave "POSIX-ly correct"-ly
- */
- public void posixlyCorrect( boolean setting ) {
- posixlyCorrect = setting;
- state = moreOptions( setting );
- }
-
- boolean posixlyCorrect() {
- return posixlyCorrect;
- }
-
- /**
- * Tells the parser either to recognize or ignore <kbd>"-W"</kbd>-style long options.
- *
- * @param recognize {@code true} if the parser is to recognize the special style of long options
- */
- public void recognizeAlternativeLongOptions( boolean recognize ) {
- if ( recognize )
- recognize( new AlternativeLongOptionSpec() );
- else
- recognizedOptions.remove( String.valueOf( RESERVED_FOR_EXTENSIONS ) );
- }
-
- void recognize( AbstractOptionSpec<?> spec ) {
- recognizedOptions.putAll( spec.options(), spec );
- }
-
- /**
- * Writes information about the options this parser recognizes to the given output sink.
- *
- * The output sink is flushed, but not closed.
- *
- * @param sink the sink to write information to
- * @throws IOException if there is a problem writing to the sink
- * @throws NullPointerException if {@code sink} is {@code null}
- * @see #printHelpOn(Writer)
- */
- public void printHelpOn( OutputStream sink ) throws IOException {
- printHelpOn( new OutputStreamWriter( sink ) );
- }
-
- /**
- * Writes information about the options this parser recognizes to the given output sink.
- *
- * The output sink is flushed, but not closed.
- *
- * @param sink the sink to write information to
- * @throws IOException if there is a problem writing to the sink
- * @throws NullPointerException if {@code sink} is {@code null}
- * @see #printHelpOn(OutputStream)
- */
- public void printHelpOn( Writer sink ) throws IOException {
- sink.write( helpFormatter.format( recognizedOptions.toJavaUtilMap() ) );
- sink.flush();
- }
-
- /**
- * Tells the parser to use the given formatter when asked to {@linkplain #printHelpOn(java.io.Writer) print help}.
- *
- * @param formatter the formatter to use for printing help
- * @throws NullPointerException if the formatter is {@code null}
- */
- public void formatHelpWith( HelpFormatter formatter ) {
- if ( formatter == null )
- throw new NullPointerException();
-
- helpFormatter = formatter;
- }
-
- /**
- * Parses the given command line arguments according to the option specifications given to the parser.
- *
- * @param arguments arguments to parse
- * @return an {@link OptionSet} describing the parsed options, their arguments, and any non-option arguments found
- * @throws OptionException if problems are detected while parsing
- * @throws NullPointerException if the argument list is {@code null}
- */
- public OptionSet parse( String... arguments ) {
- ArgumentList argumentList = new ArgumentList( arguments );
- OptionSet detected = new OptionSet( defaultValues() );
-
- while ( argumentList.hasMore() )
- state.handleArgument( this, argumentList, detected );
-
- reset();
-
- ensureRequiredOptions( detected );
-
- return detected;
- }
-
- private void ensureRequiredOptions( OptionSet options ) {
- Collection<String> missingRequiredOptions = new HashSet<String>();
- for ( AbstractOptionSpec<?> each : recognizedOptions.toJavaUtilMap().values() ) {
- if ( each.isRequired() && !options.has( each ) )
- missingRequiredOptions.addAll( each.options() );
- }
-
- boolean helpOptionPresent = false;
- for ( AbstractOptionSpec<?> each : recognizedOptions.toJavaUtilMap().values() ) {
- if ( each.isForHelp() ) {
- helpOptionPresent = true;
- break;
- }
- }
-
- if ( !missingRequiredOptions.isEmpty() && !helpOptionPresent )
- // GemFire Addition : Add options detected so far
- throw new MissingRequiredOptionException( missingRequiredOptions, options );
- }
-
- void handleLongOptionToken( String candidate, ArgumentList arguments, OptionSet detected ) {
- KeyValuePair optionAndArgument = parseLongOptionWithArgument( candidate );
-
- if ( !isRecognized( optionAndArgument.key ) )
- // GemFire Addition : Add options detected so far
- throw createUnrecognizedOptionException( optionAndArgument.key, detected );
-
- AbstractOptionSpec<?> optionSpec = specFor( optionAndArgument.key );
- optionSpec.handleOption( this, arguments, detected, optionAndArgument.value );
- }
-
- void handleShortOptionToken( String candidate, ArgumentList arguments, OptionSet detected ) {
- KeyValuePair optionAndArgument = parseShortOptionWithArgument( candidate );
-
- if ( isRecognized( optionAndArgument.key ) ) {
- specFor( optionAndArgument.key ).handleOption( this, arguments, detected, optionAndArgument.value );
- }
- else
- handleShortOptionCluster( candidate, arguments, detected );
- }
-
- private void handleShortOptionCluster( String candidate, ArgumentList arguments, OptionSet detected ) {
- char[] options = extractShortOptionsFrom( candidate );
- // GemFire Addition : Add options detected so far
- validateOptionCharacters( options, detected );
-
- for ( int i = 0; i < options.length; i++ ) {
- AbstractOptionSpec<?> optionSpec = specFor( options[ i ] );
-
- if ( optionSpec.acceptsArguments() && options.length > i + 1 ) {
- String detectedArgument = String.valueOf( options, i + 1, options.length - 1 - i );
- optionSpec.handleOption( this, arguments, detected, detectedArgument );
- break;
- }
-
- optionSpec.handleOption( this, arguments, detected, null );
- }
- }
-
- void noMoreOptions() {
- state = OptionParserState.noMoreOptions();
- }
-
- /*
- * GemFire Addition: following comment & changes in method
- * This method has be modified to remove short option support
- *
- * @param argument
- *
- * @return boolean indicating whether it is an option token
- */
- boolean looksLikeAnOption( String argument ) {
- // GemFire Addition: Modified to support Gfsh at runtime
- return ( !isShortOptionDisabled && isShortOptionToken( argument ) ) || isLongOptionToken( argument );
- }
-
- // GemFire Addition: to indicate whether short option support is disabled
- public boolean isShortOptionDisabled() {
- return isShortOptionDisabled;
- }
-
- private boolean isRecognized( String option ) {
- return recognizedOptions.contains( option );
- }
-
- private AbstractOptionSpec<?> specFor( char option ) {
- return specFor( String.valueOf( option ) );
- }
-
- private AbstractOptionSpec<?> specFor( String option ) {
- return recognizedOptions.get( option );
- }
-
- private void reset() {
- state = moreOptions( posixlyCorrect );
- }
-
- private static char[] extractShortOptionsFrom( String argument ) {
- char[] options = new char[ argument.length() - 1 ];
- argument.getChars( 1, argument.length(), options, 0 );
-
- return options;
- }
-
- /*
- * GemFire Addition : following comment & changes in method
- * Method signature has been changed to include the detected options
- *
- * The exception instantiation code has also been changed to take into account the change in expections.
- */
- private void validateOptionCharacters( char[] options, OptionSet detected ) {
- for ( char each : options ) {
- String option = String.valueOf( each );
-
- if ( !isRecognized( option ) )
- // GemFire Addition : Changed to include detected OptionSet
- throw createUnrecognizedOptionException( option, detected );
-
- if ( specFor( option ).acceptsArguments() )
- return;
- }
- }
-
- private static KeyValuePair parseLongOptionWithArgument( String argument ) {
- return KeyValuePair.valueOf( argument.substring( 2 ) );
- }
-
- private static KeyValuePair parseShortOptionWithArgument( String argument ) {
- return KeyValuePair.valueOf( argument.substring( 1 ) );
- }
-
- private Map<String, List<?>> defaultValues() {
- Map<String, List<?>> defaults = new HashMap<String, List<?>>();
- for ( Map.Entry<String, AbstractOptionSpec<?>> each : recognizedOptions.toJavaUtilMap().entrySet() )
- defaults.put( each.getKey(), each.getValue().defaultValues() );
- return defaults;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1c5ba141/geode-joptsimple/src/main/java/joptsimple/OptionParserState.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/OptionParserState.java b/geode-joptsimple/src/main/java/joptsimple/OptionParserState.java
deleted file mode 100644
index 4cda973..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/OptionParserState.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- The MIT License
-
- Copyright (c) 2004-2011 Paul R. Holser, Jr.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-package joptsimple;
-
-import static joptsimple.ParserRules.*;
-
-/**
- * Abstraction of parser state; mostly serves to model how a parser behaves depending on whether end-of-options
- * has been detected.
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- * @author Nikhil Jadhav
- */
-abstract class OptionParserState {
- static OptionParserState noMoreOptions() {
- return new OptionParserState() {
- @Override
- protected void handleArgument( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions ) {
- detectedOptions.addNonOptionArgument( arguments.next() );
- }
- };
- }
-
- /* GemFire Addition : following comment & changes in method
- * This method has been modified to disable short option support and appropriately the case wherein only the option
- * start token is specified.
- */
- static OptionParserState moreOptions( final boolean posixlyCorrect ) {
- return new OptionParserState() {
- @Override
- protected void handleArgument( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions ) {
- String candidate = arguments.next();
- if ( isOptionTerminator( candidate ) )
- parser.noMoreOptions();
- else if ( isLongOptionToken( candidate ) )
- parser.handleLongOptionToken( candidate, arguments, detectedOptions );
- // GemFire Addition : Check for Boolean property at runtime
- else if ( !parser.isShortOptionDisabled() && isShortOptionToken( candidate ) )
- parser.handleShortOptionToken( candidate, arguments, detectedOptions );
- else {
- if ( posixlyCorrect )
- parser.noMoreOptions();
- // Check whether the token is made up of only option start,
- // then we do not have to consider it.
- // GemFire Addition : Modified for Gfsh
- if ( parser.isShortOptionDisabled()
- && ( candidate.equals( "-" ) || candidate.equals( "--" ) ) ) {
- // Do nothing
- } else {
- detectedOptions.addNonOptionArgument( candidate );
- }
- }
- }
- };
- }
-
- protected abstract void handleArgument( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions );
-}