You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ud...@apache.org on 2016/06/16 22:07:19 UTC
[05/17] incubator-geode git commit: GEODE-835: replace
geode-joptsimple with jopt-simple dependency
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/OptionSet.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/OptionSet.java b/geode-joptsimple/src/main/java/joptsimple/OptionSet.java
deleted file mode 100644
index eb0582e..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/OptionSet.java
+++ /dev/null
@@ -1,309 +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.HashMap;
-import java.util.IdentityHashMap;
-import java.util.List;
-import java.util.Map;
-
-import static java.util.Collections.*;
-
-import static joptsimple.internal.Objects.*;
-
-
-/**
- * Representation of a group of detected command line options, their arguments, and non-option arguments.
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-public class OptionSet {
- private final List<OptionSpec<?>> detectedSpecs;
- private final Map<String, AbstractOptionSpec<?>> detectedOptions;
- private final Map<AbstractOptionSpec<?>, List<String>> optionsToArguments;
- private final List<String> nonOptionArguments;
- private final Map<String, List<?>> defaultValues;
-
- /*
- * Package-private because clients don't create these.
- */
- OptionSet( Map<String, List<?>> defaults ) {
- detectedSpecs = new ArrayList<OptionSpec<?>>();
- detectedOptions = new HashMap<String, AbstractOptionSpec<?>>();
- optionsToArguments = new IdentityHashMap<AbstractOptionSpec<?>, List<String>>();
- nonOptionArguments = new ArrayList<String>();
- defaultValues = new HashMap<String, List<?>>( defaults );
- }
-
- /**
- * Tells whether any options were detected.
- *
- * @return {@code true} if any options were detected
- */
- public boolean hasOptions() {
- return !detectedOptions.isEmpty();
- }
-
- /**
- * Tells whether the given option was detected.
- *
- * @param option the option to search for
- * @return {@code true} if the option was detected
- * @see #has(OptionSpec)
- */
- public boolean has( String option ) {
- return detectedOptions.containsKey( option );
- }
-
- /**
- * Tells whether the given option was detected.
- *
- * <p>This method recognizes only instances of options returned from the fluent interface methods.</p>
- *
- * <p>Specifying a {@linkplain ArgumentAcceptingOptionSpec#defaultsTo(Object, Object[])} default argument value}
- * for an option does not cause this method to return {@code true} if the option was not detected on the command
- * line.</p>
- *
- * @param option the option to search for
- * @return {@code true} if the option was detected
- * @see #has(String)
- */
- public boolean has( OptionSpec<?> option ) {
- return optionsToArguments.containsKey( option );
- }
-
- /**
- * Tells whether there are any arguments associated with the given option.
- *
- * @param option the option to search for
- * @return {@code true} if the option was detected and at least one argument was detected for the option
- * @see #hasArgument(OptionSpec)
- */
- public boolean hasArgument( String option ) {
- AbstractOptionSpec<?> spec = detectedOptions.get( option );
- return spec != null && hasArgument( spec );
- }
-
- /**
- * Tells whether there are any arguments associated with the given option.
- *
- * <p>This method recognizes only instances of options returned from the fluent interface methods.</p>
- *
- * <p>Specifying a {@linkplain ArgumentAcceptingOptionSpec#defaultsTo(Object, Object[]) default argument value}
- * for an option does not cause this method to return {@code true} if the option was not detected on the command
- * line, or if the option can take an optional argument but did not have one on the command line.</p>
- *
- * @param option the option to search for
- * @return {@code true} if the option was detected and at least one argument was detected for the option
- * @throws NullPointerException if {@code option} is {@code null}
- * @see #hasArgument(String)
- */
- public boolean hasArgument( OptionSpec<?> option ) {
- ensureNotNull( option );
-
- List<String> values = optionsToArguments.get( option );
- return values != null && !values.isEmpty();
- }
-
- /**
- * Gives the argument associated with the given option. If the option was given an argument type, the argument
- * will take on that type; otherwise, it will be a {@link String}.
- *
- * <p>Specifying a {@linkplain ArgumentAcceptingOptionSpec#defaultsTo(Object, Object[]) default argument value}
- * for an option will cause this method to return that default value even if the option was not detected on the
- * command line, or if the option can take an optional argument but did not have one on the command line.</p>
- *
- * @param option the option to search for
- * @return the argument of the given option; {@code null} if no argument is present, or that option was not
- * detected
- * @throws NullPointerException if {@code option} is {@code null}
- * @throws OptionException if more than one argument was detected for the option
- */
- public Object valueOf( String option ) {
- ensureNotNull( option );
-
- AbstractOptionSpec<?> spec = detectedOptions.get( option );
- if ( spec == null ) {
- List<?> defaults = defaultValuesFor( option );
- return defaults.isEmpty() ? null : defaults.get( 0 );
- }
-
- return valueOf( spec );
- }
-
- /**
- * Gives the argument associated with the given option.
- *
- * <p>This method recognizes only instances of options returned from the fluent interface methods.</p>
- *
- * @param <V> represents the type of the arguments the given option accepts
- * @param option the option to search for
- * @return the argument of the given option; {@code null} if no argument is present, or that option was not
- * detected
- * @throws OptionException if more than one argument was detected for the option
- * @throws NullPointerException if {@code option} is {@code null}
- * @throws ClassCastException if the arguments of this option are not of the expected type
- */
- public <V> V valueOf( OptionSpec<V> option ) {
- ensureNotNull( option );
-
- List<V> values = valuesOf( option );
- switch ( values.size() ) {
- case 0:
- return null;
- case 1:
- return values.get( 0 );
- default:
- throw new MultipleArgumentsForOptionException( option.options() );
- }
- }
-
- /**
- * <p>Gives any arguments associated with the given option. If the option was given an argument type, the
- * arguments will take on that type; otherwise, they will be {@link String}s.</p>
- *
- * @param option the option to search for
- * @return the arguments associated with the option, as a list of objects of the type given to the arguments; an
- * empty list if no such arguments are present, or if the option was not detected
- * @throws NullPointerException if {@code option} is {@code null}
- */
- public List<?> valuesOf( String option ) {
- ensureNotNull( option );
-
- AbstractOptionSpec<?> spec = detectedOptions.get( option );
- return spec == null ? defaultValuesFor( option ) : valuesOf( spec );
- }
-
- /**
- * <p>Gives any arguments associated with the given option. If the option was given an argument type, the
- * arguments will take on that type; otherwise, they will be {@link String}s.</p>
- *
- * <p>This method recognizes only instances of options returned from the fluent interface methods.</p>
- *
- * @param <V> represents the type of the arguments the given option accepts
- * @param option the option to search for
- * @return the arguments associated with the option; an empty list if no such arguments are present, or if the
- * option was not detected
- * @throws NullPointerException if {@code option} is {@code null}
- * @throws OptionException if there is a problem converting the option's arguments to the desired type; for
- * example, if the type does not implement a correct conversion constructor or method
- */
- public <V> List<V> valuesOf( OptionSpec<V> option ) {
- ensureNotNull( option );
-
- List<String> values = optionsToArguments.get( option );
- if ( values == null || values.isEmpty() )
- return defaultValueFor( option );
-
- AbstractOptionSpec<V> spec = (AbstractOptionSpec<V>) option;
- List<V> convertedValues = new ArrayList<V>();
- for ( String each : values )
- convertedValues.add( spec.convert( each ) );
-
- return unmodifiableList( convertedValues );
- }
-
- /**
- * Gives the set of options that were detected, in the form of {@linkplain OptionSpec}s, in the order in which the
- * options were found on the command line.
- *
- * @return the set of detected command line options
- */
- public List<OptionSpec<?>> specs() {
- return unmodifiableList( detectedSpecs );
- }
-
- /**
- * @return the detected non-option arguments
- */
- public List<String> nonOptionArguments() {
- return unmodifiableList( nonOptionArguments );
- }
-
- void add( AbstractOptionSpec<?> spec ) {
- addWithArgument( spec, null );
- }
-
- void addWithArgument( AbstractOptionSpec<?> spec, String argument ) {
- detectedSpecs.add( spec );
-
- for ( String each : spec.options() )
- detectedOptions.put( each, spec );
-
- List<String> optionArguments = optionsToArguments.get( spec );
-
- if ( optionArguments == null ) {
- optionArguments = new ArrayList<String>();
- optionsToArguments.put( spec, optionArguments );
- }
-
- if ( argument != null )
- optionArguments.add( argument );
- }
-
- void addNonOptionArgument( String argument ) {
- nonOptionArguments.add( argument );
- }
-
- @Override
- public boolean equals( Object that ) {
- if ( this == that )
- return true;
-
- if ( that == null || !getClass().equals( that.getClass() ) )
- return false;
-
- OptionSet other = (OptionSet) that;
- Map<AbstractOptionSpec<?>, List<String>> thisOptionsToArguments =
- new HashMap<AbstractOptionSpec<?>, List<String>>( optionsToArguments );
- Map<AbstractOptionSpec<?>, List<String>> otherOptionsToArguments =
- new HashMap<AbstractOptionSpec<?>, List<String>>( other.optionsToArguments );
- return detectedOptions.equals( other.detectedOptions )
- && thisOptionsToArguments.equals( otherOptionsToArguments )
- && nonOptionArguments.equals( other.nonOptionArguments() );
- }
-
- @Override
- public int hashCode() {
- Map<AbstractOptionSpec<?>, List<String>> thisOptionsToArguments =
- new HashMap<AbstractOptionSpec<?>, List<String>>( optionsToArguments );
- return detectedOptions.hashCode()
- ^ thisOptionsToArguments.hashCode()
- ^ nonOptionArguments.hashCode();
- }
-
- private <V> List<V> defaultValuesFor( String option ) {
- if ( defaultValues.containsKey( option ) )
- return (List<V>) defaultValues.get( option );
-
- return emptyList();
- }
-
- private <V> List<V> defaultValueFor( OptionSpec<V> option ) {
- return defaultValuesFor( option.options().iterator().next() );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/OptionSpec.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/OptionSpec.java b/geode-joptsimple/src/main/java/joptsimple/OptionSpec.java
deleted file mode 100644
index 9f79a40..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/OptionSpec.java
+++ /dev/null
@@ -1,98 +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.
- *
- * <p>Instances of this interface are returned by the "fluent interface" methods to allow retrieval of option arguments
- * in a type-safe manner. Here's an example:</p>
- *
- * <pre><code>
- * OptionParser parser = new OptionParser();
- * <strong>OptionSpec<Integer></strong> count =
- * parser.accepts( "count" ).withRequiredArg().ofType( Integer.class );
- * OptionSet options = parser.parse( "--count", "2" );
- * assert options.has( count );
- * int countValue = options.valueOf( count );
- * assert countValue == count.value( options );
- * List<Integer> countValues = options.valuesOf( count );
- * assert countValues.equals( count.values( options ) );
- * </code></pre>
- *
- * @param <V> represents the type of the arguments this option accepts
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-public interface OptionSpec<V> {
- /**
- * Gives any arguments associated with the given option in the given set of detected options.
- *
- * <p>Specifying a {@linkplain ArgumentAcceptingOptionSpec#defaultsTo(Object, Object[]) default argument value}
- * for this option will cause this method to return that default value even if this option was not detected on the
- * command line, or if this option can take an optional argument but did not have one on the command line.</p>
- *
- * @param detectedOptions the detected options to search in
- * @return the arguments associated with this option; an empty list if no such arguments are present, or if this
- * option was not detected
- * @throws OptionException if there is a problem converting this option's arguments to the desired type; for
- * example, if the type does not implement a correct conversion constructor or method
- * @throws NullPointerException if {@code detectedOptions} is {@code null}
- * @see OptionSet#valuesOf(OptionSpec)
- */
- List<V> values( OptionSet detectedOptions );
-
- /**
- * Gives the argument associated with the given option in the given set of detected options.
- *
- * <p>Specifying a {@linkplain ArgumentAcceptingOptionSpec#defaultsTo(Object, Object[]) default argument value}
- * for this option will cause this method to return that default value even if this option was not detected on the
- * command line, or if this option can take an optional argument but did not have one on the command line.</p>
- *
- * @param detectedOptions the detected options to search in
- * @return the argument of the this option; {@code null} if no argument is present, or that option was not detected
- * @throws OptionException if more than one argument was detected for the option
- * @throws NullPointerException if {@code detectedOptions} is {@code null}
- * @throws ClassCastException if the arguments of this option are not of the expected type
- * @see OptionSet#valueOf(OptionSpec)
- */
- V value( OptionSet detectedOptions );
-
- /**
- * @return the string representations of this option
- */
- Collection<String> options();
-
- /**
- * Tells whether this option is designated as a "help" option. The presence of a "help" option on a command line
- * means that missing "required" options will not cause parsing to fail.
- *
- * @return whether this option is designated as a "help" option
- */
- boolean isForHelp();
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/OptionSpecBuilder.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/OptionSpecBuilder.java b/geode-joptsimple/src/main/java/joptsimple/OptionSpecBuilder.java
deleted file mode 100644
index ff3c99e..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/OptionSpecBuilder.java
+++ /dev/null
@@ -1,96 +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;
-
-/**
- * Allows callers to specify whether a given option accepts arguments (required or optional).
- *
- * <p>Instances are returned from {@link OptionParser#accepts(String)} 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" ).<strong>withRequiredArg()</strong>.ofType( Integer.class );
- * </code></pre>
- *
- * <p>If no methods are invoked on an instance of this class, then that instance's option will accept no argument.</p>
- *
- * <p>Note that you should not use the fluent interface clauses in a way that would defeat the typing of option
- * arguments:</p>
- *
- * <pre><code>
- * OptionParser parser = new OptionParser();
- * ArgumentAcceptingOptionSpec<String> optionC =
- * parser.accepts( "c" ).withRequiredArg();
- * <strong>optionC.ofType( Integer.class ); // DON'T THROW AWAY THE TYPE!</strong>
- *
- * String value = parser.parse( "-c", "2" ).valueOf( optionC ); // ClassCastException
- * </code></pre>
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-public class OptionSpecBuilder extends NoArgumentOptionSpec {
- private final OptionParser parser;
-
- OptionSpecBuilder( OptionParser parser, Collection<String> options, String description ) {
- super( options, description );
-
- this.parser = parser;
- attachToParser();
- }
-
- private void attachToParser() {
- parser.recognize( this );
- }
-
- /**
- * Informs an option parser that this builder's option requires an argument.
- *
- * @return a specification for the option
- */
- public ArgumentAcceptingOptionSpec<String> withRequiredArg() {
- ArgumentAcceptingOptionSpec<String> newSpec =
- new RequiredArgumentOptionSpec<String>( options(), description() );
- parser.recognize( newSpec );
-
- return newSpec;
- }
-
- /**
- * Informs an option parser that this builder's option accepts an optional argument.
- *
- * @return a specification for the option
- */
- public ArgumentAcceptingOptionSpec<String> withOptionalArg() {
- ArgumentAcceptingOptionSpec<String> newSpec =
- new OptionalArgumentOptionSpec<String>( options(), description() );
- parser.recognize( newSpec );
-
- return newSpec;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/OptionSpecTokenizer.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/OptionSpecTokenizer.java b/geode-joptsimple/src/main/java/joptsimple/OptionSpecTokenizer.java
deleted file mode 100644
index 0318db5..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/OptionSpecTokenizer.java
+++ /dev/null
@@ -1,127 +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.NoSuchElementException;
-
-import static joptsimple.ParserRules.*;
-
-
-/**
- * Tokenizes a short option specification string.
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-class OptionSpecTokenizer {
- private static final char POSIXLY_CORRECT_MARKER = '+';
- private static final char HELP_MARKER = '*';
-
- private String specification;
- private int index;
-
- OptionSpecTokenizer( String specification ) {
- if ( specification == null )
- throw new NullPointerException( "null option specification" );
-
- this.specification = specification;
- }
-
- boolean hasMore() {
- return index < specification.length();
- }
-
- AbstractOptionSpec<?> next() {
- if ( !hasMore() )
- throw new NoSuchElementException();
-
-
- String optionCandidate = String.valueOf( specification.charAt( index ) );
- index++;
-
- AbstractOptionSpec<?> spec;
- if ( RESERVED_FOR_EXTENSIONS.equals( optionCandidate ) ) {
- spec = handleReservedForExtensionsToken();
-
- if ( spec != null )
- return spec;
- }
-
- ensureLegalOption( optionCandidate );
-
- if ( hasMore() ) {
- boolean forHelp = false;
- if ( specification.charAt( index ) == HELP_MARKER ) {
- forHelp = true;
- ++index;
- }
- spec = hasMore() && specification.charAt( index ) == ':'
- ? handleArgumentAcceptingOption( optionCandidate )
- : new NoArgumentOptionSpec( optionCandidate );
- if ( forHelp )
- spec.forHelp();
- } else
- spec = new NoArgumentOptionSpec( optionCandidate );
-
- return spec;
- }
-
- void configure( OptionParser parser ) {
- adjustForPosixlyCorrect( parser );
-
- while ( hasMore() )
- parser.recognize( next() );
- }
-
- private void adjustForPosixlyCorrect( OptionParser parser ) {
- if ( POSIXLY_CORRECT_MARKER == specification.charAt( 0 ) ) {
- parser.posixlyCorrect( true );
- specification = specification.substring( 1 );
- }
- }
-
- private AbstractOptionSpec<?> handleReservedForExtensionsToken() {
- if ( !hasMore() )
- return new NoArgumentOptionSpec( RESERVED_FOR_EXTENSIONS );
-
- if ( specification.charAt( index ) == ';' ) {
- ++index;
- return new AlternativeLongOptionSpec();
- }
-
- return null;
- }
-
- private AbstractOptionSpec<?> handleArgumentAcceptingOption( String candidate ) {
- index++;
-
- if ( hasMore() && specification.charAt( index ) == ':' ) {
- index++;
- return new OptionalArgumentOptionSpec<String>( candidate );
- }
-
- return new RequiredArgumentOptionSpec<String>( candidate );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/OptionalArgumentOptionSpec.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/OptionalArgumentOptionSpec.java b/geode-joptsimple/src/main/java/joptsimple/OptionalArgumentOptionSpec.java
deleted file mode 100644
index 250ffd3..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/OptionalArgumentOptionSpec.java
+++ /dev/null
@@ -1,69 +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;
-
-/**
- * Specification of an option that accepts an optional argument.
- *
- * @param <V> represents the type of the arguments this option accepts
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-class OptionalArgumentOptionSpec<V> extends ArgumentAcceptingOptionSpec<V> {
- OptionalArgumentOptionSpec( String option ) {
- super( option, false );
- }
-
- OptionalArgumentOptionSpec( Collection<String> options, String description ) {
- super( options, false, description );
- }
-
- @Override
- protected void detectOptionArgument( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions ) {
- if ( arguments.hasMore() ) {
- String nextArgument = arguments.peek();
-
- if ( !parser.looksLikeAnOption( nextArgument ) )
- handleOptionArgument( parser, detectedOptions, arguments );
- else if ( isArgumentOfNumberType() && canConvertArgument( nextArgument ) )
- addArguments( detectedOptions, arguments.next() );
- else
- detectedOptions.add( this );
- }
- else
- detectedOptions.add( this );
- }
-
- private void handleOptionArgument( OptionParser parser, OptionSet detectedOptions, ArgumentList arguments ) {
- if ( parser.posixlyCorrect() ) {
- detectedOptions.add( this );
- parser.noMoreOptions();
- }
- else
- addArguments( detectedOptions, arguments.next() );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/ParserRules.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/ParserRules.java b/geode-joptsimple/src/main/java/joptsimple/ParserRules.java
deleted file mode 100644
index da4906b..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/ParserRules.java
+++ /dev/null
@@ -1,84 +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 static java.lang.Character.*;
-
-/**
- * Can tell whether or not options are well-formed.
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-final class ParserRules {
- static final char HYPHEN_CHAR = '-';
- static final String HYPHEN = String.valueOf( HYPHEN_CHAR );
- static final String DOUBLE_HYPHEN = "--";
- static final String OPTION_TERMINATOR = DOUBLE_HYPHEN;
- static final String RESERVED_FOR_EXTENSIONS = "W";
-
- private ParserRules() {
- throw new UnsupportedOperationException();
- }
-
- static boolean isShortOptionToken( String argument ) {
- return argument.startsWith( HYPHEN )
- && !HYPHEN.equals( argument )
- && !isLongOptionToken( argument );
- }
-
- static boolean isLongOptionToken( String argument ) {
- return argument.startsWith( DOUBLE_HYPHEN ) && !isOptionTerminator( argument );
- }
-
- static boolean isOptionTerminator( String argument ) {
- return OPTION_TERMINATOR.equals( argument );
- }
-
- static void ensureLegalOption( String option ) {
- if ( option.startsWith( HYPHEN ) )
- throw new IllegalOptionSpecificationException( String.valueOf( option ) );
-
- for ( int i = 0; i < option.length(); ++i )
- ensureLegalOptionCharacter( option.charAt( i ) );
- }
-
- static void ensureLegalOptions( Collection<String> options ) {
- for ( String each : options )
- ensureLegalOption( each );
- }
-
- private static void ensureLegalOptionCharacter( char option ) {
- if ( !( isLetterOrDigit( option ) || isAllowedPunctuation( option ) ) )
- throw new IllegalOptionSpecificationException( String.valueOf( option ) );
- }
-
- private static boolean isAllowedPunctuation( char option ) {
- String allowedPunctuation = "?." + HYPHEN_CHAR;
- return allowedPunctuation.indexOf( option ) != -1;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/RequiredArgumentOptionSpec.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/RequiredArgumentOptionSpec.java b/geode-joptsimple/src/main/java/joptsimple/RequiredArgumentOptionSpec.java
deleted file mode 100644
index 7baae72..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/RequiredArgumentOptionSpec.java
+++ /dev/null
@@ -1,54 +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;
-
-/**
- * Specification of an option that accepts a required argument.
- *
- * @param <V> represents the type of the arguments this option accepts
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- * @author Nikhil Jadhav
- */
-class RequiredArgumentOptionSpec<V> extends ArgumentAcceptingOptionSpec<V> {
- RequiredArgumentOptionSpec( String option ) {
- super( option, true );
- }
-
- RequiredArgumentOptionSpec( Collection<String> options, String description ) {
- super( options, true, description );
- }
-
- @Override
- protected void detectOptionArgument( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions ) {
- if ( !arguments.hasMore() )
- // GemFire Addition : Changed to include OptionSet
- throw new OptionMissingRequiredArgumentException( options(), detectedOptions );
-
- addArguments( detectedOptions, arguments.next() );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/UnrecognizedOptionException.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/UnrecognizedOptionException.java b/geode-joptsimple/src/main/java/joptsimple/UnrecognizedOptionException.java
deleted file mode 100644
index 1d6f508..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/UnrecognizedOptionException.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 encounters an unrecognized option.
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- * @author Nikhil Jadhav
- */
-public class UnrecognizedOptionException extends OptionException {
- private static final long serialVersionUID = -1L;
-
- UnrecognizedOptionException( String option ) {
- super( singletonList( option ) );
- }
-
- // GemFire Addition : Added to include the detected options
- UnrecognizedOptionException( String option, OptionSet detected ) {
- super( singletonList( option ), detected );
- }
-
- @Override
- public String getMessage() {
- return singleOptionMessage() + " is not a recognized option";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/ValueConversionException.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/ValueConversionException.java b/geode-joptsimple/src/main/java/joptsimple/ValueConversionException.java
deleted file mode 100644
index 282c5c4..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/ValueConversionException.java
+++ /dev/null
@@ -1,54 +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;
-
-/**
- * Thrown by {@link ValueConverter}s when problems occur in converting string values to other Java types.
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-public class ValueConversionException extends RuntimeException {
- private static final long serialVersionUID = -1L;
-
- /**
- * Creates a new exception with the specified detail message.
- *
- * @param message the detail message
- */
- public ValueConversionException( String message ) {
- this( message, null );
- }
-
- /**
- * Creates a new exception with the specified detail message and cause.
- *
- * @param message the detail message
- * @param cause the original exception
- */
- public ValueConversionException( String message, Throwable cause ) {
- super( message, cause );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/ValueConverter.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/ValueConverter.java b/geode-joptsimple/src/main/java/joptsimple/ValueConverter.java
deleted file mode 100644
index d90bef8..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/ValueConverter.java
+++ /dev/null
@@ -1,58 +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;
-
-/**
- * Instances of this interface are used to convert arguments of options into specific Java types.
- *
- * @param <V> constraint on the type of values being converted to
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-public interface ValueConverter<V> {
- /**
- * Converts the given string value into a Java type.
- *
- * @param value the string to convert
- * @return the converted value
- * @throws ValueConversionException if a problem occurs while converting the value
- */
- V convert( String value );
-
- /**
- * Gives the class of the type of values this converter converts to.
- *
- * @return the target class for conversion
- */
- Class<V> valueType();
-
- /**
- * Gives a string that describes the pattern of the values this converter expects, if any. For example, a date
- * converter can respond with a {@link java.text.SimpleDateFormat date format string}.
- *
- * @return a value pattern, or {@code null} if there's nothing interesting here
- */
- String valuePattern();
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/internal/AbbreviationMap.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/internal/AbbreviationMap.java b/geode-joptsimple/src/main/java/joptsimple/internal/AbbreviationMap.java
deleted file mode 100644
index 35fad89..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/internal/AbbreviationMap.java
+++ /dev/null
@@ -1,233 +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.internal;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * <p>A map whose keys are strings; when a key/value pair is added to the map, the longest unique abbreviations of that
- * key are added as well, and associated with the value. Thus:</p>
- *
- * <pre>
- * <code>
- * abbreviations.put( "good", "bye" );
- * </code>
- * </pre>
- *
- * <p>would make it such that you could retrieve the value {@code "bye"} from the map using the keys {@code "good"},
- * {@code "goo"}, {@code "go"}, and {@code "g"}. A subsequent invocation of:</p>
- * <pre>
- * <code>
- * abbreviations.put( "go", "fish" );
- * </code>
- * </pre>
- *
- * <p>would make it such that you could retrieve the value {@code "bye"} using the keys {@code "good"} and
- * {@code "goo"}, and the value {@code "fish"} using the key {@code "go"}. The key {@code "g"} would yield
- * {@code null}, since it would no longer be a unique abbreviation.</p>
- *
- * <p>The data structure is much like a "trie".</p>
- *
- * @param <V> a constraint on the types of the values in the map
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-public class AbbreviationMap<V> {
- private String key;
- private V value;
- private final Map<Character, AbbreviationMap<V>> children = new TreeMap<Character, AbbreviationMap<V>>();
- private int keysBeyond;
-
- /**
- * <p>Tells whether the given key is in the map, or whether the given key is a unique
- * abbreviation of a key that is in the map.</p>
- *
- * @param aKey key to look up
- * @return {@code true} if {@code key} is present in the map
- * @throws NullPointerException if {@code key} is {@code null}
- */
- public boolean contains( String aKey ) {
- return get( aKey ) != null;
- }
-
- /**
- * <p>Answers the value associated with the given key. The key can be a unique
- * abbreviation of a key that is in the map. </p>
- *
- * @param aKey key to look up
- * @return the value associated with {@code aKey}; or {@code null} if there is no
- * such value or {@code aKey} is not a unique abbreviation of a key in the map
- * @throws NullPointerException if {@code aKey} is {@code null}
- */
- public V get( String aKey ) {
- char[] chars = charsOf( aKey );
-
- AbbreviationMap<V> child = this;
- for ( char each : chars ) {
- child = child.children.get( each );
- if ( child == null )
- return null;
- }
-
- return child.value;
- }
-
- /**
- * <p>Associates a given value with a given key. If there was a previous
- * association, the old value is replaced with the new one.</p>
- *
- * @param aKey key to create in the map
- * @param newValue value to associate with the key
- * @throws NullPointerException if {@code aKey} or {@code newValue} is {@code null}
- * @throws IllegalArgumentException if {@code aKey} is a zero-length string
- */
- public void put( String aKey, V newValue ) {
- if ( newValue == null )
- throw new NullPointerException();
- if ( aKey.length() == 0 )
- throw new IllegalArgumentException();
-
- char[] chars = charsOf( aKey );
- add( chars, newValue, 0, chars.length );
- }
-
- /**
- * <p>Associates a given value with a given set of keys. If there was a previous
- * association, the old value is replaced with the new one.</p>
- *
- * @param keys keys to create in the map
- * @param newValue value to associate with the key
- * @throws NullPointerException if {@code keys} or {@code newValue} is {@code null}
- * @throws IllegalArgumentException if any of {@code keys} is a zero-length string
- */
- public void putAll( Iterable<String> keys, V newValue ) {
- for ( String each : keys )
- put( each, newValue );
- }
-
- private boolean add( char[] chars, V newValue, int offset, int length ) {
- if ( offset == length ) {
- value = newValue;
- boolean wasAlreadyAKey = key != null;
- key = new String( chars );
- return !wasAlreadyAKey;
- }
-
- char nextChar = chars[ offset ];
- AbbreviationMap<V> child = children.get( nextChar );
- if ( child == null ) {
- child = new AbbreviationMap<V>();
- children.put( nextChar, child );
- }
-
- boolean newKeyAdded = child.add( chars, newValue, offset + 1, length );
-
- if ( newKeyAdded )
- ++keysBeyond;
-
- if ( key == null )
- value = keysBeyond > 1 ? null : newValue;
-
- return newKeyAdded;
- }
-
- /**
- * <p>If the map contains the given key, dissociates the key from its value.</p>
- *
- * @param aKey key to remove
- * @throws NullPointerException if {@code aKey} is {@code null}
- * @throws IllegalArgumentException if {@code aKey} is a zero-length string
- */
- public void remove( String aKey ) {
- if ( aKey.length() == 0 )
- throw new IllegalArgumentException();
-
- char[] keyChars = charsOf( aKey );
- remove( keyChars, 0, keyChars.length );
- }
-
- private boolean remove( char[] aKey, int offset, int length ) {
- if ( offset == length )
- return removeAtEndOfKey();
-
- char nextChar = aKey[ offset ];
- AbbreviationMap<V> child = children.get( nextChar );
- if ( child == null || !child.remove( aKey, offset + 1, length ) )
- return false;
-
- --keysBeyond;
- if ( child.keysBeyond == 0 )
- children.remove( nextChar );
- if ( keysBeyond == 1 && key == null )
- setValueToThatOfOnlyChild();
-
- return true;
- }
-
- private void setValueToThatOfOnlyChild() {
- Map.Entry<Character, AbbreviationMap<V>> entry = children.entrySet().iterator().next();
- AbbreviationMap<V> onlyChild = entry.getValue();
- value = onlyChild.value;
- }
-
- private boolean removeAtEndOfKey() {
- if ( key == null )
- return false;
-
- key = null;
- if ( keysBeyond == 1 )
- setValueToThatOfOnlyChild();
- else
- value = null;
-
- return true;
- }
-
- /**
- * Gives a Java map representation of this abbreviation map.
- *
- * @return a Java map corresponding to this abbreviation map
- */
- public Map<String, V> toJavaUtilMap() {
- Map<String, V> mappings = new TreeMap<String, V>();
- addToMappings( mappings );
- return mappings;
- }
-
- private void addToMappings( Map<String, V> mappings ) {
- if ( key != null )
- mappings.put( key, value );
-
- for ( AbbreviationMap<V> each : children.values() )
- each.addToMappings( mappings );
- }
-
- private static char[] charsOf( String aKey ) {
- char[] chars = new char[ aKey.length() ];
- aKey.getChars( 0, aKey.length(), chars, 0 );
- return chars;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/internal/Classes.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/internal/Classes.java b/geode-joptsimple/src/main/java/joptsimple/internal/Classes.java
deleted file mode 100644
index 89e0310..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/internal/Classes.java
+++ /dev/null
@@ -1,74 +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.internal;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-public final class Classes {
- private static final Map<Class<?>, Class<?>> WRAPPERS = new HashMap<Class<?>, Class<?>>( 13 );
-
- static {
- WRAPPERS.put( boolean.class, Boolean.class );
- WRAPPERS.put( byte.class, Byte.class );
- WRAPPERS.put( char.class, Character.class );
- WRAPPERS.put( double.class, Double.class );
- WRAPPERS.put( float.class, Float.class );
- WRAPPERS.put( int.class, Integer.class );
- WRAPPERS.put( long.class, Long.class );
- WRAPPERS.put( short.class, Short.class );
- WRAPPERS.put( void.class, Void.class );
- }
-
- private Classes() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Gives the "short version" of the given class name. Somewhat naive to inner classes.
- *
- * @param className class name to chew on
- * @return the short name of the class
- */
- public static String shortNameOf( String className ) {
- return className.substring( className.lastIndexOf( '.' ) + 1 );
- }
-
- /**
- * Gives the primitive wrapper class for the given class. If the given class is not
- * {@linkplain Class#isPrimitive() primitive}, returns the class itself.
- *
- * @param <T> generic class type
- * @param clazz the class to check
- * @return primitive wrapper type if {@code clazz} is primitive, otherwise {@code clazz}
- */
- public static <T> Class<T> wrapperOf( Class<T> clazz ) {
- return clazz.isPrimitive() ? (Class<T>) WRAPPERS.get( clazz ) : clazz;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/internal/Column.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/internal/Column.java b/geode-joptsimple/src/main/java/joptsimple/internal/Column.java
deleted file mode 100644
index e7be1a2..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/internal/Column.java
+++ /dev/null
@@ -1,133 +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.internal;
-
-import java.text.BreakIterator;
-import java.util.Comparator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-
-import static java.lang.System.*;
-import static java.text.BreakIterator.*;
-
-import static joptsimple.internal.Strings.*;
-
-
-/**
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-public class Column {
- static final Comparator<Column> BY_HEIGHT = new Comparator<Column>() {
- public int compare( Column first, Column second ) {
- if ( first.height() < second.height() )
- return -1;
- return first.height() == second.height() ? 0 : 1;
- }
- };
-
- private final String header;
- private final List<String> data;
- private final int width;
- private int height;
-
- Column( String header, int width ) {
- this.header = header;
- this.width = Math.max( width, header.length() );
- data = new LinkedList<String>();
- height = 0;
- }
-
- int addCells( Object cellCandidate ) {
- int originalHeight = height;
-
- String source = String.valueOf( cellCandidate ).trim();
- for ( String eachPiece : source.split( getProperty( "line.separator" ) ) )
- processNextEmbeddedLine( eachPiece );
-
- return height - originalHeight;
- }
-
- private void processNextEmbeddedLine( String line ) {
- BreakIterator words = BreakIterator.getLineInstance( Locale.US );
- words.setText( line );
-
- StringBuilder nextCell = new StringBuilder();
-
- int start = words.first();
- for ( int end = words.next(); end != DONE; start = end, end = words.next() )
- nextCell = processNextWord( line, nextCell, start, end );
-
- if ( nextCell.length() > 0 )
- addCell( nextCell.toString() );
- }
-
- private StringBuilder processNextWord( String source, StringBuilder nextCell, int start, int end ) {
- StringBuilder augmented = nextCell;
-
- String word = source.substring( start, end );
- if ( augmented.length() + word.length() > width ) {
- addCell( augmented.toString() );
- augmented = new StringBuilder( " " ).append( word );
- }
- else
- augmented.append( word );
-
- return augmented;
- }
-
- void addCell( String newCell ) {
- data.add( newCell );
- ++height;
- }
-
- void writeHeaderOn( StringBuilder buffer, boolean appendSpace ) {
- buffer.append( header ).append( repeat( ' ', width - header.length() ) );
-
- if ( appendSpace )
- buffer.append( ' ' );
- }
-
- void writeSeparatorOn( StringBuilder buffer, boolean appendSpace ) {
- buffer.append( repeat( '-', header.length() ) ).append( repeat( ' ', width - header.length() ) );
- if ( appendSpace )
- buffer.append( ' ' );
- }
-
- void writeCellOn( int index, StringBuilder buffer, boolean appendSpace ) {
- if ( index < data.size() ) {
- String item = data.get( index );
-
- buffer.append( item ).append( repeat( ' ', width - item.length() ) );
- if ( appendSpace )
- buffer.append( ' ' );
- }
- }
-
- int height() {
- return height;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/internal/ColumnWidthCalculator.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/internal/ColumnWidthCalculator.java b/geode-joptsimple/src/main/java/joptsimple/internal/ColumnWidthCalculator.java
deleted file mode 100644
index 9b3bccc..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/internal/ColumnWidthCalculator.java
+++ /dev/null
@@ -1,41 +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.internal;
-
-/**
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-class ColumnWidthCalculator {
- int calculate( int totalWidth, int numberOfColumns ) {
- if ( numberOfColumns == 1 )
- return totalWidth;
-
- int remainder = totalWidth % numberOfColumns;
- if ( remainder == numberOfColumns - 1 )
- return totalWidth / numberOfColumns;
- return totalWidth / numberOfColumns - 1;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/internal/ColumnarData.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/internal/ColumnarData.java b/geode-joptsimple/src/main/java/joptsimple/internal/ColumnarData.java
deleted file mode 100644
index ebb6d12..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/internal/ColumnarData.java
+++ /dev/null
@@ -1,163 +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.internal;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import static java.lang.Integer.*;
-import static java.lang.System.*;
-import static java.util.Collections.*;
-
-import static joptsimple.internal.Column.*;
-import static joptsimple.internal.Strings.*;
-
-
-/**
- * A means to display data in a text grid.
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-public class ColumnarData {
- private static final String LINE_SEPARATOR = getProperty( "line.separator" );
- private static final int TOTAL_WIDTH = 80;
-
- private final ColumnWidthCalculator widthCalculator;
- private final List<Column> columns;
- private final String[] headers;
-
- /**
- * Creates a new grid with the given column headers.
- *
- * @param headers column headers
- */
- public ColumnarData( String... headers ) {
- this.headers = headers.clone();
- widthCalculator = new ColumnWidthCalculator();
- columns = new LinkedList<Column>();
-
- clear();
- }
-
- /**
- * Adds a row to the grid. The data will fall under the corresponding headers.
- * There can be fewer elements in the row than headers. Any data in columns outside
- * of the number of headers will not be added to the grid.
- *
- * @param rowData row data to add
- */
- public void addRow( Object... rowData ) {
- int[] numberOfCellsAddedAt = addRowCells( rowData );
- addPaddingCells( numberOfCellsAddedAt );
- }
-
- /**
- * Gives a string that represents the data formatted in columns.
- *
- * @return the formatted grid
- */
- public String format() {
- StringBuilder buffer = new StringBuilder();
-
- writeHeadersOn( buffer );
- writeSeparatorsOn( buffer );
- writeRowsOn( buffer );
-
- return buffer.toString();
- }
-
- /**
- * Removes all data from the grid, but preserves the headers.
- */
- public final void clear() {
- columns.clear();
-
- int desiredColumnWidth = widthCalculator.calculate( TOTAL_WIDTH, headers.length );
- for ( String each : headers )
- columns.add( new Column( each, desiredColumnWidth ) );
- }
-
- private void writeHeadersOn( StringBuilder buffer ) {
- for ( Iterator<Column> iter = columns.iterator(); iter.hasNext(); )
- iter.next().writeHeaderOn( buffer, iter.hasNext() );
-
- buffer.append( LINE_SEPARATOR );
- }
-
- private void writeSeparatorsOn( StringBuilder buffer ) {
- for ( Iterator<Column> iter = columns.iterator(); iter.hasNext(); )
- iter.next().writeSeparatorOn( buffer, iter.hasNext() );
-
- buffer.append( LINE_SEPARATOR );
- }
-
- private void writeRowsOn( StringBuilder buffer ) {
- int maxHeight = max( columns, BY_HEIGHT ).height();
-
- for ( int i = 0; i < maxHeight; ++i )
- writeRowOn( buffer, i );
- }
-
- private void writeRowOn( StringBuilder buffer, int rowIndex ) {
- for ( Iterator<Column> iter = columns.iterator(); iter.hasNext(); )
- iter.next().writeCellOn( rowIndex, buffer, iter.hasNext() );
-
- buffer.append( LINE_SEPARATOR );
- }
-
- private int arrayMax( int[] numbers ) {
- int maximum = MIN_VALUE;
-
- for ( int each : numbers )
- maximum = Math.max( maximum, each );
-
- return maximum;
- }
-
- private int[] addRowCells( Object... rowData ) {
- int[] cellsAddedAt = new int[ rowData.length ];
-
- Iterator<Column> iter = columns.iterator();
- for ( int i = 0; iter.hasNext() && i < rowData.length; ++i )
- cellsAddedAt[ i ] = iter.next().addCells( rowData[ i ] );
-
- return cellsAddedAt;
- }
-
- private void addPaddingCells( int... numberOfCellsAddedAt ) {
- int maxHeight = arrayMax( numberOfCellsAddedAt );
-
- Iterator<Column> iter = columns.iterator();
- for ( int i = 0; iter.hasNext() && i < numberOfCellsAddedAt.length; ++i )
- addPaddingCellsForColumn( iter.next(), maxHeight, numberOfCellsAddedAt[ i ] );
- }
-
- private void addPaddingCellsForColumn( Column column, int maxHeight, int numberOfCellsAdded ) {
- for ( int i = 0; i < maxHeight - numberOfCellsAdded; ++i )
- column.addCell( EMPTY );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/internal/ConstructorInvokingValueConverter.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/internal/ConstructorInvokingValueConverter.java b/geode-joptsimple/src/main/java/joptsimple/internal/ConstructorInvokingValueConverter.java
deleted file mode 100644
index 7a23c6a..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/internal/ConstructorInvokingValueConverter.java
+++ /dev/null
@@ -1,58 +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.internal;
-
-import java.lang.reflect.Constructor;
-
-import joptsimple.ValueConverter;
-
-import static joptsimple.internal.Reflection.*;
-
-
-
-/**
- * @param <V> constraint on the type of values being converted to
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-class ConstructorInvokingValueConverter<V> implements ValueConverter<V> {
- private final Constructor<V> ctor;
-
- ConstructorInvokingValueConverter( Constructor<V> ctor ) {
- this.ctor = ctor;
- }
-
- public V convert( String value ) {
- return instantiate( ctor, value );
- }
-
- public Class<V> valueType() {
- return ctor.getDeclaringClass();
- }
-
- public String valuePattern() {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/internal/MethodInvokingValueConverter.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/internal/MethodInvokingValueConverter.java b/geode-joptsimple/src/main/java/joptsimple/internal/MethodInvokingValueConverter.java
deleted file mode 100644
index 345242c..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/internal/MethodInvokingValueConverter.java
+++ /dev/null
@@ -1,60 +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.internal;
-
-import java.lang.reflect.Method;
-
-import joptsimple.ValueConverter;
-
-import static joptsimple.internal.Reflection.*;
-
-
-
-/**
- * @param <V> constraint on the type of values being converted to
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-class MethodInvokingValueConverter<V> implements ValueConverter<V> {
- private final Method method;
- private final Class<V> clazz;
-
- MethodInvokingValueConverter( Method method, Class<V> clazz ) {
- this.method = method;
- this.clazz = clazz;
- }
-
- public V convert( String value ) {
- return clazz.cast( invoke( method, value ) );
- }
-
- public Class<V> valueType() {
- return clazz;
- }
-
- public String valuePattern() {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/internal/Objects.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/internal/Objects.java b/geode-joptsimple/src/main/java/joptsimple/internal/Objects.java
deleted file mode 100644
index 7ccca1c..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/internal/Objects.java
+++ /dev/null
@@ -1,46 +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.internal;
-
-/**
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-public final class Objects {
- private Objects() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Rejects {@code null} references.
- *
- * @param target reference to check
- * @throws NullPointerException if {@code target} is {@code null}
- */
- public static void ensureNotNull( Object target ) {
- if ( target == null )
- throw new NullPointerException();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/internal/Reflection.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/internal/Reflection.java b/geode-joptsimple/src/main/java/joptsimple/internal/Reflection.java
deleted file mode 100644
index 77d2e6b..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/internal/Reflection.java
+++ /dev/null
@@ -1,143 +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.internal;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import joptsimple.ValueConverter;
-
-import static java.lang.reflect.Modifier.*;
-
-import static joptsimple.internal.Classes.*;
-
-
-
-/**
- * Helper methods for reflection.
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-public final class Reflection {
- private Reflection() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Finds an appropriate value converter for the given class.
- *
- * @param <V> a constraint on the class object to introspect
- * @param clazz class to introspect on
- * @return a converter method or constructor
- */
- public static <V> ValueConverter<V> findConverter( Class<V> clazz ) {
- Class<V> maybeWrapper = wrapperOf( clazz );
-
- ValueConverter<V> valueOf = valueOfConverter( maybeWrapper );
- if ( valueOf != null )
- return valueOf;
-
- ValueConverter<V> constructor = constructorConverter( maybeWrapper );
- if ( constructor != null )
- return constructor;
-
- throw new IllegalArgumentException( clazz + " is not a value type" );
- }
-
- private static <V> ValueConverter<V> valueOfConverter( Class<V> clazz ) {
- try {
- Method valueOf = clazz.getDeclaredMethod( "valueOf", String.class );
- if ( meetsConverterRequirements( valueOf, clazz ) )
- return new MethodInvokingValueConverter<V>( valueOf, clazz );
-
- return null;
- }
- catch ( NoSuchMethodException ignored ) {
- return null;
- }
- }
-
- private static <V> ValueConverter<V> constructorConverter( Class<V> clazz ) {
- try {
- return new ConstructorInvokingValueConverter<V>( clazz.getConstructor( String.class ) );
- }
- catch ( NoSuchMethodException ignored ) {
- return null;
- }
- }
-
- /**
- * Invokes the given constructor with the given arguments.
- *
- * @param <T> constraint on the type of the objects yielded by the constructor
- * @param constructor constructor to invoke
- * @param args arguments to hand to the constructor
- * @return the result of invoking the constructor
- * @throws ReflectionException in lieu of the gaggle of reflection-related exceptions
- */
- public static <T> T instantiate( Constructor<T> constructor, Object... args ) {
- try {
- return constructor.newInstance( args );
- }
- catch ( Exception ex ) {
- throw reflectionException( ex );
- }
- }
-
- /**
- * Invokes the given static method with the given arguments.
- *
- * @param method method to invoke
- * @param args arguments to hand to the method
- * @return the result of invoking the method
- * @throws ReflectionException in lieu of the gaggle of reflection-related exceptions
- */
- public static Object invoke( Method method, Object... args ) {
- try {
- return method.invoke( null, args );
- }
- catch ( Exception ex ) {
- throw reflectionException( ex );
- }
- }
-
- private static boolean meetsConverterRequirements( Method method, Class<?> expectedReturnType ) {
- int modifiers = method.getModifiers();
- return isPublic( modifiers ) && isStatic( modifiers ) && expectedReturnType.equals( method.getReturnType() );
- }
-
- private static RuntimeException reflectionException( Exception ex ) {
- if ( ex instanceof IllegalArgumentException )
- return new ReflectionException( ex );
- if ( ex instanceof InvocationTargetException )
- return new ReflectionException( ex.getCause() );
- if ( ex instanceof RuntimeException )
- return (RuntimeException) ex;
-
- return new ReflectionException( ex );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/internal/ReflectionException.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/internal/ReflectionException.java b/geode-joptsimple/src/main/java/joptsimple/internal/ReflectionException.java
deleted file mode 100644
index 2f48e0b..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/internal/ReflectionException.java
+++ /dev/null
@@ -1,39 +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.internal;
-
-/**
- * This unchecked exception wraps reflection-oriented exceptions.
- *
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-public class ReflectionException extends RuntimeException {
- private static final long serialVersionUID = -2L;
-
- ReflectionException( Throwable cause ) {
- super( cause.toString() );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/921bec11/geode-joptsimple/src/main/java/joptsimple/internal/Strings.java
----------------------------------------------------------------------
diff --git a/geode-joptsimple/src/main/java/joptsimple/internal/Strings.java b/geode-joptsimple/src/main/java/joptsimple/internal/Strings.java
deleted file mode 100644
index 8e6e910..0000000
--- a/geode-joptsimple/src/main/java/joptsimple/internal/Strings.java
+++ /dev/null
@@ -1,117 +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.internal;
-
-import java.util.Iterator;
-import java.util.List;
-
-import static java.lang.System.*;
-import static java.util.Arrays.*;
-
-/**
- * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
- */
-public final class Strings {
- public static final String EMPTY = "";
- public static final String SINGLE_QUOTE = "'";
- public static final String LINE_SEPARATOR = getProperty( "line.separator" );
-
- private Strings() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Gives a string consisting of the given character repeated the given number of times.
- *
- * @param ch the character to repeat
- * @param count how many times to repeat the character
- * @return the resultant string
- */
- public static String repeat( char ch, int count ) {
- StringBuilder buffer = new StringBuilder();
-
- for ( int i = 0; i < count; ++i )
- buffer.append( ch );
-
- return buffer.toString();
- }
-
- /**
- * Tells whether the given string is either {@code} or consists solely of whitespace characters.
- *
- * @param target string to check
- * @return {@code true} if the target string is null or empty
- */
- public static boolean isNullOrEmpty( String target ) {
- return target == null || EMPTY.equals( target );
- }
-
-
- /**
- * Gives a string consisting of a given string prepended and appended with surrounding characters.
- *
- * @param target a string
- * @param begin character to prepend
- * @param end character to append
- * @return the surrounded string
- */
- public static String surround( String target, char begin, char end ) {
- return begin + target + end;
- }
-
- /**
- * Gives a string consisting of the elements of a given array of strings, each separated by a given separator
- * string.
- *
- * @param pieces the strings to join
- * @param separator the separator
- * @return the joined string
- */
- public static String join( String[] pieces, String separator ) {
- return join( asList( pieces ), separator );
- }
-
- /**
- * Gives a string consisting of the string representations of the elements of a given array of objects,
- * each separated by a given separator string.
- *
- * @param pieces the elements whose string representations are to be joined
- * @param separator the separator
- * @return the joined string
- */
- public static String join( List<String> pieces, String separator ) {
- StringBuilder buffer = new StringBuilder();
-
- for ( Iterator<String> iter = pieces.iterator(); iter.hasNext(); ) {
- buffer.append( iter.next() );
-
- if ( iter.hasNext() )
- buffer.append( separator );
- }
-
- return buffer.toString();
- }
-}