Java 类com.beust.jcommander.FuzzyMap.IKey 实例源码

项目:ttc2017smartGrids    文件:JCommander.java   
private boolean matchArg(String arg, IKey key) {
    String kn = options.caseSensitiveOptions
            ? key.getName()
            : key.getName().toLowerCase();
    if (options.allowAbbreviatedOptions) {
        if (kn.startsWith(arg)) return true;
    } else {
        ParameterDescription pd = descriptions.get(key);
        if (pd != null) {
            // It's an option. If the option has a separator (e.g. -author==foo) then
            // we only do a beginsWith match
            String separator = getSeparatorFor(arg);
            if (! " ".equals(separator)) {
                if (arg.startsWith(kn)) return true;
            } else {
                if (kn.equals(arg)) return true;
            }
        } else {
            // It's a command do a strict equality check
            if (kn.equals(arg)) return true;
        }
    }
    return false;
}
项目:ttc2017smartGrids    文件:JCommander.java   
private boolean matchArg(String arg, IKey key) {
    String kn = options.caseSensitiveOptions
            ? key.getName()
            : key.getName().toLowerCase();
    if (options.allowAbbreviatedOptions) {
        if (kn.startsWith(arg)) return true;
    } else {
        ParameterDescription pd = descriptions.get(key);
        if (pd != null) {
            // It's an option. If the option has a separator (e.g. -author==foo) then
            // we only do a beginsWith match
            String separator = getSeparatorFor(arg);
            if (! " ".equals(separator)) {
                if (arg.startsWith(kn)) return true;
            } else {
                if (kn.equals(arg)) return true;
            }
        } else {
            // It's a command do a strict equality check
            if (kn.equals(arg)) return true;
        }
    }
    return false;
}
项目:ttc2017smartGrids    文件:JCommander.java   
private ParameterDescription getPrefixDescriptionFor(String arg) {
    for (Map.Entry<IKey, ParameterDescription> es : descriptions.entrySet()) {
        if (arg.startsWith(es.getKey().getName())) return es.getValue();
    }

    return null;
}
项目:ttc2017smartGrids    文件:JCommander.java   
/**
 * Add a command object and its aliases.
 */
public void addCommand(String name, Object object, String... aliases) {
    JCommander jc = new JCommander(options);
    jc.addObject(object);
    jc.createDescriptions();
    jc.setProgramName(name, aliases);
    ProgramName progName = jc.programName;
    commands.put(progName, jc);

/*
* Register aliases
*/
    //register command name as an alias of itself for reverse lookup
    //Note: Name clash check is intentionally omitted to resemble the
    //     original behaviour of clashing commands.
    //     Aliases are, however, are strictly checked for name clashes.
    aliasMap.put(new StringKey(name), progName);
    for (String a : aliases) {
        IKey alias = new StringKey(a);
        //omit pointless aliases to avoid name clash exception
        if (!alias.equals(name)) {
            ProgramName mappedName = aliasMap.get(alias);
            if (mappedName != null && !mappedName.equals(progName)) {
                throw new ParameterException("Cannot set alias " + alias
                        + " for " + name
                        + " command because it has already been defined for "
                        + mappedName.name + " command");
            }
            aliasMap.put(alias, progName);
        }
    }
}
项目:ttc2017smartGrids    文件:JCommander.java   
private ParameterDescription getPrefixDescriptionFor(String arg) {
    for (Map.Entry<IKey, ParameterDescription> es : descriptions.entrySet()) {
        if (arg.startsWith(es.getKey().getName())) return es.getValue();
    }

    return null;
}
项目:ttc2017smartGrids    文件:JCommander.java   
/**
 * Add a command object and its aliases.
 */
public void addCommand(String name, Object object, String... aliases) {
    JCommander jc = new JCommander(options);
    jc.addObject(object);
    jc.createDescriptions();
    jc.setProgramName(name, aliases);
    ProgramName progName = jc.programName;
    commands.put(progName, jc);

/*
* Register aliases
*/
    //register command name as an alias of itself for reverse lookup
    //Note: Name clash check is intentionally omitted to resemble the
    //     original behaviour of clashing commands.
    //     Aliases are, however, are strictly checked for name clashes.
    aliasMap.put(new StringKey(name), progName);
    for (String a : aliases) {
        IKey alias = new StringKey(a);
        //omit pointless aliases to avoid name clash exception
        if (!alias.equals(name)) {
            ProgramName mappedName = aliasMap.get(alias);
            if (mappedName != null && !mappedName.equals(progName)) {
                throw new ParameterException("Cannot set alias " + alias
                        + " for " + name
                        + " command because it has already been defined for "
                        + mappedName.name + " command");
            }
            aliasMap.put(alias, progName);
        }
    }
}
项目:muJava    文件:JCommander.java   
private ParameterDescription getPrefixDescriptionFor(String arg) {
  for (Map.Entry<IKey, ParameterDescription> es : m_descriptions.entrySet()) {
    if (arg.startsWith(es.getKey().getName())) return es.getValue();
  }

  return null;
}
项目:muJava    文件:JCommander.java   
/**
 * Add a command object and its aliases.
 */
