Class AbstractOption<T>

    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • optionGroupId

        private java.lang.String optionGroupId
        The option group prefix.
      • isDefined

        protected boolean isDefined
        Determine if the option has been defined. When defined an option won't change when a default value is read from an XML file.
      • enabledBy

        private java.lang.String enabledBy
      • DEFAULT_VALUE_TAG

        protected static final java.lang.String DEFAULT_VALUE_TAG
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractOption

        protected AbstractOption​(java.lang.String id,
                                 Specification specification)
        Creates a new AbstractOption.
        Parameters:
        id - The object identifier.
        specification - The Specification to refer to.
      • AbstractOption

        protected AbstractOption​(java.lang.String id)
        Creates a new AbstractOption.
        Parameters:
        id - The object identifier.
      • AbstractOption

        public AbstractOption​(Specification specification)
        Creates a new AbstractOption.
        Parameters:
        specification - The Specification to refer to.
    • Method Detail

      • setValues

        protected void setValues​(AbstractOption<T> source)
        Sets the values from another option.
        Parameters:
        source - The other AbstractOption.
      • setValue

        protected void setValue​(java.lang.String valueString,
                                java.lang.String defaultValueString)
                         throws javax.xml.stream.XMLStreamException
        Sets the value of this option from the given string representation. Both parameters must not be null at the same time. This method does nothing. Override it if the option has a suitable string representation.
        Parameters:
        valueString - The string representation of the value of this Option.
        defaultValueString - The string representation of the default value of this Option.
        Throws:
        javax.xml.stream.XMLStreamException - if the value is invalid.
      • generateChoices

        public void generateChoices()
        Generate the choices to provide to the UI. Override if the subclass needs to determine its choices dynamically.
      • isNullValueOK

        public boolean isNullValueOK()
        Is null an acceptable value for this option? Override this in subclasses where necessary.
        Returns:
        False.
      • cloneOption

        public abstract AbstractOption<T> cloneOption()
                                               throws java.lang.CloneNotSupportedException
        Clone this option.
        Specified by:
        cloneOption in interface Option<T>
        Returns:
        A clone of this option.
        Throws:
        java.lang.CloneNotSupportedException - if we can not clone.
      • getGroup

        public java.lang.String getGroup()
        Gets the option group identifier for this option.
        Specified by:
        getGroup in interface Option<T>
        Returns:
        The option group identifier.
      • setGroup

        public void setGroup​(java.lang.String group)
        Set the option group for this option.
        Specified by:
        setGroup in interface Option<T>
        Parameters:
        group - The identifier for the option group.
      • getValue

        public abstract T getValue()
        Gets the value of this option.
        Specified by:
        getValue in interface Option<T>
        Returns:
        The value of this Option.
      • setValue

        public abstract void setValue​(T value)
        Sets the value of this option.
        Specified by:
        setValue in interface Option<T>
        Parameters:
        value - The new value of this Option.
      • getEnabledBy

        public java.lang.String getEnabledBy()
        Gets the key of an BooleanOption that must be true for this option to be enabled.
        Specified by:
        getEnabledBy in interface Option<T>
        Returns:
        The key of the BooleanOption that needs to be enabled.
      • readAttributes

        protected void readAttributes​(FreeColXMLReader xr)
                               throws javax.xml.stream.XMLStreamException
        Reads the attributes of this object from an XML stream.
        Overrides:
        readAttributes in class FreeColObject
        Parameters:
        xr - The FreeColXMLReader to read from.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem reading the stream.
      • writeAttributes

        protected void writeAttributes​(FreeColXMLWriter xw)
                                throws javax.xml.stream.XMLStreamException
        Write the attributes of this object to a stream. To be overridden if required by any object that has attributes and uses the toXML(FreeColXMLWriter, String) call.
        Overrides:
        writeAttributes in class FreeColObject
        Parameters:
        xw - The FreeColXMLWriter to write to.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.
      • readOption

        protected AbstractOption readOption​(FreeColXMLReader xr)
                                     throws javax.xml.stream.XMLStreamException
        General option reader routine.
        Parameters:
        xr - The FreeColXMLReader to read from.
        Returns:
        An option.
        Throws:
        javax.xml.stream.XMLStreamException - on stream errors.