Package de.mhus.lib.core
Class MArgs
- java.lang.Object
-
- de.mhus.lib.core.MArgs
-
public class MArgs extends Object
The class is a parser for program argument lists, like you get in the main(args) method. You can also put a usage definition to the constructor to define the possible methods. The parser will parse all arguments. If a minus is the first character the next argument will be stored under this key. A argument key can be there multiple times. If there no value after the key the key is marked as existing. A value without a key on front of it is stored under the DEFAUTL key. The "usage" feature is not finished yet!- Author:
- mhu
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(String name)Returns true if the argument list contains the key.protected List<String>getArgValues(String name)Returns a List of the arguments for the given key.Set<String>getKeys()Return a iterable set of existing keys.intgetSize(String name)Returns the amount of attributes for this key.StringgetValue(String name, int index)Returns the "index" parameter for this key.StringgetValue(String name, String def, int index)Returns the "index" parameter for this key.String[]getValues(String name)Return all values for this parameter as a array.StringtoString()
-
-
-
Field Detail
-
DEFAULT
public static final String DEFAULT
- See Also:
- Constant Field Values
-
-
Method Detail
-
contains
public boolean contains(String name)
Returns true if the argument list contains the key.- Parameters:
name-- Returns:
- if is included
-
getArgValues
protected List<String> getArgValues(String name)
Returns a List of the arguments for the given key. If the key was not set it returns null. Do not change the list.- Parameters:
name-- Returns:
-
getSize
public int getSize(String name)
Returns the amount of attributes for this key.- Parameters:
name-- Returns:
- the size
-
getValue
public String getValue(String name, String def, int index)
Returns the "index" parameter for this key. If the parameter is not set in this index it returns "def".- Parameters:
name-def-index-- Returns:
- the value
-
getValue
public String getValue(String name, int index)
Returns the "index" parameter for this key. If the parameter is not set in this index it returns null.- Parameters:
name-index-- Returns:
- the value
-
getValues
public String[] getValues(String name)
Return all values for this parameter as a array. If not set it will return an empty array.- Parameters:
name-- Returns:
- the value
-
-