Class Namespace

java.lang.Object
net.sourceforge.argparse4j.inf.Namespace

public class Namespace extends Object

This class holds attributes added by ArgumentParser.parseArgs(String[]).

It is just a wrapper of Map object which stores actual attributes. Map object can be retrieved using getAttrs(). This class provides several shortcut methods to get attribute values. toString() provides nice textual representation of stored attributes.

  • Constructor Details

    • Namespace

      public Namespace(Map<String,Object> attrs)
      Construct this object using given attrs.
      Parameters:
      attrs - The attributes
  • Method Details

    • get

      public <T> T get(String dest)
      Returns attribute with given attribute name dest.
      Parameters:
      dest - The attribute name
      Returns:
      The attribute value, or null if it is not found.
    • getString

      public String getString(String dest)
      Returns attribute as String with given attribute name dest. This method calls Object.toString() method of a found object to get string representation unless object is null.
      Parameters:
      dest - The attribute name
      Returns:
      The attribute value casted to String, or null if is not found.
    • getByte

      public Byte getByte(String dest)
      Returns attribute as Byte with given attribute name dest.
      Parameters:
      dest - The attribute name
      Returns:
      The attribute value casted to Byte, or null if it is not found.
    • getShort

      public Short getShort(String dest)
      Returns attribute as Short with given attribute name dest .
      Parameters:
      dest - The attribute name
      Returns:
      The attribute value casted to Short, or null if it is not found.
    • getInt

      public Integer getInt(String dest)
      Returns attribute as Integer with given attribute name dest.
      Parameters:
      dest - The attribute name
      Returns:
      The attribute value casted to Integer, or null if it is not found.
    • getLong

      public Long getLong(String dest)
      Returns attribute as Long with given attribute name dest.
      Parameters:
      dest - The attribute name
      Returns:
      The attribute value casted to Long, or null if it is not found.
    • getFloat

      public Float getFloat(String dest)
      Returns attribute as Float with given attribute name dest .
      Parameters:
      dest - The attribute name
      Returns:
      The attribute value casted to Float, or null if it is not found.
    • getDouble

      public Double getDouble(String dest)
      Returns attribute as Double with given attribute name dest.
      Parameters:
      dest - The attribute name
      Returns:
      The attribute value casted to Double, or null if it is not found.
    • getBoolean

      public Boolean getBoolean(String dest)
      Returns attribute as Boolean with given attribute name dest.
      Parameters:
      dest - The attribute name
      Returns:
      The attribute value casted to Boolean, or null if it is not found.
    • getList

      public <E> List<E> getList(String dest)
      Returns attribute as List with given attribute name dest.
      Parameters:
      dest - The attribute name
      Returns:
      The attribute value casted to List, or null if it is not found.
    • getAttrs

      public Map<String,Object> getAttrs()

      Returns Map object holding attribute values.

      The application code can freely use returned object.

      Returns:
      Map object holding attribute values.
    • toString

      public String toString()
      Overrides:
      toString in class Object