Class AbstractUnitOption

    • Field Detail

      • logger

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

        private AbstractUnit value
        The value of this option.
      • unitTypeOption

        private UnitTypeOption unitTypeOption
        An Option to determine the UnitType of the AbstractUnit.
      • roleOption

        private StringOption roleOption
        An Option to determine the Role of the AbstractUnit.
      • numberOption

        private IntegerOption numberOption
        An Option to determine the number of the AbstractUnit.
      • nationType

        private NationType nationType
        An optional nation type for the unit.
    • Constructor Detail

      • AbstractUnitOption

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

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

      • requireUnitTypeOption

        private void requireUnitTypeOption()
      • requireRoleOption

        private void requireRoleOption()
      • requireNumberOption

        private void requireNumberOption()
      • getUnitType

        public final UnitTypeOption getUnitType()
        Get the unit type option.
        Returns:
        The UnitTypeOption containing the unit type.
      • getRole

        public final StringOption getRole()
        Get the role option.
        Returns:
        The StringOption containing the role.
      • getNumber

        public final IntegerOption getNumber()
        Get the number option.
        Returns:
        The IntegerOption containing the number.
      • getNationType

        public final NationType getNationType()
        Get the nation type.
        Returns:
        The optional NationType.
      • isNullValueOK

        public boolean isNullValueOK()
        Is null an acceptable value for this option? Override this in subclasses where necessary.
        Overrides:
        isNullValueOK in class AbstractOption<AbstractUnit>
        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<AbstractUnit>
      • 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<AbstractUnit>
        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<AbstractUnit>
        Parameters:
        xr - The FreeColXMLReader to read from.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem reading the stream.
      • readChildren

        public 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

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