Package digilib.util

Class Parameter


  • public class Parameter
    extends Object
    General digilib parameter class.
    Author:
    casties
    • Field Detail

      • value

        protected Object value
        real value
      • defval

        protected Object defval
        default value
      • name

        protected String name
        parameter name (e.g. in config file)
      • type

        protected int type
        parameter type
    • Constructor Detail

      • Parameter

        public Parameter()
        Default constructor.
      • Parameter

        public Parameter​(String name,
                         Object defval,
                         Object value)
        Constructor with name, default, and value.
        Parameters:
        value - the value
        defval - the default
        name - the name
      • Parameter

        public Parameter​(String name,
                         Object defval,
                         Object value,
                         int type)
        Constructor with name, default, value, and type.
        Parameters:
        name - the name
        defval - the default
        value - the value
        type - the type
    • Method Detail

      • hasValue

        public boolean hasValue()
        Is the value set.
        Returns:
        if the value is set
      • setValueFromString

        public boolean setValueFromString​(String val)
        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

        public Object getDefault()
        Get the default as Object.
        Returns:
        the default
      • setDefault

        public void setDefault​(Object defval)
        Set the default.
        Parameters:
        defval - the default
      • getValue

        public Object 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

        public String 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

        public File getAsFile()
        Get the value as File. Returns the default if the value is not set.
        Returns:
        the value
      • parseAsArray

        public String[] parseAsArray​(String separator)
        Get the value as Strings split using the separator.
        Parameters:
        separator - the separator
        Returns:
        the strings
      • parseAsFloatArray

        public float[] parseAsFloatArray​(String separator)
        Get the value as floats split using the separator.
        Parameters:
        separator - the separator
        Returns:
        the floats
      • setValue

        public void setValue​(Object value)
        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

        public String getName()
        Returns:
        the name
      • setName

        public void setName​(String name)
        Parameters:
        name - the name
      • getType

        public int getType()
        Returns:
        the type
      • setType

        public void setType​(int type)
        Parameters:
        type - the type