public void addCommand(String name, Object object, String... aliases) {
  JCommander jc = new JCommander(object);
  jc.setProgramName(name, aliases);
  jc.setDefaultProvider(m_defaultProvider);
  ProgramName progName = jc.m_programName;
  m_commands.put(progName, jc);

  /*
  * Register aliases
  */
  //register command name as an alias of itself for reverse lookup
  //Note: Name clash check is intentionally omitted to resemble the
  //     original behaviour of clashing commands.
  //     Aliases are, however, are strictly checked for name clashes.
  aliasMap.put(new StringKey(name), progName);
  for (String a : aliases) {
    IKey alias = new StringKey(a);
    //omit pointless aliases to avoid name clash exception
    if (!alias.equals(name)) {
      ProgramName mappedName = aliasMap.get(alias);
      if (mappedName != null && !mappedName.equals(progName)) {
        throw new ParameterException("Cannot set alias " + alias
                + " for " + name
                + " command because it has already been defined for "
                + mappedName.m_name + " command");
      }
      aliasMap.put(alias, progName);
    }
  }
}
项目:VarJ    文件:JCommander.java   
private ParameterDescription getPrefixDescriptionFor(String arg) {
  for (Map.Entry<IKey, ParameterDescription> es : m_descriptions.entrySet()) {
    if (arg.startsWith(es.getKey().getName())) return es.getValue();
  }

  return null;
}
项目:VarJ    文件:JCommander.java   
/**
 * Add a command object and its aliases.
 */
public void addCommand(String name, Object object, String... aliases) {
  JCommander jc = new JCommander(object);
  jc.setProgramName(name, aliases);
  jc.setDefaultProvider(m_defaultProvider);
  ProgramName progName = jc.m_programName;
  m_commands.put(progName, jc);

  /*
  * Register aliases
  */
  //register command name as an alias of itself for reverse lookup
  //Note: Name clash check is intentionally omitted to resemble the
  //     original behaviour of clashing commands.
  //     Aliases are, however, are strictly checked for name clashes.
  aliasMap.put(new StringKey(name), progName);
  for (String a : aliases) {
    IKey alias = new StringKey(a);
    //omit pointless aliases to avoid name clash exception
    if (!alias.equals(name)) {
      ProgramName mappedName = aliasMap.get(alias);
      if (mappedName != null && !mappedName.equals(progName)) {
        throw new ParameterException("Cannot set alias " + alias
                + " for " + name
                + " command because it has already been defined for "
                + mappedName.m_name + " command");
      }
      aliasMap.put(alias, progName);
    }
  }
}
项目:Corporatique    文件:JCommander.java   
private ParameterDescription getPrefixDescriptionFor(String arg) {
    for (Map.Entry<IKey, ParameterDescription> es : m_descriptions.entrySet()) {
        if (arg.startsWith(es.getKey().getName())) return es.getValue();
    }

    return null;
}
项目:Corporatique    文件:JCommander.java   
/**
 * Add a command object and its aliases.
 */
public void addCommand(String name, Object object, String... aliases) {
    JCommander jc = new JCommander(object);
    jc.setProgramName(name, aliases);
    jc.setDefaultProvider(m_defaultProvider);
    jc.setAcceptUnknownOptions(m_acceptUnknownOptions);
    ProgramName progName = jc.m_programName;
    m_commands.put(progName, jc);

/*
* Register aliases
*/
    //register command name as an alias of itself for reverse lookup
    //Note: Name clash check is intentionally omitted to resemble the
    //     original behaviour of clashing commands.
    //     Aliases are, however, are strictly checked for name clashes.
    aliasMap.put(new StringKey(name), progName);
    for (String a : aliases) {
        IKey alias = new StringKey(a);
        //omit pointless aliases to avoid name clash exception
        if (!alias.equals(name)) {
            ProgramName mappedName = aliasMap.get(alias);
            if (mappedName != null && !mappedName.equals(progName)) {
                throw new ParameterException("Cannot set alias " + alias
                        + " for " + name
                        + " command because it has already been defined for "
                        + mappedName.m_name + " command");
            }
            aliasMap.put(alias, progName);
        }
    }
}
项目:java_seqbuster    文件:JCommander.java   
private ParameterDescription getPrefixDescriptionFor(String arg) {
  for (Map.Entry<IKey, ParameterDescription> es : m_descriptions.entrySet()) {
    if (arg.startsWith(es.getKey().getName())) return es.getValue();
  }

  return null;
}
项目:java_seqbuster    文件:JCommander.java   
/**
 * Add a command object and its aliases.
 */
