Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2011 Tatsuhiro Tsujikawa
   *
   * 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 net.sourceforge.argparse4j;
 
 import java.util.List;
 
Factory class to create new ArgumentParser.
 
 public final class ArgumentParsers {

    
Intentionally made private to avoid to get instantiated in application code.
 
     private ArgumentParsers() {
     }

    

Creates net.sourceforge.argparse4j.inf.ArgumentParser with given program name.

This is equivalent with newArgumentParser(prog, true, "-", null).

Parameters:
prog The program name
Returns:
ArgumentParser object
 
     public static ArgumentParser newArgumentParser(String prog) {
         return newArgumentParser(progtrue.,
                 null);
     }

    

Creates net.sourceforge.argparse4j.inf.ArgumentParser with given program name and addHelp.

This is equivalent with ArgumentParser(prog, addHelp, "-", null).

Parameters:
prog The program name
addHelp If true, -h/--help are available. If false, they are not.
Returns:
ArgumentParser object
 
     public static ArgumentParser newArgumentParser(String progboolean addHelp) {
         return newArgumentParser(progaddHelp,
                 .null);
     }

    

Creates net.sourceforge.argparse4j.inf.ArgumentParser with given program name, addHelp and prefixChars.

This is equivalent with ArgumentParser(prog, addHelp, prefixChars, null).

Parameters:
prog The program name
addHelp If true, -h/--help are available. If false, they are not.
prefixChars The set of characters that prefix optional arguments.
Returns:
ArgumentParser object.
    public static ArgumentParser newArgumentParser(String prog,
            boolean addHelpString prefixChars) {
        return newArgumentParser(progaddHelpprefixCharsnull);
    }

    

Creates net.sourceforge.argparse4j.inf.ArgumentParser with given program name, addHelp and prefixChars.

Parameters:
prog The program name
addHelp If true, -h/--help are available. If false, they are not.
prefixChars The set of characters that prefix optional arguments.
fromFilePrefix The set of characters that prefix file path from which additional arguments should be read. Specify null to disable reading arguments from file.
Returns:
ArgumentParser object.
    public static ArgumentParser newArgumentParser(String prog,
            boolean addHelpString prefixCharsString fromFilePrefix) {
        return new ArgumentParserImpl(progaddHelpprefixChars,
                fromFilePrefix
                        && .contains(Locale.getDefault()
                                .getLanguage()) ? new CJKTextWidthCounter()
                        : new ASCIITextWidthCounter());
    }
    private static final String cjkWidthLangsSrc_[] = { "ja""zh""ko" };
    private static List<StringcjkWidthLangs_ = Arrays
            .asList();
    private static boolean cjkWidthHack_ = true;

    

Set true to enable CJK width hack.

The CJK width hack is treat Unicode characters having East Asian Width property Wide/Full/Ambiguous to have twice a width of ascii characters when formatting help message if locale is "ja", "zh" or "ko". This feature is enabled by default.

Parameters:
flag true or false
    public static void setCJKWidthHack(boolean flag) {
         = flag;
    }

    
Returns true iff CJK width hack is enabled.

Returns:
true or false
    public static boolean getCjkWidthHack() {
        return ;
    }
New to GrepCode? Check out our FAQ X