本文整理了Java中org.apache.commons.cli.Option.getKey()
方法的一些代码示例,展示了Option.getKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option.getKey()
方法的具体详情如下:
包路径:org.apache.commons.cli.Option
类名称:Option
方法名:getKey
[英]Returns the 'unique' Option identifier.
[中]返回“唯一”选项标识符。
代码示例来源:origin: commons-cli/commons-cli
/**
* Construct a new <code>MissingArgumentException</code>
* with the specified detail message.
*
* @param option the option requiring an argument
* @since 1.2
*/
public MissingArgumentException(Option option)
{
this("Missing argument for option: " + option.getKey());
this.option = option;
}
代码示例来源:origin: commons-cli/commons-cli
/**
* Returns the OptionGroup the <code>opt</code> belongs to.
*
* @param opt the option whose OptionGroup is being queried.
* @return the OptionGroup if <code>opt</code> is part of an OptionGroup, otherwise return null
*/
public OptionGroup getOptionGroup(Option opt)
{
return optionGroups.get(opt.getKey());
}
代码示例来源:origin: commons-cli/commons-cli
/**
* Returns the id of this Option. This is only set when the
* Option shortOpt is a single character. This is used for switch
* statements.
*
* @return the id of this Option
*/
public int getId()
{
return getKey().charAt(0);
}
代码示例来源:origin: commons-cli/commons-cli
/**
* Compares its two arguments for order. Returns a negative
* integer, zero, or a positive integer as the first argument
* is less than, equal to, or greater than the second.
*
* @param opt1 The first Option to be compared.
* @param opt2 The second Option to be compared.
* @return a negative integer, zero, or a positive integer as
* the first argument is less than, equal to, or greater than the
* second.
*/
public int compare(Option opt1, Option opt2)
{
return opt1.getKey().compareToIgnoreCase(opt2.getKey());
}
}
代码示例来源:origin: commons-cli/commons-cli
/**
* Add the specified <code>Option</code> to this group.
*
* @param option the option to add to this group
* @return this option group with the option added
*/
public OptionGroup addOption(Option option)
{
// key - option name
// value - the option
optionMap.put(option.getKey(), option);
return this;
}
代码示例来源:origin: commons-cli/commons-cli
/**
* Construct a new <code>AlreadySelectedException</code>
* for the specified option group.
*
* @param group the option group already selected
* @param option the option that triggered the exception
* @since 1.2
*/
public AlreadySelectedException(OptionGroup group, Option option)
{
this("The option '" + option.getKey() + "' was specified but an option from this group "
+ "has already been selected: '" + group.getSelected() + "'");
this.group = group;
this.option = option;
}
代码示例来源:origin: commons-cli/commons-cli
/**
* Set the selected option of this group to <code>name</code>.
*
* @param option the option that is selected
* @throws AlreadySelectedException if an option from this group has
* already been selected.
*/
public void setSelected(Option option) throws AlreadySelectedException
{
if (option == null)
{
// reset the option previously selected
selected = null;
return;
}
// if no option has already been selected or the
// same option is being reselected then set the
// selected member variable
if (selected == null || selected.equals(option.getKey()))
{
selected = option.getKey();
}
else
{
throw new AlreadySelectedException(this, option);
}
}
代码示例来源:origin: commons-cli/commons-cli
public int compare(Option opt1, Option opt2)
{
// reverses the functionality of the default comparator
return opt2.getKey().compareToIgnoreCase(opt1.getKey());
}
});
代码示例来源:origin: commons-cli/commons-cli
/**
* Add the specified option group.
*
* @param group the OptionGroup that is to be added
* @return the resulting Options instance
*/
public Options addOptionGroup(OptionGroup group)
{
if (group.isRequired())
{
requiredOpts.add(group);
}
for (Option option : group.getOptions())
{
// an Option cannot be required if it is in an
// OptionGroup, either the group is required or
// nothing is required
option.setRequired(false);
addOption(option);
optionGroups.put(option.getKey(), group);
}
return this;
}
代码示例来源:origin: commons-cli/commons-cli
/**
* Adds an option instance
*
* @param opt the option that is to be added
* @return the resulting Options instance
*/
public Options addOption(Option opt)
{
String key = opt.getKey();
// add it to the long option list
if (opt.hasLongOpt())
{
longOpts.put(opt.getLongOpt(), opt);
}
// if the option is required add it to the required list
if (opt.isRequired())
{
if (requiredOpts.contains(key))
{
requiredOpts.remove(requiredOpts.indexOf(key));
}
requiredOpts.add(key);
}
shortOpts.put(key, opt);
return this;
}
代码示例来源:origin: commons-cli/commons-cli
/**
* Removes the option or its group from the list of expected elements.
*
* @param option
*/
private void updateRequiredOptions(Option option) throws AlreadySelectedException
{
if (option.isRequired())
{
expectedOpts.remove(option.getKey());
}
// if the option is in an OptionGroup make that option the selected option of the group
if (options.getOptionGroup(option) != null)
{
OptionGroup group = options.getOptionGroup(option);
if (group.isRequired())
{
expectedOpts.remove(group);
}
group.setSelected(option);
}
}
代码示例来源:origin: commons-cli/commons-cli
/**
* Removes the option or its group from the list of expected elements.
*
* @param opt
*/
private void updateRequiredOptions(Option opt) throws ParseException
{
// if the option is a required option remove the option from
// the requiredOptions list
if (opt.isRequired())
{
getRequiredOptions().remove(opt.getKey());
}
// if the option is in an OptionGroup make that option the selected
// option of the group
if (getOptions().getOptionGroup(opt) != null)
{
OptionGroup group = getOptions().getOptionGroup(opt);
if (group.isRequired())
{
getRequiredOptions().remove(group);
}
group.setSelected(opt);
}
}
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.cli
/**
* Construct a new <code>MissingArgumentException</code>
* with the specified detail message.
*
* @param option the option requiring an argument
* @since 1.2
*/
public MissingArgumentException(Option option)
{
this("Missing argument for option: " + option.getKey());
this.option = option;
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
/**
* Construct a new <code>MissingArgumentException</code>
* with the specified detail message.
*
* @param option the option requiring an argument
* @since 1.2
*/
public MissingArgumentException(Option option)
{
this("Missing argument for option: " + option.getKey());
this.option = option;
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.cli
/**
* Returns the id of this Option. This is only set when the
* Option shortOpt is a single character. This is used for switch
* statements.
*
* @return the id of this Option
*/
public int getId()
{
return getKey().charAt(0);
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.cli
/**
* Returns the OptionGroup the <code>opt</code> belongs to.
* @param opt the option whose OptionGroup is being queried.
*
* @return the OptionGroup if <code>opt</code> is part
* of an OptionGroup, otherwise return null
*/
public OptionGroup getOptionGroup(Option opt)
{
return (OptionGroup) optionGroups.get(opt.getKey());
}
代码示例来源:origin: cytoscape.corelibs/commons-cli-1-x-cytocape-custom
/**
* add <code>opt</code> to this group
*
* @param opt the option to add to this group
* @return this option group with opt added
*/
public OptionGroup addOption(Option opt) {
// key - option name
// value - the option
optionMap.put(opt.getKey(), opt);
return this;
}
代码示例来源:origin: cytoscape.corelibs/commons-cli-1-x-cytocape-custom
/**
* Returns the OptionGroup the <code>opt</code>
* belongs to.
* @param opt the option whose OptionGroup is being queried.
*
* @return the OptionGroup if <code>opt</code> is part
* of an OptionGroup, otherwise return null
*/
public OptionGroup getOptionGroup(Option opt) {
return (OptionGroup) optionGroups.get(opt.getKey());
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
/**
* Returns the OptionGroup the <code>opt</code> belongs to.
*
* @param opt the option whose OptionGroup is being queried.
* @return the OptionGroup if <code>opt</code> is part of an OptionGroup, otherwise return null
*/
public OptionGroup getOptionGroup(Option opt)
{
return optionGroups.get(opt.getKey());
}
代码示例来源:origin: sdedit/sdedit
/**
* Returns the id of this Option. This is only set when the
* Option shortOpt is a single character. This is used for switch
* statements.
*
* @return the id of this Option
*/
public int getId()
{
return getKey().charAt(0);
}
内容来源于网络,如有侵权,请联系作者删除!