Class Namespace


  • public class Namespace
    extends java.lang.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.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<java.lang.String,​java.lang.Object> attrs_  
    • Constructor Summary

      Constructors 
      Constructor Description
      Namespace​(java.util.Map<java.lang.String,​java.lang.Object> attrs)
      Construct this object using given attrs.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> T get​(java.lang.String dest)
      Returns attribute with given attribute name dest.
      java.util.Map<java.lang.String,​java.lang.Object> getAttrs()
      Returns Map object holding attribute values.
      java.lang.Boolean getBoolean​(java.lang.String dest)
      Returns attribute as Boolean with given attribute name dest.
      java.lang.Byte getByte​(java.lang.String dest)
      Returns attribute as Byte with given attribute name dest.
      java.lang.Double getDouble​(java.lang.String dest)
      Returns attribute as Double with given attribute name dest.
      java.lang.Float getFloat​(java.lang.String dest)
      Returns attribute as Float with given attribute name dest .
      java.lang.Integer getInt​(java.lang.String dest)
      Returns attribute as Integer with given attribute name dest.
      <E> java.util.List<E> getList​(java.lang.String dest)
      Returns attribute as List with given attribute name dest.
      java.lang.Long getLong​(java.lang.String dest)
      Returns attribute as Long with given attribute name dest.
      java.lang.Short getShort​(java.lang.String dest)
      Returns attribute as Short with given attribute name dest .
      java.lang.String getString​(java.lang.String dest)
      Returns attribute as String with given attribute name dest.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • attrs_

        private final java.util.Map<java.lang.String,​java.lang.Object> attrs_
    • Constructor Detail

      • Namespace

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

      • get

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

        public java.lang.String getString​(java.lang.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 java.lang.Byte getByte​(java.lang.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 java.lang.Short getShort​(java.lang.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 java.lang.Integer getInt​(java.lang.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 java.lang.Long getLong​(java.lang.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 java.lang.Float getFloat​(java.lang.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 java.lang.Double getDouble​(java.lang.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 java.lang.Boolean getBoolean​(java.lang.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> java.util.List<E> getList​(java.lang.String dest)
        Returns attribute as List with given attribute name dest.
        Type Parameters:
        E - The type of the list elements
        Parameters:
        dest - The attribute name
        Returns:
        The attribute value casted to List, or null if it is not found.
      • getAttrs

        public java.util.Map<java.lang.String,​java.lang.Object> getAttrs()

        Returns Map object holding attribute values.

        The application code can freely use returned object.

        Returns:
        Map object holding attribute values.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object