Class FreeColObject

    • Field Detail

      • logger

        protected static final java.util.logging.Logger logger
      • fcoComparator

        public static final java.util.Comparator<? super FreeColObject> fcoComparator
        Comparator by FCO identifier.
      • DEFAULT_CLASS_INDEX

        protected static final int DEFAULT_CLASS_INDEX
        Fallback class index.
        See Also:
        Constant Field Values
      • id

        private java.lang.String id
        The identifier of an object.
      • pcs

        private java.beans.PropertyChangeSupport pcs
        An optional property change container, allocated on demand.
      • ID_ATTRIBUTE_TAG

        public static final java.lang.String ID_ATTRIBUTE_TAG
        XML tag name for identifier attribute.
        See Also:
        Constant Field Values
      • ARRAY_SIZE_TAG

        public static final java.lang.String ARRAY_SIZE_TAG
        XML tag name for array elements.
        See Also:
        Constant Field Values
      • PARTIAL_ATTRIBUTE_TAG

        public static final java.lang.String PARTIAL_ATTRIBUTE_TAG
        XML attribute tag to denote partial updates.
        See Also:
        Constant Field Values
      • VALUE_TAG

        protected static final java.lang.String VALUE_TAG
        XML tag name for value attributes, used in many places.
        See Also:
        Constant Field Values
    • Constructor Detail

      • FreeColObject

        public FreeColObject()
    • Method Detail

      • getFreeColObjectClassByName

        public static <T extends FreeColObject> java.lang.Class<T> getFreeColObjectClassByName​(java.lang.String name)
        Get the FreeColObject class corresponding to a class name.
        Type Parameters:
        T - A FreeColObject subclass.
        Parameters:
        name - The class name.
        Returns:
        The class, or null if none found.
      • getFreeColObjectClass

        public <T extends FreeColObject> java.lang.Class<T> getFreeColObjectClass()
        Get the FreeColObject class for this object.
        Type Parameters:
        T - A FreeColObject subclass.
        Returns:
        The class, or null on error.
      • getId

        public java.lang.String getId()
        Get the object unique identifier.
        Specified by:
        getId in interface ObjectWithId
        Returns:
        The identifier.
      • setId

        public void setId​(java.lang.String newId)
        Set the object identifier.
        Parameters:
        newId - The new object identifier.
      • idEquals

        public boolean idEquals​(FreeColObject other)
        Does another FreeColObject have the same identifier?
        Parameters:
        other - The other FreeColObject to check.
        Returns:
        True if the identifiers are non-null and equal.
      • getSuffix

        public final java.lang.String getSuffix​(java.lang.String prefix)
        Gets the identifier of this object with the given prefix removed if the id of the object starts with the prefix, and the entire id otherwise.
        Parameters:
        prefix - The prefix to test.
        Returns:
        An identifier.
      • getSuffix

        public final java.lang.String getSuffix()
        Gets the usual suffix of this object's identifier, that is everything after the last '.'.
        Returns:
        The usual identifier suffix.
      • getIdTypeByName

        public static java.lang.String getIdTypeByName​(java.lang.String id)
        Get the type part of the identifier.
        Parameters:
        id - The identifier to examine.
        Returns:
        The type part of the identifier, or null on error.
      • getIdType

        public java.lang.String getIdType()
        Get the type part of the identifier of this object.
        Returns:
        The type part of the identifier, or null on error.
      • getIdNumber

        public int getIdNumber()
        Gets the numeric part of the identifier.
        Returns:
        The numeric part of the identifier, or negative on error.
      • compareIds

        public static int compareIds​(FreeColObject fco1,
                                     FreeColObject fco2)
        Compare two FreeColObjects by their identifiers.
        Parameters:
        fco1 - The first FreeColObject to compare.
        fco2 - The second FreeColObject to compare.
        Returns:
        The comparison result.
      • getClassIndex

        public int getClassIndex()
        Accessor for the class index.
        Returns:
        The class index used by ClientOptions.
      • getObjectClassIndex

        public static int getObjectClassIndex​(java.lang.Object o)
        Get the class index, handling null and non-FCO objects.
        Parameters:
        o - The object to examine.
        Returns:
        The class index.
      • getSpecification

        public Specification getSpecification()
        Get the specification.
        Returns:
        The Specification used by this object.
      • setSpecification

        protected void setSpecification​(Specification specification)
        Sets the specification for this object.
        Parameters:
        specification - The Specification to use.
      • getGame

        public Game getGame()
        Gets the game this object belongs to.
        Returns:
        The Game this object belongs to.
      • setGame

        public void setGame​(Game game)
        Sets the game object this object belongs to.
        Parameters:
        game - The Game to set.
      • getPropertyChangeSupport

        protected java.beans.PropertyChangeSupport getPropertyChangeSupport()
      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.lang.String propertyName,
                                              java.beans.PropertyChangeListener listener)
      • fireIndexedPropertyChange

        public void fireIndexedPropertyChange​(java.lang.String propertyName,
                                              int index,
                                              boolean oldValue,
                                              boolean newValue)
      • fireIndexedPropertyChange

        public void fireIndexedPropertyChange​(java.lang.String propertyName,
                                              int index,
                                              int oldValue,
                                              int newValue)
      • fireIndexedPropertyChange

        public void fireIndexedPropertyChange​(java.lang.String propertyName,
                                              int index,
                                              java.lang.Object oldValue,
                                              java.lang.Object newValue)
      • firePropertyChange

        public void firePropertyChange​(java.beans.PropertyChangeEvent event)
      • firePropertyChange

        public void firePropertyChange​(java.lang.String propertyName,
                                       boolean oldValue,
                                       boolean newValue)
      • firePropertyChange

        public void firePropertyChange​(java.lang.String propertyName,
                                       int oldValue,
                                       int newValue)
      • firePropertyChange

        public void firePropertyChange​(java.lang.String propertyName,
                                       java.lang.Object oldValue,
                                       java.lang.Object newValue)
      • getPropertyChangeListeners

        public java.beans.PropertyChangeListener[] getPropertyChangeListeners()
      • getPropertyChangeListeners

        public java.beans.PropertyChangeListener[] getPropertyChangeListeners​(java.lang.String propertyName)
      • hasListeners

        public boolean hasListeners​(java.lang.String propertyName)
      • removePropertyChangeListener

        public void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)
      • removePropertyChangeListener

        public void removePropertyChangeListener​(java.lang.String propertyName,
                                                 java.beans.PropertyChangeListener listener)
      • getFeatureContainer

        public FeatureContainer getFeatureContainer()
        Gets the feature container for this object, if any.
        Returns:
        The FeatureContainer for this object.
      • hasAbility

        public final boolean hasAbility​(java.lang.String id)
        Is an ability present in this object?
        Parameters:
        id - The object identifier.
        Returns:
        True if the ability is present.
      • hasAbility

        public final boolean hasAbility​(java.lang.String id,
                                        FreeColSpecObjectType fcgot)
        Is an ability present in this object?
        Parameters:
        id - The object identifier.
        fcgot - An optional FreeColSpecObjectType the ability applies to.
        Returns:
        True if the ability is present.
      • hasAbility

        public final boolean hasAbility​(java.lang.String id,
                                        FreeColSpecObjectType fcgot,
                                        Turn turn)
        Is an ability present in this object?
        Parameters:
        id - The object identifier.
        fcgot - An optional FreeColSpecObjectType the ability applies to.
        turn - An optional applicable Turn.
        Returns:
        True if the ability is present.
      • containsAbilityKey

        public boolean containsAbilityKey​(java.lang.String key)
        Checks if this object contains a given ability key.
        Parameters:
        key - The key to check.
        Returns:
        True if the key is present.
      • getSortedAbilities

        public final java.util.List<Ability> getSortedAbilities()
        Gets a sorted copy of the abilities of this object.
        Returns:
        A list of abilities.
      • getAbilities

        public final java.util.stream.Stream<Ability> getAbilities()
        Gets a copy of the abilities of this object.
        Returns:
        A stream of abilities.
      • getAbilities

        public final java.util.stream.Stream<Ability> getAbilities​(java.lang.String id)
        Gets the set of abilities with the given identifier from this object.
        Parameters:
        id - The object identifier.
        Returns:
        A stream of abilities.
      • getAbilities

        public final java.util.stream.Stream<Ability> getAbilities​(java.lang.String id,
                                                                   FreeColSpecObjectType fcgot)
        Gets the set of abilities with the given identifier from this object.
        Parameters:
        id - The object identifier.
        fcgot - An optional FreeColSpecObjectType the ability applies to.
        Returns:
        A stream of abilities.
      • getAbilities

        public java.util.stream.Stream<Ability> getAbilities​(java.lang.String id,
                                                             FreeColSpecObjectType fcgot,
                                                             Turn turn)
        Gets the set of abilities with the given identifier from this object. Subclasses with complex ability handling should override this as all prior routines are derived from it.
        Parameters:
        id - The object identifier.
        fcgot - An optional FreeColSpecObjectType the ability applies to.
        turn - An optional applicable Turn.
        Returns:
        A set of abilities.
      • addAbility

        public boolean addAbility​(Ability ability)
        Add the given ability to this object.
        Parameters:
        ability - An Ability to add.
        Returns:
        True if the ability was added.
      • removeAbility

        public Ability removeAbility​(Ability ability)
        Remove the given ability from this object.
        Parameters:
        ability - An Ability to remove.
        Returns:
        The ability removed or null on failure.
      • removeAbilities

        public void removeAbilities​(java.lang.String id)
        Remove all abilities with a given identifier.
        Parameters:
        id - The object identifier.
      • hasModifier

        public final boolean hasModifier​(java.lang.String id)
        Is an modifier present in this object?
        Parameters:
        id - The object identifier.
        Returns:
        True if the modifier is present.
      • hasModifier

        public final boolean hasModifier​(java.lang.String id,
                                         FreeColSpecObjectType fcgot)
        Is an modifier present in this object?
        Parameters:
        id - The object identifier.
        fcgot - An optional FreeColSpecObjectType the modifier applies to.
        Returns:
        True if the modifier is present.
      • hasModifier

        public boolean hasModifier​(java.lang.String id,
                                   FreeColSpecObjectType fcgot,
                                   Turn turn)
        Is an modifier present in this object?
        Parameters:
        id - The object identifier.
        fcgot - An optional FreeColSpecObjectType the modifier applies to.
        turn - An optional applicable Turn.
        Returns:
        True if the modifier is present.
      • containsModifierKey

        public final boolean containsModifierKey​(java.lang.String key)
        Checks if this object contains a given modifier key.
        Parameters:
        key - The key to check.
        Returns:
        True if the key is present.
      • getSortedModifiers

        public final java.util.List<Modifier> getSortedModifiers()
        Gets a sorted copy of the modifiers of this object.
        Returns:
        A list of modifiers.
      • getModifiers

        public final java.util.stream.Stream<Modifier> getModifiers()
        Gets a copy of the modifiers of this object.
        Returns:
        A set of modifiers.
      • getModifiers

        public final java.util.stream.Stream<Modifier> getModifiers​(java.lang.String id)
        Gets the set of modifiers with the given identifier from this object.
        Parameters:
        id - The object identifier.
        Returns:
        A set of modifiers.
      • getModifiers

        public final java.util.stream.Stream<Modifier> getModifiers​(java.lang.String id,
                                                                    FreeColSpecObjectType fcgot)
        Gets the set of modifiers with the given identifier from this object.
        Parameters:
        id - The object identifier.
        fcgot - An optional FreeColSpecObjectType the modifier applies to.
        Returns:
        A set of modifiers.
      • getModifiers

        public java.util.stream.Stream<Modifier> getModifiers​(java.lang.String id,
                                                              FreeColSpecObjectType fcgot,
                                                              Turn turn)
        Gets the set of modifiers with the given identifier from this object. Subclasses with complex modifier handling may override this routine.
        Parameters:
        id - The object identifier.
        fcgot - An optional FreeColSpecObjectType the modifier applies to.
        turn - An optional applicable Turn.
        Returns:
        A set of modifiers.
      • apply

        public final float apply​(float number,
                                 Turn turn,
                                 java.lang.String id)
        Applies this objects modifiers with the given identifier to the given number.
        Parameters:
        number - The number to modify.
        turn - An optional applicable Turn.
        id - The object identifier.
        Returns:
        The modified number.
      • apply

        public final float apply​(float number,
                                 Turn turn,
                                 java.lang.String id,
                                 FreeColSpecObjectType fcgot)
        Applies this objects modifiers with the given identifier to the given number.
        Parameters:
        number - The number to modify.
        turn - An optional applicable Turn.
        id - The object identifier.
        fcgot - An optional FreeColSpecObjectType the modifier applies to.
        Returns:
        The modified number.
      • applyModifiers

        public static final float applyModifiers​(float number,
                                                 Turn turn,
                                                 java.util.stream.Stream<Modifier> mods)
        Applies a stream of modifiers to the given number.
        Parameters:
        number - The number to modify.
        turn - An optional applicable Turn.
        mods - The Modifiers to apply.
        Returns:
        The modified number.
      • applyModifiers

        public static final float applyModifiers​(float number,
                                                 Turn turn,
                                                 java.util.Collection<Modifier> mods)
        Applies a collection of modifiers to the given number.
        Parameters:
        number - The number to modify.
        turn - An optional applicable Turn.
        mods - The Modifiers to apply.
        Returns:
        The modified number.
      • addModifier

        public boolean addModifier​(Modifier modifier)
        Add the given modifier to this object.
        Parameters:
        modifier - An Modifier to add.
        Returns:
        True if the modifier was added.
      • removeModifier

        public Modifier removeModifier​(Modifier modifier)
        Remove the given modifier from this object.
        Parameters:
        modifier - An Modifier to remove.
        Returns:
        The modifier removed.
      • removeModifiers

        public void removeModifiers​(java.lang.String id)
        Remove all abilities with a given identifier.
        Parameters:
        id - The object identifier.
      • addFeatures

        public void addFeatures​(FreeColObject fco)
        Adds all the features in an object to this object.
        Parameters:
        fco - The FreeColObject to add features from.
      • removeFeatures

        public void removeFeatures​(FreeColObject fco)
        Removes all the features in an object from this object.
        Parameters:
        fco - The FreeColObject to find features to remove in.
      • getDefenceModifiers

        public java.util.List<Modifier> getDefenceModifiers()
        Get the defence modifiers applicable to this object.
        Returns:
        A list of defence Modifiers.
      • compareTo

        public int compareTo​(FreeColObject other)
        Base for Comparable implementations.
        Specified by:
        compareTo in interface java.lang.Comparable<FreeColObject>
        Parameters:
        other - The other FreeColObject subclass to compare.
        Returns:
        The comparison result.
      • logFreeColObjects

        public static <T extends FreeColObject> void logFreeColObjects​(java.util.Collection<T> c,
                                                                       LogBuilder lb)
        Log a collection of FreeColObjects.
        Type Parameters:
        T - The collection member type.
        Parameters:
        c - The Collection to log.
        lb - A LogBuilder to log to.
      • invokeMethod

        protected <T> T invokeMethod​(java.lang.String methodName,
                                     java.lang.Class<T> returnClass,
                                     T defaultValue)
        Invoke a method for this object.
        Type Parameters:
        T - The actual return type.
        Parameters:
        methodName - The name of the method.
        returnClass - The expected return class.
        defaultValue - The default value.
        Returns:
        The result of invoking the method, or the default value on failure.
      • getDisplayObject

        public FreeColObject getDisplayObject()
        Get an object to display when showing the user messages for this object. Example: If this object is a Building, the object to display will be the BuildingType.
        Returns:
        A suitable FreeColObject to display, defaults to this.
      • dumpObject

        public void dumpObject()
        Debugging tool, dump object XML to System.err.
      • save

        public boolean save​(java.io.File file)
        Writes the object to the given file.
        Parameters:
        file - The File to write to.
        Returns:
        True if the save proceeded without error.
      • save

        public boolean save​(java.io.File file,
                            FreeColXMLWriter.WriteScope scope)
        Writes the object to the given file.
        Parameters:
        file - The File to write to.
        scope - The WriteScope to use.
        Returns:
        True if the save proceeded without error.
      • save

        public boolean save​(java.io.File file,
                            FreeColXMLWriter.WriteScope scope,
                            boolean pretty)
        Writes the object to the given file.
        Parameters:
        file - The File to write to.
        scope - The WriteScope to use.
        pretty - Attempt to indent the output nicely.
        Returns:
        True if the save proceeded without error.
      • save

        public boolean save​(java.io.OutputStream out,
                            FreeColXMLWriter.WriteScope scope,
                            boolean pretty)
        Writes the object to the given output stream
        Parameters:
        out - The OutputStream to write to.
        scope - The WriteScope to use.
        pretty - Attempt to indent the output nicely.
        Returns:
        True if the save proceeded without error.
      • serialize

        public java.lang.String serialize()
                                   throws javax.xml.stream.XMLStreamException
        Serialize this FreeColObject to a string.
        Returns:
        The serialized object, or null if the stream could not be created.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.
      • serialize

        public java.lang.String serialize​(Player player)
                                   throws javax.xml.stream.XMLStreamException
        Serialize this FreeColObject to a string for a target player.
        Parameters:
        player - The Player to serialize the object to.
        Returns:
        The serialized object, or null if the stream could not be created.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.
      • serialize

        public java.lang.String serialize​(FreeColXMLWriter.WriteScope scope)
                                   throws javax.xml.stream.XMLStreamException
        Serialize this FreeColObject to a string.
        Parameters:
        scope - The write scope to use.
        Returns:
        The serialized object, or null if the stream could not be created.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.
      • serialize

        public java.lang.String serialize​(FreeColXMLWriter.WriteScope scope,
                                          java.util.List<java.lang.String> fields)
                                   throws javax.xml.stream.XMLStreamException
        Serialize this FreeColObject to a string, possibly partially.
        Parameters:
        scope - The write scope to use.
        fields - A list of field names, which if non-null indicates this should be a partial write.
        Returns:
        The serialized object, or null if the stream could not be created.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.
      • copy

        public <T extends FreeColObject> T copy​(Game game)
        Copy a FreeColObject.
        Type Parameters:
        T - The actual return type.
        Parameters:
        game - The Game to add the object to.
        Returns:
        The copied object, or null on error.
      • copy

        public <T extends FreeColObject> T copy​(Game game,
                                                Player player)
        Copy a FreeColObject for a player.
        Type Parameters:
        T - The actual return type.
        Parameters:
        game - The Game to add the object to.
        player - The Player to copy for,
        Returns:
        The copied object, or null on error.
      • copy

        public <T extends FreeColObject> T copy​(Game game,
                                                java.lang.Class<T> returnClass)
        Copy a FreeColObject. The copied object and its internal descendents will be identical to the original objects, but not present in the game. Newly created objects will prefer to refer to other newly created objects. Thus if you copy a tile, an internal colony on the tile will also be copied, and the copied tile will refer to the copied colony and the copied colony refer to the copied tile, but both will refer to the original uncopied owning player.
        Type Parameters:
        T - The actual return type.
        Parameters:
        game - The Game to add the object to.
        returnClass - The expected return class.
        Returns:
        The copied object, or null on error.
      • copy

        public <T extends FreeColObject> T copy​(Game game,
                                                java.lang.Class<T> returnClass,
                                                Player player)
        Copy a FreeColObject for a target player.
        Type Parameters:
        T - The actual return type.
        Parameters:
        game - The Game to add the object to.
        returnClass - The expected return class.
        player - The Player that will see the result.
        Returns:
        The copied object, or null on error.
      • copyIn

        public <T extends FreeColObject> boolean copyIn​(T other)
        Copy another FreeColObject into this one if it is compatible.
        Type Parameters:
        T - The FreeColObject subclass of the object to copy in.
        Parameters:
        other - The other object.
        Returns:
        True if the copy in is succesful.
      • copyInCast

        protected <T extends FreeColObject,​R extends FreeColObject> R copyInCast​(T other,
                                                                                       java.lang.Class<R> returnClass)
        If another object can be copied into this one,
        Type Parameters:
        T - The FreeColObject subclass of the object to copy in.
        R - The FreeColObject subclass to copy in to.
        Parameters:
        other - The FreeColObject to copy in.
        returnClass - The return class.
        Returns:
        The other object cast to the return class, or null if incompatible in any way.
      • toXML

        public void toXML​(FreeColXMLWriter xw)
                   throws javax.xml.stream.XMLStreamException
        This method writes an XML-representation of this object to the given stream. All attributes will be made visible.
        Parameters:
        xw - The FreeColXMLWriter to write to.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.
      • toXML

        public void toXML​(FreeColXMLWriter xw,
                          java.lang.String tag)
                   throws javax.xml.stream.XMLStreamException
        This method writes an XML-representation of this object with a specified tag to the given stream. Almost all FreeColObjects end up calling these, and implementing their own write{Attributes,Children} methods which begin by calling their superclass. This allows a clean nesting of the serialization routines throughout the class hierarchy. All attributes will be made visible.
        Parameters:
        xw - The FreeColXMLWriter to write to.
        tag - The tag to use.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to 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.
        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.
        Parameters:
        xw - The FreeColXMLWriter to write to.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.
      • toXMLPartial

        public final void toXMLPartial​(FreeColXMLWriter xw,
                                       java.lang.String[] fields)
                                throws javax.xml.stream.XMLStreamException
        This method writes a partial XML-representation of this object to the given stream using only the mandatory and specified fields. All attributes are considered visible as this is server-to-owner-client functionality, but it depends ultimately on the presence of a getFieldName() method that returns a type compatible with String.valueOf.
        Parameters:
        xw - The FreeColXMLWriter to write to.
        fields - The fields to write.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.
      • toXMLPartial

        public final void toXMLPartial​(FreeColXMLWriter xw,
                                       java.util.List<java.lang.String> fields)
                                throws javax.xml.stream.XMLStreamException
        Simpler version of toXMLPartial, where the fields are pre-filled with key,value pairs. We thus no longer need call the introspector.
        Parameters:
        xw - The FreeColXMLWriter to write to.
        fields - The fields to write.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.
      • readFromXML

        public void readFromXML​(FreeColXMLReader xr)
                         throws javax.xml.stream.XMLStreamException
        Initializes this object from an XML-representation of this object, unless the PARTIAL_ATTRIBUTE tag is present which indicates a partial update of an existing object.
        Parameters:
        xr - The input stream with the XML.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems reading the stream.
      • readAttributes

        protected void readAttributes​(FreeColXMLReader xr)
                               throws javax.xml.stream.XMLStreamException
        Reads the attributes of this object from an XML stream.
        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.
        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.
        Parameters:
        xr - The FreeColXMLReader to read from.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem reading the stream.
      • readFromXMLPartial

        public final void readFromXMLPartial​(FreeColXMLReader xr)
                                      throws javax.xml.stream.XMLStreamException
        Updates this object from an XML-representation of this object. All attributes are considered visible as this is server-to-owner-client functionality. It depends ultimately on the presence of a setFieldName() method that takes a parameter type T where T.valueOf(String) exists.
        Parameters:
        xr - The input stream with the XML.
        Throws:
        javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.
      • arrayKey

        public static java.lang.String arrayKey​(int i)
        Make the standard array key.
        Parameters:
        i - The array index.
        Returns:
        The array key.
      • getXMLTagName

        public abstract java.lang.String getXMLTagName()
        Get the serialization tag for this object.
        Returns:
        The tag.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object