当前位置: 首页>>代码示例>>Java>>正文


Java Getopt.getOptarg方法代码示例

本文整理汇总了Java中gnu.getopt.Getopt.getOptarg方法的典型用法代码示例。如果您正苦于以下问题:Java Getopt.getOptarg方法的具体用法?Java Getopt.getOptarg怎么用?Java Getopt.getOptarg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gnu.getopt.Getopt的用法示例。


在下文中一共展示了Getopt.getOptarg方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import gnu.getopt.Getopt; //导入方法依赖的package包/类
/**
 * Parse the command line arguments and notify option listeners.
 */    
public void parse() throws OptionsException {
  Getopt g = new Getopt(application, argv, sargs.toString(), largs.toArray(new LongOpt[] {}));
  g.setOpterr(false); // We'll do our own error handling
  
  int c;
  while ((c = g.getopt()) != -1) {
    switch (c) {
    case '?':
      // Get invalid option
      int ix = g.getOptind();
      String option = argv[(ix == 0 ? 0 : ix-1)];
      throw new OptionsException(option, g.getOptarg());
    default:
      ListenerIF listener = listeners.get(new Integer(c));
      if (listener != null)
        listener.processOption((char)c, g.getOptarg());
      else
        System.err.println ("Warning: option '" + (char)c + "' ignored");
      break;
    }
  }
  
  // Get non-option arguments
  for (int i = g.getOptind(); i < argv.length ; i++) {
    arguments.add(argv[i]);
  }
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:31,代码来源:CmdlineOptions.java

示例2: processOption

import gnu.getopt.Getopt; //导入方法依赖的package包/类
private static String[] processOption(String[] args, Properties props) {
	LongOpt[] options = new LongOpt[] {
			new LongOpt("output", LongOpt.REQUIRED_ARGUMENT,null, 'o')
	};
	
	// Build auxilary structures
	HashMap<Integer, LongOpt> shortOptionMap = new HashMap<Integer, LongOpt>();
	StringBuffer decl = new StringBuffer();
	for(LongOpt o: options) {
		shortOptionMap.put(o.getVal(),o);
		decl.append((char)o.getVal());
		if(o.getHasArg() == LongOpt.OPTIONAL_ARGUMENT) {
			decl.append("::");
		} else if (o.getHasArg() == LongOpt.REQUIRED_ARGUMENT) {
			decl.append(":");
		}
	}
	Getopt g = new Getopt("anyurl", args, decl.toString(), options);
	 
	int c= 0;
	while ((c = g.getopt()) != -1) {
		LongOpt opt = shortOptionMap.get(c);
		String optName = opt.getName();
		String optVal = g.getOptarg();
		props.put(optName, optVal);
	}
	
	// NB: Getopt moves non options to the end
	return Arrays.copyOfRange(args, g.getOptind(), args.length);
}
 
开发者ID:bhabegger,项目名称:anyurl,代码行数:31,代码来源:App.java

示例3: parseArguments

import gnu.getopt.Getopt; //导入方法依赖的package包/类
static boolean parseArguments(String [] argv) {
	Getopt g = new Getopt("client", argv, "ds:p:");

	int c;
	String arg;

	while ((c = g.getopt()) != -1) {
		switch(c) {
			case 'd':
				_debug = true;
				break;
			case 's':
				_server = g.getOptarg();
				break;
			case 'p':
				arg = g.getOptarg();
				_port = Integer.parseInt(arg);
				break;
			case '?':
				System.out.print("getopt() returned " + c + "\n");
				break; // getopt() already printed an error
			default:
				System.out.print("getopt() returned " + c + "\n");
		}
	}
	
	if (_server == null)
		return false;
	
	if ((_port < 1024) || (_port > 65535)) {
		System.out.println("Error: Port must be in the range 1024 <= port <= 65535");
		return false;
	}

	return true;
}
 
开发者ID:dLobatog,项目名称:ASAFACMS,代码行数:37,代码来源:Client.java

示例4: parseArguments

import gnu.getopt.Getopt; //导入方法依赖的package包/类
/**
 * Parses the report command lime arguments.
 *
 * @param args array containing the command line arguments.
 */
@Override
public void parseArguments(String[] args) {
  Getopt g = new Getopt("gate.util.reporting.DocTimeReporter", args,
      "i:m:d:p:o:l:h");
  int c;
  String argNoOfDocs = null;
  while ((c = g.getopt()) != -1) {
    switch (c) {
    // -i inputFile
    case 'i':
      String argInPath = g.getOptarg();
      if (argInPath != null) {
        setBenchmarkFile(new File(argInPath));
      }
      break;
    // -m printMedia
    case 'm':
      String argPrintMedia = g.getOptarg();
      if (argPrintMedia != null) {
        setPrintMedia(argPrintMedia);
      }
      break;
    // -d noOfDocs
    case 'd':
      argNoOfDocs = g.getOptarg();
      if (argNoOfDocs == null) {
        setMaxDocumentInReport(maxDocumentInReport);
      }
      break;
    // -p prName
    case 'p':
      String argPrName = g.getOptarg();
      if (argPrName != null) {
        setPRMatchingRegex(argPrName);
      } else {
        setPRMatchingRegex(PRMatchingRegex);
      }
      break;
    // -o Report File
    case 'o':
      String argOutPath = g.getOptarg();
      if (argOutPath != null) {
        setReportFile(new File(argOutPath));
      }
      break;
    // -l logical start
    case 'l':
      String argLogicalStart = g.getOptarg();
      if (argLogicalStart != null) {
        setLogicalStart(argLogicalStart);
      }
      break;
    // -h usage information
    case 'h':
    case '?':
      usage();
      System.exit(STATUS_NORMAL);
      break;

    default:
      usage();
      System.exit(STATUS_ERROR);
      break;

    } // getopt switch
  }
  if (argNoOfDocs != null) {
    try {
      setMaxDocumentInReport(Integer.parseInt(argNoOfDocs));
    } catch (NumberFormatException e) {
      e.printStackTrace();
      usage();
      System.exit(STATUS_ERROR);
    }
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:82,代码来源:DocTimeReporter.java

示例5: processCommandLine

import gnu.getopt.Getopt; //导入方法依赖的package包/类
private void processCommandLine(String[] args) {

        String programName = System.getProperty("program.name", "Mobicents Media Server");

        int c;
        String arg;
        LongOpt[] longopts = new LongOpt[2];
        longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h');
        longopts[1] = new LongOpt("host", LongOpt.REQUIRED_ARGUMENT, null, 'b');

        Getopt g = new Getopt("SMSC", args, "-:b:h", longopts);
        g.setOpterr(false); // We'll do our own error handling
        //
        while ((c = g.getopt()) != -1) {
            switch (c) {

                //
                case 'b':
                    arg = g.getOptarg();
                    System.setProperty(SMSC_BIND_ADDRESS, arg);

                    break;
                //

                case 'h':
                    System.out.println("usage: " + programName + " [options]");
                    System.out.println();
                    System.out.println("options:");
                    System.out.println("    -h, --help                    Show this help message");
                    System.out.println("    -b, --host=<host or ip>       Bind address for all Mobicents SMSC services");
                    System.out.println();
                    System.exit(0);
                    break;

                case ':':
                    System.out.println("You need an argument for option " + (char) g.getOptopt());
                    System.exit(0);
                    break;
                //
                case '?':
                    System.out.println("The option '" + (char) g.getOptopt() + "' is not valid");
                    System.exit(0);
                    break;
                //
                default:
                    System.out.println("getopt() returned " + c);
                    break;
            }
        }

        if (System.getProperty(SMSC_BIND_ADDRESS) == null) {
            System.setProperty(SMSC_BIND_ADDRESS, "127.0.0.1");
        }

    }
 
开发者ID:RestComm,项目名称:camelgateway,代码行数:56,代码来源:Main.java

示例6: getConfigFromArgv

import gnu.getopt.Getopt; //导入方法依赖的package包/类
public static boolean getConfigFromArgv(String argv[])
{

    int c;
    String arg;

    LongOpt [] longopts = new LongOpt[10];
    longopts[0] = new LongOpt(SERVER_MODE, LongOpt.NO_ARGUMENT, null, 'S');
    longopts[1] = new LongOpt(METHOD, LongOpt.REQUIRED_ARGUMENT, null, 'm');
    longopts[2] = new LongOpt(PASSWORD, LongOpt.REQUIRED_ARGUMENT, null, 'k');
    longopts[3] = new LongOpt(SERVER_PORT, LongOpt.REQUIRED_ARGUMENT, null, 'p');
    longopts[4] = new LongOpt(AUTH, LongOpt.NO_ARGUMENT, null, 'a');
    longopts[5] = new LongOpt(SERVER_ADDR, LongOpt.REQUIRED_ARGUMENT, null, 's');
    longopts[6] = new LongOpt(LOCAL_PORT, LongOpt.REQUIRED_ARGUMENT, null, 'l');
    longopts[7] = new LongOpt(CONFIG, LongOpt.REQUIRED_ARGUMENT, null, 'c');
    longopts[8] = new LongOpt(TIMEOUT, LongOpt.REQUIRED_ARGUMENT, null, 't');
    longopts[9] = new LongOpt(HELP, LongOpt.NO_ARGUMENT, null, 'h');

    Getopt g = new Getopt("shadowsocks", argv, "Sm:k:p:as:l:c:t:h", longopts);

    while ((c = g.getopt()) != -1)
    {
        switch(c)
        {
            case 'm':
                arg = g.getOptarg();
                log.debug("CMD:Crypto method: " + arg);
                GlobalConfig.get().setMethod(arg);
                break;
            case 'k':
                arg = g.getOptarg();
                log.debug("CMD:Password: " + arg);
                GlobalConfig.get().setPassowrd(arg);
                break;
            case 'p':
                arg = g.getOptarg();
                int port = Integer.parseInt(arg);
                log.debug("CMD:Server port: " + port);
                GlobalConfig.get().setPort(port);
                break;
            case 'a':
                log.debug("CMD:OTA enforcing mode.");
                GlobalConfig.get().setOTAEnabled(true);
                break;
            case 'S':
                log.debug("CMD:Server mode.");
                GlobalConfig.get().setServerMode(true);
                break;
            case 's':
                arg = g.getOptarg();
                log.debug("CMD:Server address: " + arg);
                GlobalConfig.get().setServer(arg);
                break;
            case 'l':
                arg = g.getOptarg();
                int lport = Integer.parseInt(arg);
                log.debug("CMD:Local port: " + lport);
                GlobalConfig.get().setLocalPort(lport);
                break;
            case 'c':
                arg = g.getOptarg();
                log.debug("CMD:Config file: " + arg);
                GlobalConfig.get().setConfigFile(arg);
                break;
            case 't':
                arg = g.getOptarg();
                int timeout = Integer.parseInt(arg);
                log.debug("CMD:timeout: " + timeout);
                GlobalConfig.get().setTimeout(timeout);
                break;
            case 'h':
            case '?':
            default:
                help();
                return false;
        }
    }
    return true;
}
 
开发者ID:Bestoa,项目名称:shadowsocks-vertx,代码行数:80,代码来源:GlobalConfig.java

示例7: main

import gnu.getopt.Getopt; //导入方法依赖的package包/类
public static void
main(String[] argv)
{
 int c;
 String arg;
 LongOpt[] longopts = new LongOpt[3];
 // 
 StringBuffer sb = new StringBuffer();
 longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h');
 longopts[1] = new LongOpt("outputdir", LongOpt.REQUIRED_ARGUMENT, sb, 'o'); 
 longopts[2] = new LongOpt("maximum", LongOpt.OPTIONAL_ARGUMENT, null, 2);
 // 
 Getopt g = new Getopt("testprog", argv, "-:bc::d:hW;", longopts);
 g.setOpterr(false); // We'll do our own error handling
 //
 while ((c = g.getopt()) != -1)
   switch (c)
     {
        case 0:
          arg = g.getOptarg();
          System.out.println("Got long option with value '" +
                             (char)(new Integer(sb.toString())).intValue()
                             + "' with argument " +
                             ((arg != null) ? arg : "null"));
          break;
          //
        case 1:
          System.out.println("I see you have return in order set and that " +
                             "a non-option argv element was just found " +
                             "with the value '" + g.getOptarg() + "'");
          break;
          //
        case 2:
          arg = g.getOptarg();
          System.out.println("I know this, but pretend I didn't");
          System.out.println("We picked option " +
                             longopts[g.getLongind()].getName() +
                           " with value " + 
                           ((arg != null) ? arg : "null"));
          break;
          //
        case 'b':
          System.out.println("You picked plain old option " + (char)c);
          break;
          //
        case 'c':
        case 'd':
          arg = g.getOptarg();
          System.out.println("You picked option '" + (char)c + 
                             "' with argument " +
                             ((arg != null) ? arg : "null"));
          break;
          //
        case 'h':
          System.out.println("I see you asked for help");
          break;
          //
        case 'W':
          System.out.println("Hmmm. You tried a -W with an incorrect long " +
                             "option name");
          break;
          //
        case ':':
          System.out.println("Doh! You need an argument for option " +
                             (char)g.getOptopt());
          break;
          //
        case '?':
          System.out.println("The option '" + (char)g.getOptopt() + 
                           "' is not valid");
          break;
          //
        default:
          System.out.println("getopt() returned " + c);
          break;
     }
 //
 for (int i = g.getOptind(); i < argv.length ; i++)
   System.out.println("Non option argv element: " + argv[i] + "\n");
}
 
开发者ID:mrmaxent,项目名称:Maxent,代码行数:81,代码来源:GetoptDemo.java

示例8: parseArguments

import gnu.getopt.Getopt; //导入方法依赖的package包/类
private static BenchmarkTest parseArguments(String[] args) throws Exception
{
   String shortOpts = "t:r:s:i:a:vh";
   LongOpt[] longOpts =
   {new LongOpt("deployment", LongOpt.REQUIRED_ARGUMENT, null, 'd'),
         new LongOpt("threads", LongOpt.REQUIRED_ARGUMENT, null, 't'),
         new LongOpt("runs", LongOpt.REQUIRED_ARGUMENT, null, 'r'),
         new LongOpt("sleep", LongOpt.REQUIRED_ARGUMENT, null, 's'),
         new LongOpt("iterations", LongOpt.REQUIRED_ARGUMENT, null, 'i'),
         new LongOpt("address", LongOpt.REQUIRED_ARGUMENT, null, 'a'),
         new LongOpt("verbose", LongOpt.NO_ARGUMENT, null, 'v'), new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h')};

   Getopt getopt = new Getopt("Benchmark-runner", args, shortOpts, longOpts);
   int c;
   while ((c = getopt.getopt()) != -1)
   {
      switch (c)
      {
         case 't' :
            threadCount = Integer.parseInt(getopt.getOptarg());
            break;
         case 'r' :
            runs = Integer.parseInt(getopt.getOptarg());
            break;
         case 's' :
            sleep = Long.parseLong(getopt.getOptarg());
            break;
         case 'i' :
            iterations = Integer.parseInt(getopt.getOptarg());
            break;
         case 'a' :
            address = getopt.getOptarg();
            break;
         case 'v' :
            verbose = true;
            break;
         case 'h' :
            printHelp();
            System.exit(0);
         case '?' :
            System.exit(1);
      }
   }

   int classPos = getopt.getOptind();
   if (classPos >= args.length)
   {
      System.err.println("Error: test-class was not specified!");
      printHelp();
      System.exit(1);
   }

   try
   {
      Class<?> clazz = Class.forName(args[classPos]);
      System.out.println(BenchmarkTest.class.isAssignableFrom(clazz));
      System.out.println(clazz.isAssignableFrom(BenchmarkTest.class));

      return (BenchmarkTest) clazz.newInstance();
   }
   catch (Exception e)
   {
      System.out.println("Cannot instanciate " + args[classPos]);
      throw e;
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:67,代码来源:Runner.java

示例9: main

import gnu.getopt.Getopt; //导入方法依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	// TODO Auto-generated method stub
	String GTFfilepath = "";
	String input_file = "";
	String reference_FASTA_file = "";
	boolean verbose = false;
	boolean print_exons = false;
	boolean print_domain = false;

       Getopt g = new Getopt("MultiFusionSequenceFromGTF", args, "evdg:r:i:");
       //
       int c;

       while ((c = g.getopt()) != -1)
       {
           switch(c)
           {
   			case 'e':
   				print_exons = true;
   				break;

   			case 'v':
   				verbose = true;
   				break;

       		case 'd':
       			print_domain = true;                	 
       			break;

       		case 'g':
       			GTFfilepath = g.getOptarg();                	 
       			break;

       		case 'i':
       			input_file = g.getOptarg();                	 
       			break;

       		case 'r':
           		reference_FASTA_file = g.getOptarg();                	 
           		break;

                case '?':
               	 System.exit(1);
               	 break;

                default:
               	 System.exit(1);
               	 System.out.println("default");
           }
       }
	
       if (	
       		GTFfilepath.compareTo("")==0 || 
       		input_file.compareTo("")==0 || 
       		reference_FASTA_file.compareTo("")==0
       	)
       {
       	System.err.println("Error!\nusage: java -jar MultiFusionSequenceFromGTF" +
       			" -g [GTF file list] " +
       			" -i [Fusion Input File ] " +
       			" -r [reference FASTA file] " +
       			" -e [Print Exons (Optional)]" +
       			" -d [Print Domains (Optional)]" +
       			" -v [Verbose (Optional)]"
       	);
       	System.exit(1);
       }

       MultiFusionSequenceFromGTF mfsfgtf = new MultiFusionSequenceFromGTF(GTFfilepath, input_file, reference_FASTA_file, verbose, print_exons, print_domain);

	
}
 
开发者ID:RabadanLab,项目名称:Pegasus,代码行数:76,代码来源:MultiFusionSequenceFromGTF.java

示例10: readParameters

import gnu.getopt.Getopt; //导入方法依赖的package包/类
public Properties readParameters( String[] args ) throws java.net.MalformedURLException {
Properties params = new Properties();

params.setProperty( "host", HOST );

// Read parameters
LongOpt[] longopts = new LongOpt[8];
// General parameters
longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h');
longopts[1] = new LongOpt("debug", LongOpt.OPTIONAL_ARGUMENT, null, 'd');
longopts[2] = new LongOpt("D", LongOpt.REQUIRED_ARGUMENT, null, 'D');
// Service parameters
longopts[3] = new LongOpt("server", LongOpt.REQUIRED_ARGUMENT, null, 'S');
longopts[4] = new LongOpt("rest", LongOpt.NO_ARGUMENT, null, 'r');

Getopt g = new Getopt("", args, "rhD:d::S:", longopts);
int c;
String arg;

while ((c = g.getopt()) != -1) {
    switch (c) {
    case 'h' :
	usage();
	System.exit(0);
    case 'd' :
	/* Debug level  */
	arg = g.getOptarg();
	if ( arg != null ) debug = Integer.parseInt(arg.trim());
	else debug = 4;
	break;
    case 'r' :
	/* Use direct HTTP interface (REST)  */
	rest = true;
	break;
    case 'S' :
	/* HTTP Server + port */
	arg = g.getOptarg();
	SERVUrl = arg;
	break;
    case 'D' :
	/* Parameter definition */
	arg = g.getOptarg();
	int index = arg.indexOf('=');
	if ( index != -1 ) {
	    params.setProperty( arg.substring( 0, index), 
				 arg.substring(index+1));
	} else {
	    System.err.println("Bad parameter syntax: "+g);
	    usage();
	    System.exit(0);
	}
	break;
    }
}

if (debug > 0) {
    params.setProperty("debug", Integer.toString( debug ) );
} else if ( params.getProperty("debug") != null ) {
    debug = Integer.parseInt((String)params.getProperty("debug"));
}

// Store the remaining arguments in param
int i = g.getOptind();
if ( args.length < i + 1 ){
    usage();
    System.exit(-1);
} else {
    params.setProperty("command", args[i++]);
    for ( int k = 1; i < args.length; i++,k++ ){
	params.setProperty("arg"+k, args[i]);
    }
}
return params;
   }
 
开发者ID:dozed,项目名称:align-api-project,代码行数:75,代码来源:AlignmentClient.java

示例11: run

import gnu.getopt.Getopt; //导入方法依赖的package包/类
public void run(String[] args) throws Exception {
String listFile = "";
LongOpt[] longopts = new LongOpt[10];

	longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h');
longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o');
longopts[2] = new LongOpt("format", LongOpt.REQUIRED_ARGUMENT, null, 'f');
longopts[3] = new LongOpt("type", LongOpt.REQUIRED_ARGUMENT, null, 't');
longopts[4] = new LongOpt("debug", LongOpt.OPTIONAL_ARGUMENT, null, 'd');
longopts[5] = new LongOpt("sup", LongOpt.REQUIRED_ARGUMENT, null, 's');
longopts[6] = new LongOpt("list", LongOpt.REQUIRED_ARGUMENT, null, 'l');
longopts[7] = new LongOpt("color", LongOpt.OPTIONAL_ARGUMENT, null, 'c');
longopts[8] = new LongOpt("reference", LongOpt.REQUIRED_ARGUMENT, null, 'r');
longopts[9] = new LongOpt("directory", LongOpt.REQUIRED_ARGUMENT, null, 'w');

Getopt g = new Getopt("", args, "ho:a:d::l:f:t:r:w:c::", longopts);
int c;
String arg;

while ((c = g.getopt()) != -1) {
    switch (c) {
    case 'h' :
	usage();
	return;
    case 'o' :
	/* Write output here */
	filename = g.getOptarg();
	break;
    case 'r' :
	/* File name for the reference alignment */
	reference = g.getOptarg();
	break;
    case 'f' :
	/* Sequence of results to print */
	format = g.getOptarg();
	break;
    case 't' :
	/* Type of output (tex/html/xml/ascii) */
	type = g.getOptarg();
	break;
    case 's' :
	/* Print per type or per algo */
	dominant = g.getOptarg();
	break;
    case 'c' :
	/* Print colored lines */
	color = "lightblue";
	    //dominant = g.getOptarg();
	break;
    case 'l' :
	/* List of filename */
	listFile = g.getOptarg();
	break;
    case 'd' :
	/* Debug level  */
	arg = g.getOptarg();
	if ( arg != null ) debug = Integer.parseInt(arg.trim());
	else debug = 4;
	break;
    case 'w' :
	/* Use the given ontology directory */
    arg = g.getOptarg();
    if ( arg != null ) ontoDir = g.getOptarg();
    else ontoDir = null;
	break;
    }
}

listAlgo = new Vector<String>();
for ( String s : listFile.split(",") ) {
    listAlgo.add( s );	    
}

params = new Properties();
if (debug > 0) params.setProperty( "debug", Integer.toString( debug-1 ) );

print( iterateDirectories() );
   }
 
开发者ID:dozed,项目名称:align-api-project,代码行数:79,代码来源:ExtGroupEval.java

示例12: run

import gnu.getopt.Getopt; //导入方法依赖的package包/类
public void run(String[] args) throws Exception {
String listFile = "";
LongOpt[] longopts = new LongOpt[10];

	longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h');
longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o');
longopts[2] = new LongOpt("format", LongOpt.REQUIRED_ARGUMENT, null, 'f');
longopts[3] = new LongOpt("type", LongOpt.REQUIRED_ARGUMENT, null, 't');
longopts[4] = new LongOpt("debug", LongOpt.OPTIONAL_ARGUMENT, null, 'd');
longopts[5] = new LongOpt("sup", LongOpt.REQUIRED_ARGUMENT, null, 's');
longopts[6] = new LongOpt("list", LongOpt.REQUIRED_ARGUMENT, null, 'l');
longopts[7] = new LongOpt("color", LongOpt.OPTIONAL_ARGUMENT, null, 'c');
longopts[8] = new LongOpt("reference", LongOpt.REQUIRED_ARGUMENT, null, 'r');
longopts[9] = new LongOpt("directory", LongOpt.REQUIRED_ARGUMENT, null, 'w');

Getopt g = new Getopt("", args, "ho:a:d::l:f:t:r:w:c::", longopts);
int c;
String arg;

while ((c = g.getopt()) != -1) {
    switch (c) {
    case 'h' :
	usage();
	return;
    case 'o' :
	/* Write output here */
	filename = g.getOptarg();
	break;
    case 'r' :
	/* File name for the reference alignment */
	reference = g.getOptarg();
	break;
    case 'f' :
	/* Sequence of results to print */
	format = g.getOptarg();
	break;
    case 't' :
	/* Type of output (tex/html/xml/ascii) */
	type = g.getOptarg();
	break;
    case 's' :
	/* Print per type or per algo */
	dominant = g.getOptarg();
	break;
    case 'c' :
	/* Print colored lines */
	arg = g.getOptarg();
	if ( arg != null )  {
	    color = arg.trim();
	} else color = "lightblue";
	break;
    case 'l' :
	/* List of filename */
	listFile = g.getOptarg();
	break;
    case 'd' :
	/* Debug level  */
	arg = g.getOptarg();
	if ( arg != null ) debug = Integer.parseInt(arg.trim());
	else debug = 4;
	break;
    case 'w' :
	/* Use the given ontology directory */
    arg = g.getOptarg();
    if ( arg != null ) ontoDir = g.getOptarg();
    else ontoDir = null;
	break;
    }
}

listAlgo = new Vector<String>();
for ( String s : listFile.split(",") ) {
    listAlgo.add( s );	    
}

params = new Properties();
if (debug > 0) params.setProperty( "debug", Integer.toString( debug-1 ) );

print( iterateDirectories() );
   }
 
开发者ID:dozed,项目名称:align-api-project,代码行数:81,代码来源:GroupEval.java

示例13: main

import gnu.getopt.Getopt; //导入方法依赖的package包/类
public static void main(String[] args) throws ParseException, IOException {
	// 运行程序需要指定参数,否则就打印帮助信息
	if ( args.length == 0 ) {
		printHelp();
		return;
	}
	
	// 创建一个闹铃设置对象
	Option option = new Option();
	// 默认情况下闹铃不重复
	option.repeatSetting = RepeatSetting.NoRepeat;
	// 创建一个将字符串格式的日期解析成Java日期实例的对象。
	DateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
	// Getopt是用来解析命令行参数的
	// 其具体用法请参见:
	// www.urbanophile.com/arenn/hacking/getopt/gnu.getopt.Getopt.html
	Getopt g = new Getopt("alarm", args, "a:r:");
	int c;
	String arg;
	// 通过循环解析命令行传入的每一个参数并填充闹铃设置。
	while ((c = g.getopt()) != -1) {
		switch (c) {
		// -a表示闹铃时间设置。
		case 'a':
			// 其后需要跟有一个格式为“yyyy-MM-dd hh:mm:ss”的日期字符串
			// 如:-a "2012-12-15 16:15:00"
			arg = g.getOptarg();
			// 将字符串格式的日期解析成一个Java可理解的对象
			option.alarmTime = format.parse(arg);
			break;
			
			// -r 表示闹铃重复设置
		case 'r':
			// 其后只能跟有字符"D“、”W“、”M“
			arg = g.getOptarg();
			// 字符”D“表示每日重复
			if ( "D".compareToIgnoreCase(arg) == 0 ) {
				option.repeatSetting = RepeatSetting.EveryDay;
			} else if ( "W".compareToIgnoreCase(arg) == 0 ) {
				// 字符”W“表示每周重复
				option.repeatSetting = RepeatSetting.EveryWeek;
			} else if ( "M".compareToIgnoreCase(arg) == 0 ) {
				// 字符”M“表示每月重复
				option.repeatSetting = RepeatSetting.EveryMonth;
			}
			break;
			
		default:
			printHelp();
		}
	}
	
	// 去掉下面一行注释,并将TestableAlarm注释去掉,就可以看使用
	// Timer自身提供的功能实现的闹钟效果
	// 使用闹铃设置对象创建闹铃
	// Alarm alarm = new Alarm(option);
	TestableAlarm alarm = new TestableAlarm(option, new SimpleGetDate());
	// 启动闹铃
	alarm.start();
	
	// 一直运行直到用户关闭程序
	System.out.println("按任意键退出程序!");
	System.in.read();
	// 用户打算关闭程序,执行清理操作
	alarm.stop();
}
 
开发者ID:shiyimin,项目名称:androidtestdebug,代码行数:67,代码来源:Program.java

示例14: InitCommandLine

import gnu.getopt.Getopt; //导入方法依赖的package包/类
public static FastAlign InitCommandLine(String[] argv) {
	LongOpt[] options = {
			new LongOpt("input",                     LongOpt.REQUIRED_ARGUMENT, null,               'i' ),
			new LongOpt("reverse",                   LongOpt.NO_ARGUMENT,       new StringBuffer(),  1  ),
			new LongOpt("iterations",                LongOpt.REQUIRED_ARGUMENT, null,               'I' ),
			new LongOpt("favor_diagonal",            LongOpt.NO_ARGUMENT,       new StringBuffer(),  0  ),
			new LongOpt("p0",                        LongOpt.REQUIRED_ARGUMENT, null,               'p' ),
			new LongOpt("diagonal_tension",          LongOpt.REQUIRED_ARGUMENT, null,               'T' ),
			new LongOpt("optimize_tension",          LongOpt.NO_ARGUMENT,       new StringBuffer(),  1  ),
			new LongOpt("variational_bayes",         LongOpt.NO_ARGUMENT,       new StringBuffer(),  1  ),
			new LongOpt("alpha",                     LongOpt.REQUIRED_ARGUMENT, null,               'a' ),
			new LongOpt("no_null_word",              LongOpt.NO_ARGUMENT,       new StringBuffer(),  1  ),
			new LongOpt("conditional_probabilities", LongOpt.REQUIRED_ARGUMENT, null,               'c' ),
			new LongOpt("existing_probabilities",    LongOpt.REQUIRED_ARGUMENT, null,               'e' )		
	};

	String input = "";
	String conditional_probability_filename = "";
	String existing_probability_filename = "";
	boolean is_reverse = false;
	int iterations = 5;
	boolean favor_diagonal = false;
	double prob_align_null = 0.08;
	double diagonal_tension = 4.0;
	boolean optimize_tension = false;
	boolean variational_bayes = false;
	double alpha = 0.01;
	boolean no_null_word = false;	

	Getopt g = new Getopt("fast_align", argv, "i:rI:dp:T:ova:Nc:e:", options);
	while (true) {
		int c = g.getopt();
		if (c == -1) break;
		switch(c) {
		case 'i': input = g.getOptarg(); break;
		case 'r': is_reverse = true; break;
		case 'I': iterations = Integer.valueOf(g.getOptarg()); break;
		case 'd': favor_diagonal = true; break;
		case 'p': prob_align_null = Double.valueOf(g.getOptarg()); break;
		case 'T': diagonal_tension = Double.valueOf(g.getOptarg()); break;
		case 'o': optimize_tension = true; break;
		case 'v': variational_bayes = true; break;
		case 'a': alpha = Double.valueOf(g.getOptarg()); break;
		case 'N': no_null_word = true; break;
		case 'c': conditional_probability_filename = g.getOptarg(); break;
		case 'e': existing_probability_filename = g.getOptarg(); break;
		default: return null;
		}
	}
	if (input.length() == 0) return null;
	return new FastAlign(
			input,
			conditional_probability_filename,
			existing_probability_filename,
			is_reverse,
			iterations,
			favor_diagonal,
			prob_align_null,
			diagonal_tension,
			optimize_tension,
			variational_bayes,
			alpha,
			no_null_word);
}
 
开发者ID:dowobeha,项目名称:fast_align.java,代码行数:65,代码来源:FastAlign.java


注:本文中的gnu.getopt.Getopt.getOptarg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。