- java.lang.Object
-
- net.sourceforge.argparse4j.inf.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 usinggetAttrs()
. 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 givenattrs
.
-
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 namedest
.java.util.Map<java.lang.String,java.lang.Object>
getAttrs()
ReturnsMap
object holding attribute values.java.lang.Boolean
getBoolean(java.lang.String dest)
Returns attribute asBoolean
with given attribute namedest
.java.lang.Byte
getByte(java.lang.String dest)
Returns attribute asByte
with given attribute namedest
.java.lang.Double
getDouble(java.lang.String dest)
Returns attribute asDouble
with given attribute namedest
.java.lang.Float
getFloat(java.lang.String dest)
Returns attribute asFloat
with given attribute namedest
.java.lang.Integer
getInt(java.lang.String dest)
Returns attribute asInteger
with given attribute namedest
.<E> java.util.List<E>
getList(java.lang.String dest)
Returns attribute asList
with given attribute namedest
.java.lang.Long
getLong(java.lang.String dest)
Returns attribute asLong
with given attribute namedest
.java.lang.Short
getShort(java.lang.String dest)
Returns attribute asShort
with given attribute namedest
.java.lang.String
getString(java.lang.String dest)
Returns attribute asString
with given attribute namedest
.java.lang.String
toString()
-
-
-
Method Detail
-
get
public <T> T get(java.lang.String dest)
Returns attribute with given attribute namedest
.- 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 asString
with given attribute namedest
. This method callsObject.toString()
method of a found object to get string representation unless object isnull
.- Parameters:
dest
- The attribute name- Returns:
- The attribute value casted to
String
, ornull
if is not found.
-
getByte
public java.lang.Byte getByte(java.lang.String dest)
Returns attribute asByte
with given attribute namedest
.- Parameters:
dest
- The attribute name- Returns:
- The attribute value casted to
Byte
, ornull
if it is not found.
-
getShort
public java.lang.Short getShort(java.lang.String dest)
Returns attribute asShort
with given attribute namedest
.- Parameters:
dest
- The attribute name- Returns:
- The attribute value casted to
Short
, ornull
if it is not found.
-
getInt
public java.lang.Integer getInt(java.lang.String dest)
Returns attribute asInteger
with given attribute namedest
.- Parameters:
dest
- The attribute name- Returns:
- The attribute value casted to
Integer
, ornull
if it is not found.
-
getLong
public java.lang.Long getLong(java.lang.String dest)
Returns attribute asLong
with given attribute namedest
.- Parameters:
dest
- The attribute name- Returns:
- The attribute value casted to
Long
, ornull
if it is not found.
-
getFloat
public java.lang.Float getFloat(java.lang.String dest)
Returns attribute asFloat
with given attribute namedest
.- Parameters:
dest
- The attribute name- Returns:
- The attribute value casted to
Float
, ornull
if it is not found.
-
getDouble
public java.lang.Double getDouble(java.lang.String dest)
Returns attribute asDouble
with given attribute namedest
.- Parameters:
dest
- The attribute name- Returns:
- The attribute value casted to
Double
, ornull
if it is not found.
-
getBoolean
public java.lang.Boolean getBoolean(java.lang.String dest)
Returns attribute asBoolean
with given attribute namedest
.- Parameters:
dest
- The attribute name- Returns:
- The attribute value casted to
Boolean
, ornull
if it is not found.
-
getList
public <E> java.util.List<E> getList(java.lang.String dest)
Returns attribute asList
with given attribute namedest
.- Type Parameters:
E
- The type of the list elements- Parameters:
dest
- The attribute name- Returns:
- The attribute value casted to
List
, ornull
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 classjava.lang.Object
-
-