Creates a map of option short-names to the corresponding option instance.

@param cl
the command line containing the parsed option instances

@return a map of parameter short namese to their corresponding option instance.
189056
private Map<String, Option> toMap(CommandLine cl) {
        final Map<String, Option> opts = new HashMap<>();
        for (Option opt : cl.getOptions()) {
            opts.put(opt.getOpt(), opt);
        }
        return opts;
    }
331013
public static <T> Optional<Optional<T>> getOptional(final Map map, final Class<T> clazz, final Object... path) {
        return get(map, Optional.class, path).map(opt -> (Optional<T>) opt);
    }
904175
public static Map<String, PropertyDescriptor> mapPropertyDescriptors(Class<?> clazz) {
        PropertyDescriptor[] properties = propertyDescriptors(clazz);
        Map<String, PropertyDescriptor> mappedProperties = new HashMap<String, PropertyDescriptor>();

        for (PropertyDescriptor property : properties) {
            if ("class".equals(property.getName()) == false) {
                mappedProperties.put(property.getName(), property);
            }
        }

        return mappedProperties;
    }
225663
protected List<String> getOptionsByCommand(String command){
        String rawOption = commands.get(command);
        String[] options = rawOption.split(CoreConstants.COMMA);
        return Arrays.asList(options);
    }
530483
protected ClassMapping mapClass (short code, String cname)
        throws IOException, ClassNotFoundException
    {
        // create a class mapping record, and cache it
        ClassMapping cmap = createClassMapping(code, cname);
        _classmap.add(code, cmap);
        return cmap;
    }
585209
public List<CommandCallback> buildCommandCallback(CommandContext ctx, ClassLoader cl) {
        List<CommandCallback> callbackList = new ArrayList<CommandCallback>();
        if (ctx != null && ctx.getData("callbacks") != null) {
            logger.debug("Callback: {}", ctx.getData("callbacks"));
            String[] callbacksArray = ((String) ctx.getData("callbacks")).split(",");
            List<String> callbacks = (List<String>) Arrays.asList(callbacksArray);
            for (String callbackName : callbacks) {
                CommandCallback handler = findCommandCallback(callbackName.trim(), cl);
                callbackList.add(handler);
            }
        }
        return callbackList;
    }
183315
@Pure
	public static Map<String, List<Object>> getCommandLineOptions() {
		if (commandLineOptions != null) {
			return Collections.unmodifiableSortedMap(commandLineOptions);
		}
		return Collections.emptyMap();
	}
638215
public List<SaneOption> listOptions() throws IOException {
    if (optionTitleMap == null) {
      groups.clear();
      optionTitleMap =
          Maps.uniqueIndex(
              SaneOption.optionsFor(this),
              new Function<SaneOption, String>() {
                @Override
                public String apply(SaneOption input) {
                  return input.getName();
                }
              });
    }

    // Maps.uniqueIndex guarantees the order of optionTitleMap.values()
    return ImmutableList.copyOf(optionTitleMap.values());
  }
1343520
private List<CmsSelectWidgetOption> getSortNamesConf() {

        List<CmsSelectWidgetOption> retVal = new ArrayList<CmsSelectWidgetOption>();
        try {
            String[] names = CmsSearchParameters.SORT_NAMES;
            for (int i = 0; i < names.length; i++) {
                retVal.add(
                    new CmsSelectWidgetOption(
                        names[i],
                        (i == 0),
                        key(A_CmsWidget.LABEL_PREFIX + names[i].toLowerCase())));
            }
        } catch (Exception e) {
            // noop
        }
        return retVal;
    }
286483
protected List<String> createOption(final String option, final Object value) {
        if (value == null){
            return new ArrayList<String>();
        }
        return Arrays.asList(option, String.valueOf(value));
    }
1033057
public static Object getDefaultValue(Class cl) {
        if (cl.isArray()) {// 处理数组
            return Array.newInstance(cl.getComponentType(), 0);
        } else if (cl.isPrimitive() || primitiveValueMap.containsKey(cl)) { // 处理原型
            return primitiveValueMap.get(cl);
        } else {
            return newInstance(cl);
            // return null;
        }
    }
