Package net.sourceforge.argparse4j.inf
Class Namespace
- java.lang.Object
-
- net.sourceforge.argparse4j.inf.Namespace
-
public class Namespace extends java.lang.ObjectThis class holds attributes added by
ArgumentParser.parseArgs(String[]).It is just a wrapper of
Mapobject which stores actual attributes.Mapobject can be retrieved usinggetAttrs(). This class provides several shortcut methods to get attribute values.toString()provides nice textual representation of stored attributes.
-
-
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> Tget(java.lang.String dest)Returns attribute with given attribute namedest.java.util.Map<java.lang.String,java.lang.Object>getAttrs()ReturnsMapobject holding attribute values.java.lang.BooleangetBoolean(java.lang.String dest)Returns attribute asBooleanwith given attribute namedest.java.lang.BytegetByte(java.lang.String dest)Returns attribute asBytewith given attribute namedest.java.lang.DoublegetDouble(java.lang.String dest)Returns attribute asDoublewith given attribute namedest.java.lang.FloatgetFloat(java.lang.String dest)Returns attribute asFloatwith given attribute namedest.java.lang.IntegergetInt(java.lang.String dest)Returns attribute asIntegerwith given attribute namedest.<E> java.util.List<E>getList(java.lang.String dest)Returns attribute asListwith given attribute namedest.java.lang.LonggetLong(java.lang.String dest)Returns attribute asLongwith given attribute namedest.java.lang.ShortgetShort(java.lang.String dest)Returns attribute asShortwith given attribute namedest.java.lang.StringgetString(java.lang.String dest)Returns attribute asStringwith given attribute namedest.java.lang.StringtoString()
-
-
-
Method Detail
-
get
public <T> T get(java.lang.String dest)
Returns attribute with given attribute namedest.- Parameters:
dest- The attribute name- Returns:
- The attribute value, or
nullif it is not found.
-
getString
public java.lang.String getString(java.lang.String dest)
Returns attribute asStringwith 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, ornullif is not found.
-
getByte
public java.lang.Byte getByte(java.lang.String dest)
Returns attribute asBytewith given attribute namedest.- Parameters:
dest- The attribute name- Returns:
- The attribute value casted to
Byte, ornullif it is not found.
-
getShort
public java.lang.Short getShort(java.lang.String dest)
Returns attribute asShortwith given attribute namedest.- Parameters:
dest- The attribute name- Returns:
- The attribute value casted to
Short, ornullif it is not found.
-
getInt
public java.lang.Integer getInt(java.lang.String dest)
Returns attribute asIntegerwith given attribute namedest.- Parameters:
dest- The attribute name- Returns:
- The attribute value casted to
Integer, ornullif it is not found.
-
getLong
public java.lang.Long getLong(java.lang.String dest)
Returns attribute asLongwith given attribute namedest.- Parameters:
dest- The attribute name- Returns:
- The attribute value casted to
Long, ornullif it is not found.
-
getFloat
public java.lang.Float getFloat(java.lang.String dest)
Returns attribute asFloatwith given attribute namedest.- Parameters:
dest- The attribute name- Returns:
- The attribute value casted to
Float, ornullif it is not found.
-
getDouble
public java.lang.Double getDouble(java.lang.String dest)
Returns attribute asDoublewith given attribute namedest.- Parameters:
dest- The attribute name- Returns:
- The attribute value casted to
Double, ornullif it is not found.
-
getBoolean
public java.lang.Boolean getBoolean(java.lang.String dest)
Returns attribute asBooleanwith given attribute namedest.- Parameters:
dest- The attribute name- Returns:
- The attribute value casted to
Boolean, ornullif it is not found.
-
getList
public <E> java.util.List<E> getList(java.lang.String dest)
Returns attribute asListwith given attribute namedest.- Parameters:
dest- The attribute name- Returns:
- The attribute value casted to
List, ornullif it is not found.
-
getAttrs
public java.util.Map<java.lang.String,java.lang.Object> getAttrs()
Returns
Mapobject holding attribute values.The application code can freely use returned object.
- Returns:
Mapobject holding attribute values.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-