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


Java ArgumentMap.isSet方法代码示例

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


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

示例1: initFileLogging

import ca.nrc.cadc.util.ArgumentMap; //导入方法依赖的package包/类
/**
* Initializes logging to a file.
* @param loggerNames the names of the loggers (usually names of packages
* or classes or ancestors of packages or classes). Can't be null.
* @param argMap command line arguments.
*/
public static synchronized void initFileLogging(String[] loggerNames, ArgumentMap argMap, String filename)
    throws IOException
{
    Level level = DEFAULT_FILE_LOGGING_LEVEL;
    if (argMap.isSet(Argument.LOG_QUIET_SHORT) || argMap.isSet(Argument.LOG_QUIET)) level = Level.ERROR;
    if (argMap.isSet(Argument.LOG_VERBOSE_SHORT) || argMap.isSet(Argument.LOG_VERBOSE)) level = Level.INFO;
    if (argMap.isSet(Argument.LOG_DEBUG_SHORT) || argMap.isSet(Argument.DEBUG)) level = Level.DEBUG;

    FileAppender fileAppender = new FileAppender(new PatternLayout(), filename);

    boolean append = true;
    Writer fileWriter = new FileWriter(filename, append);
    for (String loggerName : loggerNames)
        Log4jInit.setLevel(loggerName, level, fileWriter);
}
 
开发者ID:opencadc,项目名称:caom2,代码行数:22,代码来源:Util.java

示例2: main

import ca.nrc.cadc.util.ArgumentMap; //导入方法依赖的package包/类
public static void main(String[] args) {
    try {
        ArgumentMap am = new ArgumentMap(args);

        if (am.isSet("d") || am.isSet("debug")) {
            Log4jInit.setLevel("ca.nrc.cadc.caom2.repo.client", Level.DEBUG);
            Log4jInit.setLevel("ca.nrc.cadc.reg.client", Level.DEBUG);
        } else if (am.isSet("v") || am.isSet("verbose")) {
            Log4jInit.setLevel("ca.nrc.cadc.caom2.repo.client", Level.INFO);
        } else {
            Log4jInit.setLevel("ca.nrc.cadc", Level.WARN);
            Log4jInit.setLevel("ca.nrc.cadc.caom2.repo.client", Level.WARN);

        }

        if (am.isSet("h") || am.isSet("help")) {
            usage();
            System.exit(0);
        }

        // TODO: implement useful command-line fatures here: 

        // setup
        // am.getValue("resourceID")
        // am.getValue("collection")

        // get list
        // am.isSet("list")
        // am.getValue("maxrec")

        // get a single observation
        // am.getValue("observationID")
    } catch (Throwable uncaught) {
        log.error("uncaught exception", uncaught);
        System.exit(-1);
    }
}
 
开发者ID:opencadc,项目名称:caom2db,代码行数:38,代码来源:Main.java

示例3: initConsoleLogging

import ca.nrc.cadc.util.ArgumentMap; //导入方法依赖的package包/类
/**
* Initializes logging to the console.
* @param loggerNames the names of the loggers (usually names of packages 
* or classes or ancestors of packages or classes). Can't be null.
* @param argMap command line arguments.
*/
private static synchronized Level initConsoleLogging(String[] loggerNames, ArgumentMap argMap)
{
    Level level = DEFAULT_CONSOLE_LOGGING_LEVEL;
    if (argMap.isSet(Argument.LOG_QUIET_SHORT) || argMap.isSet(Argument.LOG_QUIET)) level = Level.ERROR;
    if (argMap.isSet(Argument.LOG_VERBOSE_SHORT) || argMap.isSet(Argument.LOG_VERBOSE)) level = Level.INFO;
    if (argMap.isSet(Argument.LOG_DEBUG_SHORT) || argMap.isSet(Argument.DEBUG)) level = Level.DEBUG;

    for (int i = 0; i < loggerNames.length; i++)
        Log4jInit.setLevel(loggerNames[i], level);

    return level;
}
 
开发者ID:opencadc,项目名称:caom2,代码行数:19,代码来源:Util.java

示例4: main