362741
public CommandCallback findCommandCallback(String name, ClassLoader cl) {
        synchronized (callbackCache) {
            
            if (!callbackCache.containsKey(name)) {
                try {
                    CommandCallback commandCallbackInstance = (CommandCallback) Class.forName(name, true, cl).newInstance();
                    return commandCallbackInstance;
                    //                            callbackCache.put(name, commandCallbackInstance);
                } catch (Exception ex) {
                    throw new IllegalArgumentException("Unknown Command implementation with name '" + name + "'");
                }

            } else {
                CommandCallback cmdCallback = callbackCache.get(name);
                if (!cmdCallback.getClass().getClassLoader().equals(cl)) {
                    callbackCache.remove(name);
                    try {
                        CommandCallback commandCallbackInstance = (CommandCallback) Class.forName(name, true, cl).newInstance();
                        callbackCache.put(name, commandCallbackInstance);
                    } catch (Exception ex) {
                        throw new IllegalArgumentException("Unknown Command implementation with name '" + name + "'");
                    }
                }
            }

        }
        return callbackCache.get(name);
    }
1148465
public static Map<String, Object> cmd(String c) {
		HashMap<String, Object> r = new HashMap<>();
		r.put("cmd", c.toUpperCase());
		return r;
	}
856159
public String getArgDecl(HashMap<String,TypeMirror> bindingMap)
    {
        StringBuffer sb = new StringBuffer();

        if ( _methodDecl.getParameters() == null )
            return "";
        
        int i = 0;
        for (ParameterDeclaration paramDecl : _methodDecl.getParameters())
        {
            TypeMirror paramType = paramDecl.getType();
            if ( paramType == null )
                return "";
                
            if (bindingMap != null && bindingMap.containsKey(paramType.toString()))
                paramType = bindingMap.get(paramType.toString());

            if (i != 0)
                sb.append(", ");
            
            sb.append(paramType.toString());

            sb.append(' ');

            // BUGBUG: when the MethodDeclaration is derived from Reflection, this seems
            // to return 'arg0' for all arguments!
            String argName = paramDecl.getSimpleName();
            if (argName.equals("arg0"))
                sb.append("arg" + i);
            else
                sb.append(argName);

            i++;
        }
        return sb.toString();
    }
1279123
public static SettingsMode get(Map<String, String[]> clArgs)
    {
        String[] params = clArgs.remove("-mode");
        if (params == null)
        {
            Cql3NativeOptions opts = new Cql3NativeOptions();
            opts.accept("cql3");
            opts.accept("native");
            opts.accept("prepared");
            return new SettingsMode(opts);
        }

        GroupedOptions options = GroupedOptions.select(params, new ThriftOptions(), new Cql3NativeOptions(), new Cql3ThriftOptions(), new Cql3SimpleNativeOptions(), new Cql2ThriftOptions());
        if (options == null)
        {
            printHelp();
            System.out.println("Invalid -mode options provided, see output for valid options");
            System.exit(1);
        }
        return new SettingsMode(options);
    }
485795
protected static Object getParamArg(Class cl)
    {
        if (!cl.isPrimitive())
            return null;
        else if (boolean.class.equals(cl))
            return Boolean.FALSE;
        else if (byte.class.equals(cl))
            return Byte.valueOf((byte) 0);
        else if (short.class.equals(cl))
            return Short.valueOf((short) 0);
        else if (char.class.equals(cl))
            return Character.valueOf((char) 0);
        else if (int.class.equals(cl))
            return Integer.valueOf(0);
        else if (long.class.equals(cl))
            return Long.valueOf(0);
        else if (float.class.equals(cl))
            return Double.valueOf(0);
        else if (double.class.equals(cl))
            return Double.valueOf(0);
        else
            throw new UnsupportedOperationException();
    }
1229230
public static CommandLine processCommandLineArgs(Option[] customOptions, String[] args) {
    Options options = new Options();

    options.addOption("h", "help", false, "Print this message");
    options.addOption("v", "verbose", false, "Generate verbose log messages");

    if (customOptions != null) {
      for (int i = 0; i < customOptions.length; i++)
        options.addOption(customOptions[i]);
    }

    CommandLine cli = null;
    try {
      cli = (new GnuParser()).parse(options, args);
    } catch (ParseException exp) {
      boolean hasHelpArg = false;
      if (args != null && args.length > 0) {
        for (int z = 0; z < args.length; z++) {
          if ("-h".equals(args[z]) || "-help".equals(args[z])) {
            hasHelpArg = true;
            break;
          }
        }
      }
      if (!hasHelpArg) {
        System.err.println("Failed to parse command-line arguments due to: " + exp.getMessage());
      }
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp(SparkApp.class.getName(), options);
      System.exit(1);
    }

    if (cli.hasOption("help")) {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp(SparkApp.class.getName(), options);
      System.exit(0);
    }

    return cli;
  }