Package net.sf.freecol.common.networking
Class AttributeMessage
- java.lang.Object
-
- net.sf.freecol.common.networking.Message
-
- net.sf.freecol.common.networking.TrivialMessage
-
- net.sf.freecol.common.networking.AttributeMessage
-
- Direct Known Subclasses:
AbandonColonyMessage
,AskSkillMessage
,AssignTeacherMessage
,AssignTradeRouteMessage
,AttackMessage
,BuildColonyMessage
,CashInTreasureTrainMessage
,ChangeStateMessage
,ChangeWorkImprovementTypeMessage
,ChangeWorkTypeMessage
,ChatMessage
,ChooseFoundingFatherMessage
,ClaimLandMessage
,ClearSpecialityMessage
,CloseMessage
,ConnectionVerificationMessage
,DeclareIndependenceMessage
,DeclineMoundsMessage
,DeleteTradeRouteMessage
,DemandTributeMessage
,DisbandUnitMessage
,DisembarkMessage
,EmbarkMessage
,EmigrateUnitMessage
,EquipForRoleMessage
,FirstContactMessage
,FountainOfYouthMessage
,GameEndedMessage
,GameStateMessage
,InciteMessage
,IndianDemandMessage
,JoinColonyMessage
,LearnSkillMessage
,LoadGoodsMessage
,LogoutMessage
,MissionaryMessage
,MoveMessage
,MoveToMessage
,MultipleMessage
,NativeGiftMessage
,NewLandNameMessage
,NewRegionNameMessage
,NewTurnMessage
,ObjectMessage
,PartialMessage
,PayArrearsMessage
,PayForBuildingMessage
,PutOutsideColonyMessage
,ReadyMessage
,RearrangeColonyMessage
,RemoveMessage
,RenameMessage
,ScoutIndianSettlementMessage
,ScoutSpeakToChiefMessage
,ServerInfoMessage
,SetAIMessage
,SetAvailableMessage
,SetBuildQueueMessage
,SetColorMessage
,SetCurrentPlayerMessage
,SetCurrentStopMessage
,SetDeadMessage
,SetDestinationMessage
,SetNationMessage
,SetNationTypeMessage
,SetStanceMessage
,TrainUnitInEuropeMessage
,UnloadGoodsMessage
,VacantPlayersMessage
,WorkMessage
,WrapperMessage
public class AttributeMessage extends TrivialMessage
The basic message with optional attributes.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.freecol.common.networking.Message
Message.MessagePriority
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,java.lang.String>
attributes
The key,value attribute pairs.private boolean
mergeable
Whether this message is trivially mergeable.static java.lang.String
TAG
-
Fields inherited from class net.sf.freecol.common.networking.TrivialMessage
continueMessage, disconnectMessage, endTurnMessage, enterRevengeModeMessage, reconnectMessage, requestLaunchMessage, retireMessage, startGameMessage
-
Fields inherited from class net.sf.freecol.common.networking.Message
logger, messagePriorityComparator
-
-
Constructor Summary
Constructors Modifier Constructor Description AttributeMessage(java.lang.String type)
Create a newAttributeMessage
of a given type.AttributeMessage(java.lang.String type, java.lang.String... attributes)
Create a newAttributeMessage
of a given type and attributes.protected
AttributeMessage(java.lang.String type, java.util.Map<java.lang.String,java.lang.String> attributeMap)
Create a newAttributeMessage
of a given type and attributes.protected
AttributeMessage(java.lang.String type, FreeColXMLReader xr, java.lang.String... attributes)
Create a newAttributeMessage
from a stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canMerge()
Does this message consist only of mergeable attributes?Message.MessagePriority
getPriority()
Get the priority of this type of message.protected java.lang.String
getStringAttribute(java.lang.String key)
Get a string attribute value.protected java.util.Map<java.lang.String,java.lang.String>
getStringAttributeMap()
Get a map of all the attributes in this message.protected boolean
hasAttribute(java.lang.String key)
Checks if an attribute is present in this message.AttributeMessage
setMergeable(boolean mergeable)
Set the mergeable state of this message.protected void
setStringAttribute(java.lang.String key, java.lang.String value)
Sets an attribute in this message.-
Methods inherited from class net.sf.freecol.common.networking.TrivialMessage
aiHandler, appendChild, appendChildren, clientHandler, currentPlayerMessage, getChildCount, getChildren, getType, serverHandler, setChildren, setType
-
Methods inherited from class net.sf.freecol.common.networking.Message
clientGeneric, expected, getArrayAttributes, getBooleanAttribute, getChild, getChildren, getEnumAttribute, getIntegerAttribute, getPriorityLevel, igc, igc, invokeAndWait, invokeLater, isEmpty, isType, merge, pgc, pgc, pretty, read, setArrayAttributes, setArrayAttributes, setBooleanAttribute, setEnumAttribute, setIntegerAttribute, setStringAttributeMap, setStringAttributes, setStringAttributes, toString, toXML, writeAttributes, writeChildren
-
-
-
-
Field Detail
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
attributes
protected final java.util.Map<java.lang.String,java.lang.String> attributes
The key,value attribute pairs.
-
mergeable
private boolean mergeable
Whether this message is trivially mergeable.
-
-
Constructor Detail
-
AttributeMessage
public AttributeMessage(java.lang.String type)
Create a newAttributeMessage
of a given type.- Parameters:
type
- The message type.
-
AttributeMessage
public AttributeMessage(java.lang.String type, java.lang.String... attributes)
Create a newAttributeMessage
of a given type and attributes.- Parameters:
type
- The message type.attributes
- The key,value pairs.
-
AttributeMessage
protected AttributeMessage(java.lang.String type, java.util.Map<java.lang.String,java.lang.String> attributeMap)
Create a newAttributeMessage
of a given type and attributes.- Parameters:
type
- The message type.attributeMap
- A map of key,value pairs.
-
AttributeMessage
protected AttributeMessage(java.lang.String type, FreeColXMLReader xr, java.lang.String... attributes) throws javax.xml.stream.XMLStreamException
Create a newAttributeMessage
from a stream. Should only be called by direct subclasses of AttributeMessage as the entire message is consumed.- Parameters:
type
- The message type.xr
- TheFreeColXMLReader
to read from.attributes
- The attributes to read.- Throws:
javax.xml.stream.XMLStreamException
- if the stream is corrupt.
-
-
Method Detail
-
hasAttribute
protected boolean hasAttribute(java.lang.String key)
Checks if an attribute is present in this message.- Overrides:
hasAttribute
in classTrivialMessage
- Parameters:
key
- The attribute to look for.- Returns:
- True if the attribute is present.
-
getStringAttribute
protected java.lang.String getStringAttribute(java.lang.String key)
Get a string attribute value.- Overrides:
getStringAttribute
in classTrivialMessage
- Parameters:
key
- The attribute to look for.- Returns:
- The string value found, or null if the attribute was absent.
-
setStringAttribute
protected void setStringAttribute(java.lang.String key, java.lang.String value)
Sets an attribute in this message.- Overrides:
setStringAttribute
in classTrivialMessage
- Parameters:
key
- The attribute to set.value
- The new value of the attribute.
-
getStringAttributeMap
protected java.util.Map<java.lang.String,java.lang.String> getStringAttributeMap()
Get a map of all the attributes in this message.- Overrides:
getStringAttributeMap
in classTrivialMessage
- Returns:
- A
Map
of the attributes.
-
getPriority
public Message.MessagePriority getPriority()
Get the priority of this type of message.- Overrides:
getPriority
in classTrivialMessage
- Returns:
- The message priority.
-
canMerge
public boolean canMerge()
Does this message consist only of mergeable attributes?
-
setMergeable
public AttributeMessage setMergeable(boolean mergeable)
Set the mergeable state of this message.- Parameters:
mergeable
- The new mergeable state.- Returns:
- This message.
-
-