Java 类org.kohsuke.args4j.spi.MapOptionHandler 实例源码

项目:JavaGraph    文件:GrooveCmdLineParser.java   
/** Modified from superclass to add parameter controlling
 * closing bracket printing. */
protected void printSingleLineOption(PrintWriter pw, OptionHandler<?> h,
        ResourceBundle rb, boolean closeOpt) {
    pw.print(' ');
    boolean multiOccurrences =
        (h instanceof MapOptionHandler) || h.option.isMultiValued();
    boolean brackets = !h.option.required() || multiOccurrences;
    if (brackets) {
        pw.print('[');
    }
    pw.print(h.getNameAndMeta(rb));
    if (h.option.isArgument() && h.option.isMultiValued()) {
        pw.print(" ...");
    }
    if (brackets && closeOpt) {
        pw.print(']');
    }
    if (!h.option.isArgument() && multiOccurrences) {
        pw.print(h.option.required() ? '+' : '*');
    }
}