|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.common.model.FreeColObject
net.sf.freecol.common.model.StringTemplate
net.sf.freecol.common.model.ModelMessage
public class ModelMessage
Contains a message about a change in the model.
| Nested Class Summary | |
|---|---|
static class |
ModelMessage.MessageType
Constants describing the type of message. |
| Nested classes/interfaces inherited from class net.sf.freecol.common.model.StringTemplate |
|---|
StringTemplate.TemplateType |
| Field Summary | |
|---|---|
private boolean |
beenDisplayed
|
private java.lang.String |
displayId
|
private ModelMessage.MessageType |
messageType
|
private java.lang.String |
ownerId
|
private java.lang.String |
sourceId
|
| Fields inherited from class net.sf.freecol.common.model.FreeColObject |
|---|
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, INFINITY, logger, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG |
| Constructor Summary | |
|---|---|
ModelMessage()
|
|
ModelMessage(ModelMessage.MessageType messageType,
java.lang.String id,
FreeColGameObject source)
Creates a new ModelMessage. |
|
ModelMessage(ModelMessage.MessageType messageType,
java.lang.String id,
FreeColGameObject source,
FreeColObject display)
Creates a new ModelMessage. |
|
ModelMessage(java.lang.String id,
FreeColGameObject source)
Creates a new ModelMessage. |
|
ModelMessage(java.lang.String id,
FreeColGameObject source,
FreeColObject display)
Creates a new ModelMessage. |
|
| Method Summary | |
|---|---|
ModelMessage |
add(java.lang.String value)
Add a replacement value without a key to the ModelMessage. |
ModelMessage |
add(java.lang.String key,
java.lang.String value)
Add a new key and replacement to the ModelMessage. |
ModelMessage |
addAmount(java.lang.String key,
int amount)
Add a key and an integer value to replace it to this StringTemplate. |
ModelMessage |
addName(java.lang.String value)
Add a replacement value without a key to the ModelMessage. |
ModelMessage |
addName(java.lang.String key,
java.lang.String value)
Add a new key and replacement to the ModelMessage. |
ModelMessage |
addStringTemplate(java.lang.String key,
StringTemplate template)
Add a key and a StringTemplate to replace it to this StringTemplate. |
ModelMessage |
addStringTemplate(StringTemplate template)
Add a StringTemplate to this LABEL StringTemplate. |
void |
divert(FreeColGameObject newSource)
Switch the source (and display if it is the same) to a new object. |
boolean |
equals(java.lang.Object o)
Checks if this ModelMessage is equal to another
ModelMessage. |
private static FreeColObject |
getDefaultDisplay(ModelMessage.MessageType messageType,
FreeColGameObject source)
Returns the default display object for the given type. |
java.lang.String |
getDisplayId()
Gets the ID of the object to display. |
ModelMessage.MessageType |
getMessageType()
Gets the messageType of the message to display. |
java.lang.String |
getMessageTypeName()
|
java.lang.String |
getOwnerId()
Compatibility hack. |
java.lang.String |
getSourceId()
Gets the ID of the source of the message. |
static java.lang.String |
getXMLElementTagName()
Gets the tag name of the root element representing this object. |
boolean |
hasBeenDisplayed()
Checks if this ModelMessage has been displayed. |
int |
hashCode()
|
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. |
ModelMessage |
setDefaultId(java.lang.String newDefaultId)
Set the DefaultId value. |
void |
setDisplayId(java.lang.String displayId)
Sets the ID of the object to display. |
void |
setMessageType(ModelMessage.MessageType messageType)
Sets the type of the message. |
void |
setOwnerId(java.lang.String ownerId)
Compatibility hack. |
void |
setSourceId(java.lang.String sourceId)
Sets the ID of the source object. |
java.lang.String |
toString()
Debug helper. |
protected void |
toXMLImpl(javax.xml.stream.XMLStreamWriter out)
This method writes an XML-representation of this object to the given stream. |
protected void |
writeAttributes(javax.xml.stream.XMLStreamWriter out)
Write the attributes of this object to a stream. |
| Methods inherited from class net.sf.freecol.common.model.StringTemplate |
|---|
addAmount, addName, getDefaultId, getKeys, getReplacement, getReplacements, getTemplateType, key, label, name, readAttributes, readChildren, template, writeChildren |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private java.lang.String ownerId
private java.lang.String sourceId
private java.lang.String displayId
private ModelMessage.MessageType messageType
private boolean beenDisplayed
| Constructor Detail |
|---|
public ModelMessage()
public ModelMessage(java.lang.String id,
FreeColGameObject source,
FreeColObject display)
ModelMessage.
id - The ID of the message to display.source - The source of the message. This is what the
message should be associated with.display - The Object to display.
public ModelMessage(ModelMessage.MessageType messageType,
java.lang.String id,
FreeColGameObject source)
ModelMessage.
messageType - The type of this model message.id - The ID of the message to display.source - The source of the message. This is what the
message should be associated with.
public ModelMessage(java.lang.String id,
FreeColGameObject source)
ModelMessage.
id - The ID of the message to display.source - The source of the message. This is what the
message should be associated with.
public ModelMessage(ModelMessage.MessageType messageType,
java.lang.String id,
FreeColGameObject source,
FreeColObject display)
ModelMessage.
messageType - The type of this model message.id - The ID of the message to display.source - The source of the message. This is what the
message should be associated with.display - The object to display.| Method Detail |
|---|
public final ModelMessage setDefaultId(java.lang.String newDefaultId)
DefaultId value.
setDefaultId in class StringTemplatenewDefaultId - The new DefaultId value.
ModelMessage value
private static FreeColObject getDefaultDisplay(ModelMessage.MessageType messageType,
FreeColGameObject source)
messageType - The type to find the default display object for.source - The source object
public boolean hasBeenDisplayed()
ModelMessage has been displayed.
ModelMessage has been
displayed.setBeenDisplayed(boolean)public void setBeenDisplayed(boolean beenDisplayed)
beenDisplayed value of this
ModelMessage. This is used to avoid showing the
same message twice.
beenDisplayed - Should be set to true after the
message has been displayed.public java.lang.String getSourceId()
public void setSourceId(java.lang.String sourceId)
sourceId - A new source ID.public java.lang.String getDisplayId()
public void setDisplayId(java.lang.String displayId)
displayId - A new display ID.public ModelMessage.MessageType getMessageType()
public void setMessageType(ModelMessage.MessageType messageType)
messageType - The new messageType.public java.lang.String getMessageTypeName()
public void divert(FreeColGameObject newSource)
newSource - A new source.public java.lang.String getOwnerId()
public void setOwnerId(java.lang.String ownerId)
public ModelMessage add(java.lang.String key,
java.lang.String value)
add in class StringTemplatekey - a String valuevalue - a String value
ModelMessage valuepublic ModelMessage add(java.lang.String value)
add in class StringTemplatevalue - a String value
ModelMessage value
public ModelMessage addName(java.lang.String key,
java.lang.String value)
addName in class StringTemplatekey - a String valuevalue - a String value
ModelMessage valuepublic ModelMessage addName(java.lang.String value)
addName in class StringTemplatevalue - a String value
ModelMessage value
public ModelMessage addAmount(java.lang.String key,
int amount)
key - a String valueamount - an int value
ModelMessage value
public ModelMessage addStringTemplate(java.lang.String key,
StringTemplate template)
addStringTemplate in class StringTemplatekey - a String valuetemplate - a StringTemplate value
ModelMessage valuepublic ModelMessage addStringTemplate(StringTemplate template)
addStringTemplate in class StringTemplatetemplate - a StringTemplate value
ModelMessage valuepublic boolean equals(java.lang.Object o)
ModelMessage is equal to another
ModelMessage.
equals in class StringTemplateo - The Object to compare.
public int hashCode()
hashCode in class StringTemplate
protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
toXMLImpl in class StringTemplateout - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
protected void writeAttributes(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
writeAttributes in class StringTemplateout - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
public void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readFromXMLImpl in class FreeColObjectin - The input stream with the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.public java.lang.String toString()
toString in class StringTemplatepublic static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||