import ca.nrc.cadc.util.ArgumentMap; //导入方法依赖的package包/类
public static void main(String[] args) {
    try {
        ArgumentMap am = new ArgumentMap(args);
        if (am.isSet("h") || am.isSet("help")) {
            usage();
            System.exit(0);
        }

        // Set debug mode
        CaomEntity.MCS_DEBUG = true;
        if (am.isSet("d") || am.isSet("debug")) {
            Log4jInit.setLevel("ca.nrc.cadc.caom2", Level.DEBUG);
        } else if (am.isSet("v") || am.isSet("verbose")) {
            Log4jInit.setLevel("ca.nrc.cadc.caom2", Level.INFO);
        } else {
            Log4jInit.setLevel("ca.nrc.cadc.caom2", Level.WARN);
        }

        if (am.getPositionalArgs().isEmpty()) {
            usage();
            System.exit(1);
        }
        
        String fname = am.getPositionalArgs().get(0);
        File f = new File(fname);
        ObservationReader r = new ObservationReader();
        Observation obs = r.read(new FileReader(f));
        
        if (am.getPositionalArgs().size() == 2) {
            File out = new File(am.getPositionalArgs().get(1));
            ObservationWriter w = new ObservationWriter();
            w.write(obs, new FileWriter(out));
            log.info("wrote copy: " + out.getAbsolutePath());
        }
        
        List<Runnable> validators = new ArrayList<>();
        if (am.isSet("checksum")) {
            int depth = 5;
            if (am.isSet("depth")) {
                try { 
                    depth = Integer.parseInt(am.getValue("depth"));
                } catch (NumberFormatException ex) {
                    log.error("invalid depth: " + am.getValue("depth") + ": must be integer in [1,5]");
                    usage();
                    System.exit(1);
                }
            }
            validators.add(new ChecksumValidator(obs, depth, am.isSet("acc")));
        }
        
        if (am.isSet("wcs")) {
            validators.add(new WCSValidator(obs));
        }

        for (Runnable v : validators) {
            log.info("START " + v.getClass().getName());
            v.run();
            log.info("DONE " + v.getClass().getName() + System.getProperty("line.separator"));
        }

    } catch (Throwable t) {
        log.error("unexpected failure", t);
        System.exit(1);
    }
    System.exit(0);
}
 
开发者ID:opencadc,项目名称:caom2,代码行数:67,代码来源:Main.java

示例5: main

import ca.nrc.cadc.util.ArgumentMap; //导入方法依赖的package包/类
public static void main(String[] args) {
    String cur = null;
    try {
        ArgumentMap am = new ArgumentMap(args);

        if (am.isSet("h") || am.isSet("help")) {
            usage();
            System.exit(0);
        }

        Level lvl = Level.WARN;
        if (am.isSet("d") || am.isSet("debug")) {
            lvl = Level.DEBUG;
        } else if (am.isSet("v") || am.isSet("verbose")) {
            lvl = Level.INFO;
        }

        Log4jInit.setLevel("ca.nrc.cadc.caom2.viz", lvl);
        Log4jInit.setLevel("ca.nrc.cadc.caom2.types", lvl);
        Log4jInit.setLevel("ca.nrc.cadc.caom2.wcs", lvl);

        String fname = am.getValue("in");
        String productID = am.getValue("productID");
        boolean recomp = am.isSet("r");
        boolean headless = am.isSet("headless");
        if (fname == null) {
            usage();
            System.exit(1);
        }
        File f = new File(fname);

        if (headless) {
            ComputeFromXML cu = new ComputeFromXML(f, productID);
            cu.doit();
        } else {
            VizUnion vu = new VizUnion(f, productID, recomp);
            vu.doit();
        }
    } catch (Exception ex) {
        log.error("failed to display: " + cur, ex);
    }
}
 
开发者ID:opencadc,项目名称:caom2,代码行数:43,代码来源:Main.java

示例6: initialize

import ca.nrc.cadc.util.ArgumentMap; //导入方法依赖的package包/类
/**
   * Configures logging to either the console or a file, but not both.
   * 
   * If the ArgumentMap contains a key name 'log', a file logger named with the
   * value of 'log' is created. If the value of 'log' is null or an empty string,
   * a file logger will not be created. If the ArgumentMap doesn't contain
   * a 'log' key, a console logger is created.
   *
   * The log level is set using log level arguments in the ArgumentMap. If the
   * ArgumentMap doesn't contain log level arguments, the default log level
   * for the console logger is WARN, and the default log level for
   * the file logger is INFO.
   *
   * @param loggerNames names of the loggers to apply the logging options of
   * in the argsMap to.
   * @param argMap command line argument options.
   * @throws IOException problems with the log file
   * @throws IllegalArgumentException if there is a disagreement with the way 
   *                                  the file is handled.              
   */
  public static void initialize(String[] loggerNames, ArgumentMap argMap)
      throws IOException, IllegalArgumentException
  {
      if (argMap.isSet(Argument.LOG))
      {
          String filename = argMap.getValue(Argument.LOG);
          if (filename.isEmpty())
          {
              filename = "empty or zero-length string";
throw new IllegalArgumentException("Illegal log file name option: " + filename);
          }
          initFileLogging(loggerNames, argMap, filename);
      }
      else
      {
          initConsoleLogging(loggerNames, argMap);
      }
  }
 
开发者ID:opencadc,项目名称:caom2,代码行数:39,代码来源:Util.java


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