net.sf.freecol.common.model
Class ModelMessage

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.ModelMessage

public class ModelMessage
extends FreeColObject

Contains a message about a change in the model.


Nested Class Summary
static class ModelMessage.MessageType
          Constants describing the type of message.
 
Field Summary
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ID_ATTRIBUTE_TAG
 
Constructor Summary
ModelMessage()
           
ModelMessage(FreeColGameObject source, ModelMessage.MessageType type, FreeColObject display, java.lang.String id, java.lang.String... data)
          Creates a new ModelMessage.
ModelMessage(FreeColGameObject source, java.lang.String id, java.lang.String[][] data)
          Creates a new ModelMessage.
ModelMessage(FreeColGameObject source, java.lang.String id, java.lang.String[][] data, ModelMessage.MessageType type)
          Creates a new ModelMessage.
ModelMessage(FreeColGameObject source, java.lang.String id, java.lang.String[][] data, ModelMessage.MessageType type, FreeColObject display)
          Deprecated. 
 
Method Summary
 boolean equals(java.lang.Object o)
          Checks if this ModelMessage is equal to another ModelMessage.
 java.lang.String[] getData()
          Returns the data to be displayed in the message.
 FreeColObject getDisplay()
          Gets the Object to display.
 Player getOwner()
          Returns the owner of this message.
 FreeColGameObject getSource()
          Gets the source of the message.
 ModelMessage.MessageType getType()
          Gets the type of the message to display.
 java.lang.String getTypeName()
           
static java.lang.String getXMLElementTagName()
           
 boolean hasBeenDisplayed()
          Checks if this ModelMessage has been displayed.
 int hashCode()
           
 void readFromXML(javax.xml.stream.XMLStreamReader in, Game game)
          Initialize this object from an XML-representation of this object.
 void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
          Initialize this object from an XML-representation of this object.
 void setBeenDisplayed(boolean beenDisplayed)
          Sets the beenDisplayed value of this ModelMessage.
 void setDisplay(FreeColGameObject newDisplay)
          Sets the Object to display.
 void setOwner(Player newOwner)
          Set the owner of this message.
 void setSource(FreeColGameObject newSource)
          Sets the source of the message.
 java.lang.String toString()
           
 void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          This method writes an XML-representation of this object to the given stream.
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, hasAbility, hasAttribute, hasListeners, readFromXML, readFromXMLElement, removePropertyChangeListener, removePropertyChangeListener, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, writeAttribute, writeFreeColGameObject
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ModelMessage

public ModelMessage()

ModelMessage

@Deprecated
public ModelMessage(FreeColGameObject source,
                               java.lang.String id,
                               java.lang.String[][] data,
                               ModelMessage.MessageType type,
                               FreeColObject display)
Deprecated. 

Creates a new ModelMessage.

Parameters:
source - The source of the message. This is what the message should be associated with. In addition, the owner of the source is the player getting the message.
id - The ID of the message to display.
data - Contains data to be displayed in the message or null.
type - The type of this model message.
display - The Object to display.

ModelMessage

public ModelMessage(FreeColGameObject source,
                    ModelMessage.MessageType type,
                    FreeColObject display,
                    java.lang.String id,
                    java.lang.String... data)
Creates a new ModelMessage.

Parameters:
source - The source of the message. This is what the message should be associated with. In addition, the owner of the source is the player getting the message.
type - The type of this model message.
display - The Object to display.
id - The ID of the message to display.
data - Contains data to be displayed in the message or null.

ModelMessage

public ModelMessage(FreeColGameObject source,
                    java.lang.String id,
                    java.lang.String[][] data,
                    ModelMessage.MessageType type)
Creates a new ModelMessage.

Parameters:
source - The source of the message. This is what the message should be associated with. In addition, the owner of the source is the player getting the message.
id - The ID of the message to display.
data - Contains data to be displayed in the message or null.
type - The type of this model message.

ModelMessage

public ModelMessage(FreeColGameObject source,
                    java.lang.String id,
                    java.lang.String[][] data)
Creates a new ModelMessage.

Parameters:
source - The source of the message. This is what the message should be associated with. In addition, the owner of the source is the player getting the message.
id - The ID of the message to display.
data - Contains data to be displayed in the message or null.
Method Detail

hasBeenDisplayed

public boolean hasBeenDisplayed()
Checks if this ModelMessage has been displayed.

Returns:
true if this ModelMessage has been displayed.
See Also:
setBeenDisplayed(boolean)

setBeenDisplayed

public void setBeenDisplayed(boolean beenDisplayed)
Sets the beenDisplayed value of this ModelMessage. This is used to avoid showing the same message twice.

Parameters:
beenDisplayed - Should be set to true after the message has been displayed.

getSource

public FreeColGameObject getSource()
Gets the source of the message. This is what the message should be associated with. In addition, the owner of the source is the player getting the message.

Returns:
The source of the message.
See Also:
getOwner()

setSource

public void setSource(FreeColGameObject newSource)
Sets the source of the message.

Parameters:
newSource - a new source for this message

getData

public java.lang.String[] getData()
Returns the data to be displayed in the message.

Returns:
The data as a String[] or null if no data applies.

getType

public ModelMessage.MessageType getType()
Gets the type of the message to display.

Returns:
The type.

getTypeName

public java.lang.String getTypeName()

getDisplay

public FreeColObject getDisplay()
Gets the Object to display.

Returns:
The Object to display.

setDisplay

public void setDisplay(FreeColGameObject newDisplay)
Sets the Object to display.

Parameters:
newDisplay - the new object to display

getOwner

public Player getOwner()
Returns the owner of this message. The owner of this method is the owner of the source.

Returns:
The owner of the message. This is the Player who should receive the message.

setOwner

public void setOwner(Player newOwner)
Set the owner of this message.

Parameters:
newOwner - A Player to own this message.

equals

public boolean equals(java.lang.Object o)
Checks if this ModelMessage is equal to another ModelMessage.

Overrides:
equals in class java.lang.Object
Returns:
true if the sources, message IDs and data are equal.

hashCode

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

toString

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

getXMLElementTagName

public static java.lang.String getXMLElementTagName()

toXMLImpl

public void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
               throws javax.xml.stream.XMLStreamException
Description copied from class: FreeColObject
This method writes an XML-representation of this object to the given stream.

Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

readFromXMLImpl

public void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
                     throws javax.xml.stream.XMLStreamException
Initialize this object from an XML-representation of this object.

Parameters:
in - The input stream with the XML.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

readFromXML

public void readFromXML(javax.xml.stream.XMLStreamReader in,
                        Game game)
                 throws javax.xml.stream.XMLStreamException
Initialize this object from an XML-representation of this object.

Parameters:
in - The input stream with the XML.
game - a Game value
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.