Package digilib.util
Class Parameter
java.lang.Object
digilib.util.Parameter
General digilib parameter class.
- Author:
- casties
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanGet the value as boolean.Get the value as File.floatGet the value as float.intgetAsInt()Get the value as Object.Get the value as String.Get the default as Object.getName()intgetType()getValue()Get the value as Object.booleanhasValue()Is the value set.String[]parseAsArray(String separator) Get the value as Strings split using the separator.float[]parseAsFloatArray(String separator) Get the value as floats split using the separator.voidsetDefault(Object defval) Set the default.voidvoidsetType(int type) voidsetValue(float value) Set the value.voidsetValue(int value) Set the value.voidSet the value.booleansetValueFromString(String val) Try to set the value from a String.
-
Field Details
-
value
real value -
defval
default value -
name
parameter name (e.g. in config file) -
type
protected int typeparameter type
-
-
Constructor Details
-
Parameter
public Parameter()Default constructor. -
Parameter
Constructor with name, default, and value.- Parameters:
name- the namedefval- the defaultvalue- the value
-
Parameter
Constructor with name, default, value, and type.- Parameters:
name- the namedefval- the defaultvalue- the valuetype- the type
-
-
Method Details
-
hasValue
public boolean hasValue()Is the value set.- Returns:
- if the value is set
-
setValueFromString
Try to set the value from a String. Tries to convert the String to the same type as the default value. Sets the value anyway if the default is null. Returns if the value could be set.- Parameters:
val- the value- Returns:
- if the value was set
-
getDefault
Get the default as Object.- Returns:
- the default
-
setDefault
Set the default.- Parameters:
defval- the default
-
getValue
Get the value as Object. Returns the default if the value is not set.- Returns:
- the value
-
getAsInt
public int getAsInt()Get the value as Object. Returns the default if the value is not set.- Returns:
- the value
-
getAsFloat
public float getAsFloat()Get the value as float. Returns the default if the value is not set.- Returns:
- the value
-
getAsString
Get the value as String. Returns the default if the value is not set.- Returns:
- the value
-
getAsBoolean
public boolean getAsBoolean()Get the value as boolean. Returns the default if the value is not set.- Returns:
- the value
-
getAsFile
Get the value as File. Returns the default if the value is not set.- Returns:
- the value
-
parseAsArray
Get the value as Strings split using the separator.- Parameters:
separator- the separator- Returns:
- the strings
-
parseAsFloatArray
Get the value as floats split using the separator.- Parameters:
separator- the separator- Returns:
- the floats
-
setValue
Set the value.- Parameters:
value- the value
-
setValue
public void setValue(int value) Set the value.- Parameters:
value- the value
-
setValue
public void setValue(float value) Set the value.- Parameters:
value- the value
-
getName
- Returns:
- the name
-
setName
- Parameters:
name- the name
-
getType
public int getType()- Returns:
- the type
-
setType
public void setType(int type) - Parameters:
type- the type
-