Package gnu.getopt

Examples of gnu.getopt.Getopt


   * Parse command strings from the command line arguments
   */
  public void parseCommands(String[] args)
  {
    String argString = "o:e:il:t:sw:h:";
    Getopt opt = new Getopt("SingleFeaturePanel", args, argString);
    opt.setOpterr(false);

    int c = -1;
    while ((c = opt.getopt()) != -1)
    { 
      switch (c)
      {
      case 'o':
        pngOutputFileName = opt.getOptarg();
        System.out.println("png output filename: " + pngOutputFileName);
        break;
      case 'e':
        edlFileName = opt.getOptarg();
        System.out.println("edlFileName: " + edlFileName);
        break;
      case 'i':
        setShowPanelInfo(true);
        break;
      case 'l':
      {
        int type = NO_TIMELINE;
        String typeString = opt.getOptarg();
       
        if (typeString.equals("NO_TIMELINE"))
          type = NO_TIMELINE;
        else if (typeString.equals("TENTHS_TIMELINE"))
          type = TENTHS_TIMELINE;
        else if (typeString.equals("SECS_TIMELINE"))
          type = SECS_TIMELINE;
        else if (typeString.equals("MINS_TIMELINE"))
          type = MINS_TIMELINE;
        else
          System.out.println("I don't know this kind of timeline: " + typeString);
       
        //System.out.println("timeline type: " + type);
        setShowTimeline(type);
        break;
      }
      case 't':
      {
        int type = NO_SEG_TICKS;
        String typeString = opt.getOptarg();
       
        if (typeString.equals("NO_SEG_TICKS"))
        {
          type = NO_SEG_TICKS;
        }
        else if (typeString.equals("SHORT_SEG_TICKS"))
        {
          type = SHORT_SEG_TICKS;
        }
        else if (typeString.equals("FULL_SEG_TICKS"))
        {
          type = FULL_SEG_TICKS; 
        }
        else
        {
          System.out.println("I don't know this kind of segment tick: " + typeString);
         
        }
        setSegTickType(type);
        //System.out.println("string: " + typeString + " setting seg type: " + type);
        break;
      }
      case 's':
        setShowScale(true);
        break;
      case 'w':
        int w = new Integer(opt.getOptarg()).intValue();
        int currH = getHeight();
        setPreferredSize(new Dimension(w, currH));
        setSize(w, currH);
        break;
      case 'h':
        int h = new Integer(opt.getOptarg()).intValue();
        int currW = getWidth();
        setPreferredSize(new Dimension(currW, h));
        setSize(currW, h);
        break;
      }
View Full Code Here


                throw new RuntimeException("unable to create default IRI base");
            }
            Collection<IRI> ontologies=new LinkedList<IRI>();
            boolean didSomething=false;
            {
                Getopt g=new Getopt("hermit",argv,Option.formatOptionsString(options),Option.createLongOpts(options));
                g.setOpterr(false);
                int opt;
                while ((opt=g.getopt())!=-1) {
                    switch (opt) {
                    // meta:
                    case 'h': {
                        System.out.println(usageString);
                        for (String s : helpHeader)
                            System.out.println(s);
                        System.out.println(Option.formatOptionHelp(options));
                        for (String s : footer)
                            System.out.println(s);
                        System.exit(0);
                        didSomething=true;
                    }
                        break;
                    case 'V': {
                        System.out.println(versionString);
                        for (String s : footer)
                            System.out.println(s);
                        System.exit(0);
                        didSomething=true;
                    }
                        break;
                    case 'v': {
                        String arg=g.getOptarg();
                        if (arg==null) {
                            verbosity+=1;
                        }
                        else
                            try {
                                verbosity+=Integer.parseInt(arg,10);
                            }
                            catch (NumberFormatException e) {
                                throw new UsageException("argument to --verbose must be a number");
                            }
                    }
                        break;
                    case 'q': {
                        String arg=g.getOptarg();
                        if (arg==null) {
                            verbosity-=1;
                        }
                        else
                            try {
                                verbosity-=Integer.parseInt(arg,10);
                            }
                            catch (NumberFormatException e) {
                                throw new UsageException("argument to --verbose must be a number");
                            }
                    }
                        break;
                    case 'o': {
                        String arg=g.getOptarg();
                        if (arg==null)
                            throw new UsageException("--output requires an argument");
                        if (arg.equals("-"))
                            output=new PrintWriter(System.out);
                        else {
                            java.io.FileOutputStream f;
                            try {
                                f=new java.io.FileOutputStream(arg);
                            }
                            catch (java.io.FileNotFoundException e) {
                                throw new IllegalArgumentException("unable to open "+arg+" for writing");
                            }
                            catch (SecurityException e) {
                                throw new IllegalArgumentException("unable to write to "+arg);
                            }
                            output=new PrintWriter(f);
                        }
                    }
                        break;
                    case kPremise: {
                        String arg=g.getOptarg();
                        if (arg==null)
                            throw new UsageException("--premise requires a IRI as argument");
                        else {
                            ontologies.add(IRI.create(arg));
                        }
                    }
                        break;
                    case kConclusion: {
                        String arg=g.getOptarg();
                        if (arg==null)
                            throw new UsageException("--conclusion requires a IRI as argument");
                        else {
                            conclusionIRI=IRI.create(arg);
                        }
                    }
                        break;
                    // actions:
                    case 'l': {
                        // load is a no-op; loading happens no matter what the user asks
                    }
                        break;
                    case 'c': {
                        actions.add(new ClassifyAction(g.getOptarg()));
                    }
                        break;
                    case 'k': {
                        String arg=g.getOptarg();
                        if (arg==null) {
                            arg="<http://www.w3.org/2002/07/owl#Thing>";
                        }
                        actions.add(new SatisfiabilityAction(arg));
                    }
                        break;
                    case 'd': {
                        doAll=false;
                    }
                        break;
                    case 's': {
                        String arg=g.getOptarg();
                        actions.add(new SubsAction(arg,doAll));
                        doAll=true;
                    }
                        break;
                    case 'S': {
                        String arg=g.getOptarg();
                        actions.add(new SupersAction(arg,doAll));
                        doAll=true;
                    }
                        break;
                    case 'e': {
                        String arg=g.getOptarg();
                        actions.add(new EquivalentsAction(arg));
                    }
                        break;
                    case 'U': {
                        actions.add(new EquivalentsAction("<http://www.w3.org/2002/07/owl#Nothing>"));
                    }
                        break;
                    case 'E': {
                        if (conclusionIRI!=null)
                            actions.add(new EntailsAction(config, conclusionIRI));
                    }
                        break;
                    case kDumpPrefixes: {
                        actions.add(new DumpPrefixesAction());
                    }
                        break;
                    case 'N': {
                        ignoreOntologyPrefixes=true;
                    }
                        break;
                    case 'p': {
                        String arg=g.getOptarg();
                        int eqIndex=arg.indexOf('=');
                        if (eqIndex==-1) {
                            throw new IllegalArgumentException("the prefix declaration '"+arg+"' is not of the form PN=IRI.");
                        }
                        prefixes.declarePrefix(arg.substring(0,eqIndex),arg.substring(eqIndex+1));
                    }
                        break;
                    case kDefaultPrefix: {
                        String arg=g.getOptarg();
                        prefixes.declareDefaultPrefix(arg);
                    }
                        break;
                    case kBase: {
                        String arg=g.getOptarg();
                        try {
                            base=new URI(arg);
                        }
                        catch (java.net.URISyntaxException e) {
                            throw new IllegalArgumentException("'"+arg+"' is not a valid base URI.");
                        }
                    }
                        break;

                    case kDirectBlock: {
                        String arg=g.getOptarg();
                        if (arg.toLowerCase().equals("pairwise")) {
                            config.directBlockingType=Configuration.DirectBlockingType.PAIR_WISE;
                        }
                        else if (arg.toLowerCase().equals("single")) {
                            config.directBlockingType=Configuration.DirectBlockingType.SINGLE;
                        }
                        else if (arg.toLowerCase().equals("optimal")) {
                            config.directBlockingType=Configuration.DirectBlockingType.OPTIMAL;
                        }
                        else
                            throw new UsageException("unknown direct blocking type '"+arg+"'; supported values are 'pairwise', 'single', and 'optimal'");
                    }
                        break;
                    case kBlockStrategy: {
                        String arg=g.getOptarg();
                        if (arg.toLowerCase().equals("anywhere")) {
                            config.blockingStrategyType=Configuration.BlockingStrategyType.ANYWHERE;
                        }
                        else if (arg.toLowerCase().equals("ancestor")) {
                            config.blockingStrategyType=Configuration.BlockingStrategyType.ANCESTOR;
                        }
                        else
                            throw new UsageException("unknown blocking strategy type '"+arg+"'; supported values are 'ancestor' and 'anywhere'");
                    }
                        break;
                    case kBlockCache: {
                        String arg=g.getOptarg();
                        if (arg.toLowerCase().equals("on")) {
                            config.blockingSignatureCacheType=Configuration.BlockingSignatureCacheType.CACHED;
                        }
                        else if (arg.toLowerCase().equals("off")) {
                            config.blockingSignatureCacheType=Configuration.BlockingSignatureCacheType.NOT_CACHED;
                        }
                        else
                            throw new UsageException("unknown blocking cache type '"+arg+"'; supported values are 'on' and 'off'");
                    }
                        break;
                    case kExpansion: {
                        String arg=g.getOptarg();
                        if (arg.toLowerCase().equals("creation")) {
                            config.existentialStrategyType=Configuration.ExistentialStrategyType.CREATION_ORDER;
                        }
                        else if (arg.toLowerCase().equals("el")) {
                            config.existentialStrategyType=Configuration.ExistentialStrategyType.EL;
                        }
                        else if (arg.toLowerCase().equals("reuse")) {
                            config.existentialStrategyType=Configuration.ExistentialStrategyType.INDIVIDUAL_REUSE;
                        }
                        else
                            throw new UsageException("unknown existential strategy type '"+arg+"'; supported values are 'creation', 'el', and 'reuse'");
                    }
                        break;
                    case kIgnoreUnsupportedDatatypes: {
                        config.ignoreUnsupportedDatatypes=true;
                    }
                        break;
                    case kDumpClauses: {
                        actions.add(new DumpClausesAction(g.getOptarg()));
                    }
                        break;
                    case kTaxonomy: {
                        actions.add(new TaxonomyAction());
                    }
                        break;
                    default: {
                        if (g.getOptopt()!=0) {
                            throw new UsageException("invalid option -- "+(char)g.getOptopt());
                        }
                        throw new UsageException("invalid option");
                    }
                    } // end option switch
                } // end loop over options
                for (int i=g.getOptind();i<argv.length;++i) {
                    try {
                        ontologies.add(IRI.create(base.resolve(argv[i])));
                    }
                    catch (IllegalArgumentException e) {
                        throw new UsageException(argv[i]+" is not a valid ontology name");
View Full Code Here

         new LongOpt("verbose", LongOpt.NO_ARGUMENT, null, 'v'),
         new LongOpt("extension", LongOpt.NO_ARGUMENT, null, 'e'),
         new LongOpt("load-consumer", LongOpt.NO_ARGUMENT, null, 'l'),
      };

      Getopt getopt = new Getopt(PROGRAM_NAME, args, shortOpts, longOpts);
      int c;
      while ((c = getopt.getopt()) != -1)
      {
         switch (c)
         {
            case 'b':
               bindingFiles.add(new File(getopt.getOptarg()));
               break;
            case 'k':
               generateSource = true;
               break;
            case 'c':
               catalog = new File(getopt.getOptarg());
               break;
            case 'p':
               targetPackage = getopt.getOptarg();
               break;
            case 'w':
               wsdlLocation = getopt.getOptarg();
               break;
            case 'o':
               outputDir = new File(getopt.getOptarg());
               break;
            case 's':
               sourceDir = new File(getopt.getOptarg());
               break;
            case 't':
               target = getopt.getOptarg();
               break;
            case 'q':
               quiet = true;
               break;
            case 'v':
               verbose = true;
               break;
            case 'l':
               loadConsumer = true;
               break;
            case 'e':
               extension = true;
               break;
            case 'h':
               printHelp();
               System.exit(0);
            case '?':
               System.exit(1);
         }
      }

      // debug output
      if(loadConsumer)
      {
         WSContractConsumer importer = WSContractConsumer.newInstance();
         System.out.println("WSContractConsumer instance: " + importer.getClass().getCanonicalName());
         System.exit(0);
      }

      int wsdlPos = getopt.getOptind();
      if (wsdlPos >= args.length)
      {
         System.err.println("Error: WSDL URL was not specified!");
         printHelp();
         System.exit(1);
View Full Code Here

         new LongOpt("quiet", LongOpt.NO_ARGUMENT, null, 'q'),
         new LongOpt("show-traces", LongOpt.NO_ARGUMENT, null, 't'),
         new LongOpt("load-provider", LongOpt.NO_ARGUMENT, null, 'l'),
      };
     
      Getopt getopt = new Getopt(PROGRAM_NAME, args, shortOpts, longOpts);
      int c;
      while ((c = getopt.getopt()) != -1)
      {
         switch (c)
         {
            case 'k':
               generateSource = true;
               break;
            case 's':
               sourceDir = new File(getopt.getOptarg());
               break;
            case 'r':
               resourceDir = new File(getopt.getOptarg());
               break;
            case 'w':
               generateWsdl = true;
               break;
            case 't':
               showTraces = true;
               break;
            case 'o':
               outputDir = new File(getopt.getOptarg());
               break;
            case 'q':
               quiet = true;
               break;
            case 'c':
               processClassPath(getopt.getOptarg());
               break;
            case 'l':
               loadProvider = true;
               break;
            case 'h':
               printHelp();
               System.exit(0);
            case '?':
               System.exit(1);
         }
      }

      // debug output
      if(loadProvider)
      {
         WSContractProvider gen = WSContractProvider.newInstance(loader);
         System.out.println("WSContractProvider instance: " + gen.getClass().getCanonicalName());
         System.exit(0);
      }

      int endpointPos = getopt.getOptind();
      if (endpointPos >= args.length)
      {
         System.err.println("Error: endpoint implementation was not specified!");
         printHelp();
         System.exit(1);
View Full Code Here

  boolean debug = false;
  boolean startCmdl = false;
  boolean showHelp  = false;
  boolean jdkCheck = true;

  Getopt g = new Getopt("xnap", argv, "cd::hnv");

  int c;
  while ((c = g.getopt()) != -1) {
      //System.out.println((char)c + " [" + g.getOptarg() + "]");
      switch (c) {
      case 'c':
    startCmdl = true;
    break;
      case 'd':
    debug = true;
    String arg = g.getOptarg();
    level = (arg != null) ? Level.toLevel(arg) : Level.ALL;
    break;
      case 'h':
    showHelp = true;
    break;
View Full Code Here

  {
      SearchFilter filter = new SearchFilter();

      // remove command
      System.arraycopy(argv, 1, argv, 0, argv.length - 1);
      Getopt g = new Getopt("xnap search", argv, "b:s:");
      g.setOpterr(false);

      try {
    int c;
    NumberParser p;
    while ((c = g.getopt()) != -1) {
        switch (c) {
        case 'b':
       p = new NumberParser(g.getOptarg(),
                SearchFilter.COMPARE_AT_LEAST);
      filter.setBitrateCompare(p.getCompare());
      filter.setBitrate(p.getValue());
      break;
        case 's':
      p = new NumberParser (g.getOptarg(),
                SearchFilter.COMPARE_AT_LEAST);
      filter.setFilesizeCompare(p.getCompare());
      filter.setFilesize(p.getValue());
        default:
      return false;
        }
    }
      }
      catch (NumberFormatException e) {
    return false;
      }

      StringBuffer sb = new StringBuffer();
      for (int i = g.getOptind(); i < argv.length - 1; i++) {
    sb.append(argv[i]);
    sb.append(" ");
      }
     
      String s = sb.toString().trim();
View Full Code Here

        boolean upgrade = false;
        boolean updatestorage = false;
        String valueToEncode = null;
        String associatedProperty = null;

        Getopt getopt = new Getopt("installer", args, sopts, lopts);
        int code;

        while ((code = getopt.getopt()) != -1) {
            switch (code) {
            case ':':
            case '?': {
                // for now both of these should exit
                LOG.error("Invalid option");
                return new WhatToDo[] { WhatToDo.DISPLAY_USAGE };
            }

            case 1: {
                // this will catch non-option arguments (which we don't currently support)
                LOG.error("Unknown option: " + getopt.getOptarg());
                return new WhatToDo[] { WhatToDo.DISPLAY_USAGE };
            }

            case 'H': {
                return new WhatToDo[] { WhatToDo.DISPLAY_USAGE };
            }

            case 'D': {
                // set a system property
                String sysprop = getopt.getOptarg();
                int i = sysprop.indexOf("=");
                String name;
                String value;

                if (i == -1) {
                    name = sysprop;
                    value = "true";
                } else {
                    name = sysprop.substring(0, i);
                    value = sysprop.substring(i + 1, sysprop.length());
                }

                System.setProperty(name, value);
                LOG.info("System property set: " + name + "=" + value);

                break;
            }

            case 'h': {
                String hostString = getopt.getOptarg();
                if (hostString == null) {
                    throw new IllegalArgumentException("Missing host value");
                }
                this.installerConfig.setManagementHost(hostString);
                break;
            }

            case 'p': {
                String portString = getopt.getOptarg();
                if (portString == null) {
                    throw new IllegalArgumentException("Missing port value");
                }
                this.installerConfig.setManagementPort(Integer.parseInt(portString));
                break;
View Full Code Here

        LongOpt[] lopts = { new LongOpt("check", LongOpt.NO_ARGUMENT, null, 'c'), // check if using primary server
            new LongOpt("list", LongOpt.NO_ARGUMENT, null, 'l'), // show the failover list
            new LongOpt("reset", LongOpt.NO_ARGUMENT, null, 'r'), // reset the failover list iterator
            new LongOpt("switch", LongOpt.REQUIRED_ARGUMENT, null, 's') }; // switch immediately to the given server

        Getopt getopt = new Getopt(getPromptCommandString(), args, sopts, lopts);
        int code;

        while ((code = getopt.getopt()) != -1) {
            switch (code) {
            case ':':
            case '?':
            case 1: {
                out.println(MSG.getMsg(AgentI18NResourceKeys.HELP_SYNTAX_LABEL, getSyntax()));
                break;
            }

            case 'c': {
                out.println(MSG.getMsg(AgentI18NResourceKeys.FAILOVER_CHECK_NOW));
                agent.performPrimaryServerSwitchoverCheck();
                break;
            }

            case 'l': {
                showFailoverList(agent, out);
                break;
            }

            case 'r': {
                agent.getServerFailoverList().resetIndex();
                out.println(MSG.getMsg(AgentI18NResourceKeys.FAILOVER_RESET_DONE));
                out.println();
                showFailoverList(agent, out);
                break;
            }

            case 's': {
                String server = getopt.getOptarg();
                if (agent.switchToServer(server)) {
                    out.println(MSG.getMsg(AgentI18NResourceKeys.FAILOVER_IMMEDIATE_SWITCH_DONE, server));
                } else {
                    out.println(MSG.getMsg(AgentI18NResourceKeys.FAILOVER_IMMEDIATE_SWITCH_FAILED, server));
                }
                break;
            }
            }
        }

        if ((getopt.getOptind() + 1) < args.length) {
            out.println(MSG.getMsg(AgentI18NResourceKeys.HELP_SYNTAX_LABEL, getSyntax()));
        }

        return;
    }
View Full Code Here

            new LongOpt("enable", LongOpt.NO_ARGUMENT, null, 'e'), new LongOpt("os", LongOpt.NO_ARGUMENT, null, 'o'),
            new LongOpt("ps", LongOpt.OPTIONAL_ARGUMENT, null, 'p'),
            new LongOpt("shutdown", LongOpt.NO_ARGUMENT, null, 's'),
            new LongOpt("version", LongOpt.NO_ARGUMENT, null, 'v') };

        Getopt getopt = new Getopt("native", args, sopts, lopts);
        int code;

        while ((code = getopt.getopt()) != -1) {
            switch (code) {
            case ':':
            case '?':
            case 1: {
                out.println(MSG.getMsg(AgentI18NResourceKeys.HELP_SYNTAX_LABEL, getSyntax()));
                break;
            }

            case 'd': {
                SystemInfoFactory.disableNativeSystemInfo();
                out.println(MSG.getMsg(AgentI18NResourceKeys.NATIVE_DISABLE_DONE));
                break;
            }

            case 'e': {
                SystemInfoFactory.enableNativeSystemInfo();
                out.println(MSG.getMsg(AgentI18NResourceKeys.NATIVE_ENABLE_DONE));
                break;
            }

            case 'o': {
                SystemInfo sysInfo = SystemInfoFactory.createSystemInfo();

                // careful - I chose to only output things that I know the non-native Java sysinfo can support
                out.println(MSG.getMsg(AgentI18NResourceKeys.NATIVE_OS_OUTPUT, sysInfo.getOperatingSystemName(),
                    sysInfo.getOperatingSystemVersion(), sysInfo.getHostname()));

                break;
            }

            case 'p': {
                SystemInfo sysInfo = SystemInfoFactory.createSystemInfo();
                String verboseOpt = getopt.getOptarg();
                boolean verbose = (verboseOpt != null)
                    && verboseOpt.equals(MSG.getMsg(AgentI18NResourceKeys.NATIVE_VERBOSE));

                try {
                    List<ProcessInfo> processes = sysInfo.getAllProcesses();
                    if (verbose) {
                        out.println(MSG.getMsg(AgentI18NResourceKeys.NATIVE_PS_OUTPUT_VERBOSE_HEADER));
                    } else {
                        out.println(MSG.getMsg(AgentI18NResourceKeys.NATIVE_PS_OUTPUT_SHORT_HEADER));
                    }

                    for (ProcessInfo p : processes) {
                        if (verbose) {
                            out.println(MSG.getMsg(AgentI18NResourceKeys.NATIVE_PS_OUTPUT_VERBOSE, p.getPid(), p
                                .getParentPid(), p.getBaseName(), Arrays.toString(p.getCommandLine())));
                        } else {
                            out.println(MSG.getMsg(AgentI18NResourceKeys.NATIVE_PS_OUTPUT_SHORT, p.getPid(), p
                                .getName()));
                        }
                    }
                } catch (Exception e) {
                    out.println(MSG.getMsg(AgentI18NResourceKeys.NATIVE_NOT_SUPPORTED));
                }

                break;
            }

            case 's': {
                if (!agent.isStarted()) {
                    SystemInfoFactory.shutdown();
                    SystemInfoFactory.disableNativeSystemInfo();
                    out.println(MSG.getMsg(AgentI18NResourceKeys.NATIVE_SHUTDOWN_DONE));
                } else {
                    out.println(MSG.getMsg(AgentI18NResourceKeys.NATIVE_SHUTDOWN_FAILED_AGENT_STARTED));
                }

                break;
            }

            case 'v': {
                out.println(SystemInfoFactory.getNativeSystemInfoVersion());
                break;
            }
            }
        }

        if ((getopt.getOptind() + 1) < args.length) {
            out.println(MSG.getMsg(AgentI18NResourceKeys.HELP_SYNTAX_LABEL, getSyntax()));
        }

        return;
    }
View Full Code Here

            new LongOpt("threaddump", LongOpt.NO_ARGUMENT, null, 't'), // dump thread stacks
            new LongOpt("enable", LongOpt.NO_ARGUMENT, null, 'e'), // shorthand for -f log4j-debug.xml
            new LongOpt("disable", LongOpt.NO_ARGUMENT, null, 'd'), // shorthand for -f log4j.xml
            new LongOpt("file", LongOpt.REQUIRED_ARGUMENT, null, 'f') }; // reconfigure with new log file

        Getopt getopt = new Getopt(getPromptCommandString(), args, sopts, lopts);
        int code;

        while ((code = getopt.getopt()) != -1) {
            switch (code) {
            case ':':
            case '?':
            case 1: {
                out.println(MSG.getMsg(AgentI18NResourceKeys.HELP_SYNTAX_LABEL, getSyntax()));
                break;
            }

            case 'c': {
                String flag = getopt.getOptarg();
                boolean flagBoolean = Boolean.parseBoolean(flag);
                agent.agentServerCommunicationsTrace(flagBoolean);
                if (flagBoolean) {
                    out.println(MSG.getMsg(AgentI18NResourceKeys.DEBUG_CMD_TRACING_ENABLED, //
                        CommandTraceUtil.getSettingTraceCommandConfig(), //
                        CommandTraceUtil.getSettingTraceCommandResponseResults(), //
                        CommandTraceUtil.getSettingTraceCommandSizeThreshold(), //
                        CommandTraceUtil.getSettingTraceCommandResponseSizeThreshold()));
                } else {
                    out.println(MSG.getMsg(AgentI18NResourceKeys.DEBUG_CMD_TRACING_DISABLED));
                }
                break;
            }

            case 'd': {
                String file = "log4j.xml";
                try {
                    agent.hotDeployLogConfigurationFile(file);
                    out.println(MSG.getMsg(AgentI18NResourceKeys.DEBUG_LOG_FILE_LOADED, file, LogManager
                        .getRootLogger().getLevel()));
                } catch (Exception e) {
                    out.println(MSG.getMsg(AgentI18NResourceKeys.DEBUG_CANNOT_LOAD_LOG_FILE, file, ThrowableUtil
                        .getAllMessages(e)));
                }
                break;
            }

            case 'e': {
                String file = "log4j-debug.xml";
                try {
                    agent.hotDeployLogConfigurationFile(file);
                    out.println(MSG.getMsg(AgentI18NResourceKeys.DEBUG_LOG_FILE_LOADED, file, LogManager
                        .getRootLogger().getLevel()));
                } catch (Exception e) {
                    out.println(MSG.getMsg(AgentI18NResourceKeys.DEBUG_CANNOT_LOAD_LOG_FILE, file, ThrowableUtil
                        .getAllMessages(e)));
                }
                break;
            }

            case 'f': {
                String file = getopt.getOptarg();
                try {
                    agent.hotDeployLogConfigurationFile(file);
                    out.println(MSG.getMsg(AgentI18NResourceKeys.DEBUG_LOG_FILE_LOADED, file, LogManager
                        .getRootLogger().getLevel()));
                } catch (Exception e) {
                    out.println(MSG.getMsg(AgentI18NResourceKeys.DEBUG_CANNOT_LOAD_LOG_FILE, file, ThrowableUtil
                        .getAllMessages(e)));
                }
                break;
            }

            case 't': {
                try {
                    // TODO: Once we drop support for Java 5, we can use ThreadMXBean.dumpAllThreads(false, false)
                    //       (introduced in Java 6) here instead.
                    ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
                    long[] allIds = threadMXBean.getAllThreadIds();
                    ThreadInfo[] allInfo = threadMXBean.getThreadInfo(allIds, 256);
                    for (ThreadInfo threadInfo : allInfo) {
                        if (threadInfo != null) {
                            out.println(threadInfo);
                        }
                    }
                } catch (Exception e) {
                    out.println(MSG.getMsg(AgentI18NResourceKeys.DEBUG_CANNOT_DUMP_THREADS, ThrowableUtil
                        .getAllMessages(e)));
                }
                break;
            }
            }
        }

        if ((getopt.getOptind() + 1) < args.length) {
            out.println(MSG.getMsg(AgentI18NResourceKeys.HELP_SYNTAX_LABEL, getSyntax()));
        }

        return;
    }
View Full Code Here

TOP

Related Classes of gnu.getopt.Getopt

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.