/** * Returns <jk>true</jk> if the named argument exists. * * @param name The argument name. * @return <jk>true</jk> if the named argument exists. */ public boolean hasArg(String name) { ObjectList l = (ObjectList)get(name); return l != null; }
/** * Returns <jk>true</jk> if the named argument exists. * * @param name The argument name. * @return <jk>true</jk> if the named argument exists. */ public boolean hasArg(String name) { ObjectList l = (ObjectList)get(name); return l != null; }
/** * Returns <jk>true</jk> if the named argument exists. * * @param name The argument name. * @return <jk>true</jk> if the named argument exists. */ public boolean hasArg(String name) { ObjectList l = (ObjectList)get(name); return l != null; }
/** * Returns the optional argument values as a list of strings. * * <h5 class='section'>Example:</h5> * <p class='bcode w800'> * <jc>// Command: java com.sample.MyClass -extraArgs foo bar baz</jc> * List<String> l1 = args.getArgs(<js>"extraArgs"</js>); <jc>// ['foo','bar','baz']</jc> * List<String> l2 = args.getArgs(<js>"nonExistentArgs"</js>); <jc>// An empty list</jc> * </p> * * @param name The optional argument name. * @return The optional argument values, or an empty list if the optional argument was not specified. */ @SuppressWarnings({"rawtypes", "unchecked"}) public List<String> getArgs(String name) { List l = (ObjectList)get(name); if (l == null) return Collections.emptyList(); return l; } }
/** * Returns the optional argument values as a list of strings. * * <h5 class='section'>Example:</h5> * <p class='bcode w800'> * <jc>// Command: java com.sample.MyClass -extraArgs foo bar baz</jc> * List<String> l1 = args.getArgs(<js>"extraArgs"</js>); <jc>// ['foo','bar','baz']</jc> * List<String> l2 = args.getArgs(<js>"nonExistentArgs"</js>); <jc>// An empty list</jc> * </p> * * @param name The optional argument name. * @return The optional argument values, or an empty list if the optional argument was not specified. */ @SuppressWarnings({"rawtypes", "unchecked"}) public List<String> getArgs(String name) { List l = (ObjectList)get(name); if (l == null) return Collections.emptyList(); return l; } }
/** * Returns the optional argument values as a list of strings. * * <h5 class='section'>Example:</h5> * <p class='bcode w800'> * <jc>// Command: java com.sample.MyClass -extraArgs foo bar baz</jc> * List<String> l1 = args.getArgs(<js>"extraArgs"</js>); <jc>// ['foo','bar','baz']</jc> * List<String> l2 = args.getArgs(<js>"nonExistentArgs"</js>); <jc>// An empty list</jc> * </p> * * @param name The optional argument name. * @return The optional argument values, or an empty list if the optional argument was not specified. */ @SuppressWarnings({"rawtypes", "unchecked"}) public List<String> getArgs(String name) { List l = (ObjectList)get(name); if (l == null) return Collections.emptyList(); return l; } }
/** * Returns the optional argument value, or blank if the optional argument was not specified. * * <p> * If the optional arg has multiple values, returns values as a comma-delimited list. * * @param name The optional argument name. * @return The optional argument value, or blank if the optional argument was not specified. */ public String getArg(String name) { ObjectList l = (ObjectList)get(name); if (l == null || l.size() == 0) return null; if (l.size() == 1) return l.get(0).toString(); return Arrays.toString(l.toArray()).replaceAll("[\\[\\]]", ""); }
/** * Returns the optional argument value, or blank if the optional argument was not specified. * * <p> * If the optional arg has multiple values, returns values as a comma-delimited list. * * @param name The optional argument name. * @return The optional argument value, or blank if the optional argument was not specified. */ public String getArg(String name) { ObjectList l = (ObjectList)get(name); if (l == null || l.size() == 0) return null; if (l.size() == 1) return l.get(0).toString(); return Arrays.toString(l.toArray()).replaceAll("[\\[\\]]", ""); }
/** * Returns the optional argument value, or blank if the optional argument was not specified. * * <p> * If the optional arg has multiple values, returns values as a comma-delimited list. * * @param name The optional argument name. * @return The optional argument value, or blank if the optional argument was not specified. */ public String getArg(String name) { ObjectList l = (ObjectList)get(name); if (l == null || l.size() == 0) return null; if (l.size() == 1) return l.get(0).toString(); return Arrays.toString(l.toArray()).replaceAll("[\\[\\]]", ""); }
/** * Returns the optional argument value converted to the specified object type. * * <p> * If the optional arg has multiple values, returns only the first converted value. * * <h5 class='section'>Example:</h5> * <p class='bcode w800'> * <jc>// Command: java com.sample.MyClass -verbose true -debug 5</jc> * <jk>boolean</jk> b = args.getArg(<jk>boolean</jk>.<jk>class</jk>, <js>"verbose"</js>); * <jk>int</jk> i = args.getArg(<jk>int</jk>.<jk>class</jk>, <js>"debug"</js>); * </p> * * @param c The class type to convert the value to. * @param <T> The class type to convert the value to. * @param name The optional argument name. * @return The optional argument value, or blank if the optional argument was not specified. */ public <T> T getArg(Class<T> c, String name) { ObjectList l = (ObjectList)get(name); if (l == null || l.size() == 0) return null; return l.get(0, c); }
/** * Returns the optional argument value converted to the specified object type. * * <p> * If the optional arg has multiple values, returns only the first converted value. * * <h5 class='section'>Example:</h5> * <p class='bcode w800'> * <jc>// Command: java com.sample.MyClass -verbose true -debug 5</jc> * <jk>boolean</jk> b = args.getArg(<jk>boolean</jk>.<jk>class</jk>, <js>"verbose"</js>); * <jk>int</jk> i = args.getArg(<jk>int</jk>.<jk>class</jk>, <js>"debug"</js>); * </p> * * @param c The class type to convert the value to. * @param <T> The class type to convert the value to. * @param name The optional argument name. * @return The optional argument value, or blank if the optional argument was not specified. */ public <T> T getArg(Class<T> c, String name) { ObjectList l = (ObjectList)get(name); if (l == null || l.size() == 0) return null; return l.get(0, c); }
/** * Returns the optional argument value converted to the specified object type. * * <p> * If the optional arg has multiple values, returns only the first converted value. * * <h5 class='section'>Example:</h5> * <p class='bcode w800'> * <jc>// Command: java com.sample.MyClass -verbose true -debug 5</jc> * <jk>boolean</jk> b = args.getArg(<jk>boolean</jk>.<jk>class</jk>, <js>"verbose"</js>); * <jk>int</jk> i = args.getArg(<jk>int</jk>.<jk>class</jk>, <js>"debug"</js>); * </p> * * @param c The class type to convert the value to. * @param <T> The class type to convert the value to. * @param name The optional argument name. * @return The optional argument value, or blank if the optional argument was not specified. */ public <T> T getArg(Class<T> c, String name) { ObjectList l = (ObjectList)get(name); if (l == null || l.size() == 0) return null; return l.get(0, c); }
put(key, new ObjectList()); } else { ((ObjectList)get(key)).add(s);
put(key, new ObjectList()); } else { ((ObjectList)get(key)).add(s);
put(key, new ObjectList()); } else { ((ObjectList)get(key)).add(s);