Class UnitTypeOption

    • Field Detail

      • logger

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

        private UnitType value
        The option value.
      • addNone

        private boolean addNone
        Whether to add "none" to the list of choices to be generated.
      • choices

        private final java.util.List<UnitType> choices
        A list of choices to provide to the UI.
    • Constructor Detail

      • UnitTypeOption

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

        public UnitTypeOption​(java.lang.String id,
                              Specification specification)
        Creates a new UnitTypeOption.
        Parameters:
        id - The object identifier.
        specification - The Specification to refer to.
    • Method Detail

      • addNone

        public final boolean addNone()
        Is "none" a valid choice for this option?
        Returns:
        True if "none" is a valid choice.
      • getChoices

        public final java.util.List<UnitType> getChoices()
        Get the list of choices for this option.
        Returns:
        A list of UnitTypes.
      • getSelector

        public final UnitTypeOption.TypeSelector getSelector()
        Get the type of choices to generate.
        Returns:
        The type of choices to generate.
      • setValue

        protected void setValue​(java.lang.String valueString,
                                java.lang.String defaultValueString)
        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.
        Overrides:
        setValue in class AbstractOption<UnitType>
        Parameters:
        valueString - The string representation of the value of this Option.
        defaultValueString - The string representation of the default value of this Option.
      • isNullValueOK

        public boolean isNullValueOK()
        Is null an acceptable value for this option? Override this in subclasses where necessary.
        Overrides:
        isNullValueOK in class AbstractOption<UnitType>
        Returns:
        False.
      • generateChoices

        public void generateChoices()
        Generate the choices to provide to the UI. Override if the subclass needs to determine its choices dynamically.
        Overrides:
        generateChoices in class AbstractOption<UnitType>
      • 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 AbstractOption<UnitType>
        Parameters:
        xw - The FreeColXMLWriter to write to.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.
      • writeChildren

        protected void writeChildren​(FreeColXMLWriter xw)
                              throws javax.xml.stream.XMLStreamException
        Write the children of this object to a stream. To be overridden if required by any object that has children and uses the toXML(FreeColXMLWriter, String) call.
        Overrides:
        writeChildren in class FreeColObject
        Parameters:
        xw - The FreeColXMLWriter to write to.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.
      • 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 AbstractOption<UnitType>
        Parameters:
        xr - The FreeColXMLReader to read from.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem reading the stream.
      • readChildren

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

        protected void readChild​(FreeColXMLReader xr)
                          throws javax.xml.stream.XMLStreamException
        Reads a single child object. Subclasses must override to read their enclosed elements. This particular instance of the routine always throws XMLStreamException because we should never arrive here. However it is very useful to always call super.readChild() when an unexpected tag is encountered, as the exception thrown here provides some useful debugging context.
        Overrides:
        readChild in class FreeColObject
        Parameters:
        xr - The FreeColXMLReader to read from.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem reading the stream.
      • getXMLTagName

        public java.lang.String getXMLTagName()
        Get the serialization tag for this object.
        Specified by:
        getXMLTagName in class FreeColObject
        Returns:
        The tag.