public void addCommand(String name, Object object, String... aliases) {
  JCommander jc = new JCommander(object);
  jc.setProgramName(name, aliases);
  jc.setDefaultProvider(m_defaultProvider);
  ProgramName progName = jc.m_programName;
  m_commands.put(progName, jc);

  /*
  * Register aliases
  */
  //register command name as an alias of itself for reverse lookup
  //Note: Name clash check is intentionally omitted to resemble the
  //     original behaviour of clashing commands.
  //     Aliases are, however, are strictly checked for name clashes.
  aliasMap.put(new StringKey(name), progName);
  for (String a : aliases) {
    IKey alias = new StringKey(a);
    //omit pointless aliases to avoid name clash exception
    if (!alias.equals(name)) {
      ProgramName mappedName = aliasMap.get(alias);
      if (mappedName != null && !mappedName.equals(progName)) {
        throw new ParameterException("Cannot set alias " + alias
                + " for " + name
                + " command because it has already been defined for "
                + mappedName.m_name + " command");
      }
      aliasMap.put(alias, progName);
    }
  }
}
项目:java_seqbuster    文件:JCommander.java   
private ParameterDescription getPrefixDescriptionFor(String arg) {
  for (Map.Entry<IKey, ParameterDescription> es : m_descriptions.entrySet()) {
    if (arg.startsWith(es.getKey().getName())) return es.getValue();
  }

  return null;
}
项目:java_seqbuster    文件:JCommander.java   
/**
 * Add a command object and its aliases.
 */
public void addCommand(String name, Object object, String... aliases) {
  JCommander jc = new JCommander(object);
  jc.setProgramName(name, aliases);
  jc.setDefaultProvider(m_defaultProvider);
  ProgramName progName = jc.m_programName;
  m_commands.put(progName, jc);

  /*
  * Register aliases
  */
  //register command name as an alias of itself for reverse lookup
  //Note: Name clash check is intentionally omitted to resemble the
  //     original behaviour of clashing commands.
  //     Aliases are, however, are strictly checked for name clashes.
  aliasMap.put(new StringKey(name), progName);
  for (String a : aliases) {
    IKey alias = new StringKey(a);
    //omit pointless aliases to avoid name clash exception
    if (!alias.equals(name)) {
      ProgramName mappedName = aliasMap.get(alias);
      if (mappedName != null && !mappedName.equals(progName)) {
        throw new ParameterException("Cannot set alias " + alias
                + " for " + name
                + " command because it has already been defined for "
                + mappedName.m_name + " command");
      }
      aliasMap.put(alias, progName);
    }
  }
}
项目:java_seqbuster    文件:JCommander.java   
private ParameterDescription getPrefixDescriptionFor(String arg) {
  for (Map.Entry<IKey, ParameterDescription> es : m_descriptions.entrySet()) {
    if (arg.startsWith(es.getKey().getName())) return es.getValue();
  }

  return null;
}
项目:java_seqbuster    文件:JCommander.java   
/**
 * Add a command object and its aliases.
 */
public void addCommand(String name, Object object, String... aliases) {
  JCommander jc = new JCommander(object);
  jc.setProgramName(name, aliases);
  jc.setDefaultProvider(m_defaultProvider);
  ProgramName progName = jc.m_programName;
  m_commands.put(progName, jc);

  /*
  * Register aliases
  */
  //register command name as an alias of itself for reverse lookup
  //Note: Name clash check is intentionally omitted to resemble the
  //     original behaviour of clashing commands.
  //     Aliases are, however, are strictly checked for name clashes.
  aliasMap.put(new StringKey(name), progName);
  for (String a : aliases) {
    IKey alias = new StringKey(a);
    //omit pointless aliases to avoid name clash exception
    if (!alias.equals(name)) {
      ProgramName mappedName = aliasMap.get(alias);
      if (mappedName != null && !mappedName.equals(progName)) {
        throw new ParameterException("Cannot set alias " + alias
                + " for " + name
                + " command because it has already been defined for "
                + mappedName.m_name + " command");
      }
      aliasMap.put(alias, progName);
    }
  }
}
项目:sparc    文件:JCommander.java   
private ParameterDescription getPrefixDescriptionFor(String arg) {
  for (Map.Entry<IKey, ParameterDescription> es : m_descriptions.entrySet()) {
    if (arg.startsWith(es.getKey().getName())) return es.getValue();
  }

  return null;
}
项目:sparc    文件:JCommander.java   
/**
 * Add a command object and its aliases.
 */
public void addCommand(String name, Object object, String... aliases) {
  JCommander jc = new JCommander(object);
  jc.setProgramName(name, aliases);
  jc.setDefaultProvider(m_defaultProvider);
  ProgramName progName = jc.m_programName;
  m_commands.put(progName, jc);

  /*
  * Register aliases
  */
  //register command name as an alias of itself for reverse lookup
  //Note: Name clash check is intentionally omitted to resemble the
  //     original behaviour of clashing commands.
  //     Aliases are, however, are strictly checked for name clashes.
  aliasMap.put(new StringKey(name), progName);
  for (String a : aliases) {
    IKey alias = new StringKey(a);
    //omit pointless aliases to avoid name clash exception
    if (!alias.equals(name)) {
      ProgramName mappedName = aliasMap.get(alias);
      if (mappedName != null && !mappedName.equals(progName)) {
        throw new ParameterException("Cannot set alias " + alias
                + " for " + name
                + " command because it has already been defined for "
                + mappedName.m_name + " command");
      }
      aliasMap.put(alias, progName);
    }
  }
}