soc.message
Class SOCMessage

java.lang.Object
  extended by soc.message.SOCMessage
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
SOCAcceptOffer, SOCAdminPing, SOCAdminReset, SOCAuthRequest, SOCBankTrade, SOCBCastTextMsg, SOCBoardLayout, SOCBoardLayout2, SOCBuildRequest, SOCBuyCardRequest, SOCCancelBuildRequest, SOCChangeFace, SOCChannels, SOCChoosePlayer, SOCChoosePlayerRequest, SOCClearOffer, SOCClearTradeMsg, SOCCreateAccount, SOCDebugFreePlace, SOCDeleteChannel, SOCDeleteGame, SOCDevCardAction, SOCDevCardCount, SOCDiscard, SOCDiscardRequest, SOCDiscoveryPick, SOCEndTurn, SOCFirstPlayer, SOCGameMembers, SOCGameOptionGetDefaults, SOCGameOptionGetInfos, SOCGames, SOCGameServerText, SOCGameState, SOCGameStats, SOCGameTextMsg, SOCImARobot, SOCInventoryItemAction, SOCJoin, SOCJoinAuth, SOCJoinGameAuth, SOCLargestArmy, SOCLastSettlement, SOCLeave, SOCLeaveAll, SOCLeaveGame, SOCLegalEdges, SOCLongestRoad, SOCMakeOffer, SOCMembers, SOCMessageMulti, SOCMessageTemplate0, SOCMessageTemplate1i, SOCMessageTemplate1s, SOCMessageTemplate2i, SOCMessageTemplate2s, SOCMessageTemplate3i, SOCMessageTemplate3s, SOCMessageTemplate4i, SOCMessageTemplateJoinGame, SOCMonopolyPick, SOCMoveRobber, SOCNewChannel, SOCNewGame, SOCPickResources, SOCPlayDevCardRequest, SOCPlayerElement, SOCPotentialSettlements, SOCPutPiece, SOCRejectConnection, SOCRejectOffer, SOCResourceCount, SOCRobotDismiss, SOCRobotJoinGameRequest, SOCRollDice, SOCRollDicePrompt, SOCRollDiceRequest, SOCServerPing, SOCSetPlayedDevCard, SOCSetSeatLock, SOCSetSpecialItem, SOCSetupDone, SOCSitDown, SOCStartGame, SOCStatusMessage, SOCSVPTextMessage, SOCTextMsg, SOCTimingPing, SOCTurn, SOCUpdateRobotParams, SOCVersion

public abstract class SOCMessage
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Messages used for game data, events, and chatting on a channel.

No objects, only strings and integers, are to be sent over the network between servers and clients! Your game's code must guarantee that no string sent contains a separator character (sep_char or sep2_char). To help with this, use isSingleLineAndSafe(String).

Text announcements (SOCGameServerText or SOCGameTextMsg) are often sent after data messages.

The message data is sent over the network as type ID + data strings built by each SOCMessage subclass's toCmd() method.

On the remote end, it's reconstructed to a new instance of the appropriate SOCMessage subclass, by the subclass' required method static SOCMessageSubclass parseDataStr(String). parseDataStr is called from toMsg(String) in this class.

The client receives messages in SOCPlayerClient.MessageTreater.treat(SOCMessage, boolean). The server receives messages in SOCServer.processCommand(String, StringConnection).

To create and add a new message type:

Backwards compatibility: Unknown message types are ignored by client and by server. Technically they are returned as null from toMsg(String) if the local copy (the old version's code) of SOCMessage doesn't know that message type.

Format: For most messages, at most one sep token per message, which separates the messagetype number from the message data; multiple SEP2 are allowed after SEP. For multi-messages, multiple SEP are allowed; see SOCMessageMulti.

Author:
Robert S Thomas
See Also:
Serialized Form

Field Summary
static int ACCEPTOFFER
           
static int ADMINPING
           
static int ADMINRESET
           
static int AUTHREQUEST
          Authentication request, to do so without creating or joining a game or channel; see SOCAuthRequest.
static int BANKTRADE
           
static int BCASTTEXTMSG
           
static int BOARDLAYOUT
           
static int BOARDLAYOUT2
           
static int BOARDSPECIALEDGE
          Make an edge on the board special or no longer special (SOCBoardSpecialEdge).
static int BUILDREQUEST
           
static int BUYCARDREQUEST
           
static int CANCELBUILDREQUEST
           
static int CHANGEFACE
           
static int CHANNELS
           
static int CHOOSEPLAYER
           
static int CHOOSEPLAYERREQUEST
           
static int CLEAROFFER
           
static int CLEARTRADEMSG
           
static int CREATEACCOUNT
           
static int DEBUGFREEPLACE
           
static int DELETECHANNEL
           
static int DELETEGAME
           
static int DEVCARDACTION
          SOCDevCardAction message; before v2.0.00, this type was DEVCARD (class name SOCDevCard).
static int DEVCARDCOUNT
           
static int DICERESULT
           
static int DICERESULTRESOURCES
          SOCDiceResultResources - All resources gained by players from a dice roll.
static int DISCARD
           
static int DISCARDREQUEST
           
static int DISCOVERYPICK
           
static int ENDTURN
           
static int FIRSTPLAYER
           
static java.lang.String GAME_NONE
          "Not for any game" marker, used when any of the SOCMessageTemplate* message types (which all implement SOCMessageForGame) are used for convenience for non-game messages such as SOCLocalizedStrings.
static int GAMEMEMBERS
           
static int GAMEOPTIONGETDEFAULTS
           
static int GAMEOPTIONGETINFOS
           
static int GAMEOPTIONINFO
           
static int GAMES
           
static int GAMESERVERTEXT
          SOCGameServerText - Game text announcements from the server.
static int GAMESTATE
           
static int GAMESTATS
           
static int GAMESWITHOPTIONS
           
static int GAMETEXTMSG
          SOCGameTextMsg - Game text from players.
static int IMAROBOT
           
static int INVENTORYITEMACTION
          SOCInventoryItemAction message: Add or remove a SOCInventoryItem (excluding SOCDevCards) from a player's inventory.
static int JOIN
           
static int JOINAUTH
           
static int JOINGAME
           
static int JOINGAMEAUTH
           
static int LARGESTARMY
           
static int LASTSETTLEMENT
           
static int LEAVE
           
static int LEAVEALL
           
static int LEAVEGAME
           
static int LEGALEDGES
          Legal road or ship edges for the large sea board.
static int LOCALIZEDSTRINGS
          SOCLocalizedStrings - Localized i18n strings for items such as game options or scenarios.
static int LONGESTROAD
           
static int MAKEOFFER
           
static int MEMBERS
           
protected  int messageType
          An ID identifying the type of message
static int MONOPOLYPICK
           
static int MOVEPIECE
          Move a piece to another location; server reply to MOVEPIECEREQUEST.
static int MOVEPIECEREQUEST
          Ask server to move a piece to another location.
static int MOVEROBBER
           
static int NEWCHANNEL
           
static int NEWGAME
           
static int NEWGAMEWITHOPTIONS
           
static int NEWGAMEWITHOPTIONSREQUEST
           
static int NULLMESSAGE
           
static int PICKRESOURCES
          Client reply to PICKRESOURCESREQUEST.
static int PICKRESOURCESREQUEST
          Ask client to pick this many resources, when they have a settlement or city next to a gold hex.
static int PIECEVALUE
          Update the value(s) of a piece on the board.
static int PLAYDEVCARDREQUEST
           
static int PLAYERELEMENT
           
static int PLAYERELEMENTS
           
static int PLAYERSTATS
           
static int POTENTIALSETTLEMENTS
           
static int PUTPIECE
           
static int REJECTCONNECTION
           
static int REJECTOFFER
           
static int REMOVEPIECE
          SOCRemovePiece - Remove a piece from the board; currently used only with ships.
static int RESETBOARDAUTH
           
static int RESETBOARDREJECT
           
static int RESETBOARDREQUEST
           
static int RESETBOARDVOTE
           
static int RESETBOARDVOTEREQUEST
           
static int RESOURCECOUNT
           
static int REVEALFOGHEX
          Reveal a hidden hex on the board; server to all clients in game.
static int ROBOTDISMISS
           
static int ROBOTJOINGAMEREQUEST
           
static int ROLLDICE
           
static int ROLLDICEPROMPT
           
static int ROLLDICEREQUEST
           
static int SCENARIOINFO
          SOCScenarioInfo - Client's request about available SOCScenarios, or server's reply about a single scenario.
static java.lang.String sep
          Token separators.
static char sep_char
          main separator token sep, as character.
static java.lang.String sep2
          secondary separator token SEP2, as string.
static char sep2_char
          secondary separator token sep2, as character.
private static long serialVersionUID
           
static int SERVERPING
           
static int SETPLAYEDDEVCARD
           
static int SETSEATLOCK
           
static int SETSPECIALITEM
          SOCSetSpecialItem - Special Item requests and change announcements.
static int SETTURN
           
static int SETUPDONE
           
static int SIMPLEACTION
          SOCSimpleAction - Generic message type for simple actions for players.
static int SIMPLEREQUEST
          SOCSimpleRequest - Generic message type for simple requests by players.
static int SITDOWN
           
static int STARTGAME
           
static int STATUSMESSAGE
           
static int SVPTEXTMSG
          Text that a player has been awarded Special Victory Point(s).
static int TEXTMSG
           
static int TIMINGPING
           
static int TURN
           
static int UPDATEROBOTPARAMS
           
static int VERSION
           
 
Constructor Summary
SOCMessage()
           
 
Method Summary
protected static void arrayIntoStringBuf(int[] ia, java.lang.StringBuffer sb, boolean useHex)
          For use in toString: Append int array contents to stringbuffer, formatted as "{ 1 2 3 4 5 }".
protected static void enumIntoStringBuf(java.util.Enumeration<java.lang.String> se, java.lang.StringBuffer sb)
          For use in toString: Append string enum contents to stringbuffer, formatted as "a,b,c,d,e".
 java.lang.String getClassNameShort()
          Utility, get the short simple name of the class: SOCResetBoardVote, not soc.message.SOCResetBoardVote
 int getMaximumVersion()
          To identify obsolete message types, give the maximum version where this type is used.
 int getMinimumVersion()
          To identify new message types, give the minimum version where this type is used.
 int getType()
           
static boolean isSingleLineAndSafe(java.lang.String s)
          Test whether a string is non-empty and its characters are all 'safe' as a single-line string: No newlines or control characters, no line separators or paragraph separators.
static boolean isSingleLineAndSafe(java.lang.String s, boolean allowSepChars)
          Variant of isSingleLineAndSafe(String) that can optionally allow sep_char or sep2_char.
abstract  java.lang.String toCmd()
          Converts the contents of this message into a String that can be transferred by a client or server.
static SOCMessage toMsg(java.lang.String s)
          Convert a string into a SOCMessage.
abstract  java.lang.String toString()
          Simple human-readable representation, used for debug purposes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

AUTHREQUEST

public static final int AUTHREQUEST
Authentication request, to do so without creating or joining a game or channel; see SOCAuthRequest.

Since:
1.1.19
See Also:
Constant Field Values

NULLMESSAGE

public static final int NULLMESSAGE
See Also:
Constant Field Values

NEWCHANNEL

public static final int NEWCHANNEL
See Also:
Constant Field Values

MEMBERS

public static final int MEMBERS
See Also:
Constant Field Values

CHANNELS

public static final int CHANNELS
See Also:
Constant Field Values

JOIN

public static final int JOIN
See Also:
Constant Field Values

TEXTMSG

public static final int TEXTMSG
See Also:
Constant Field Values

LEAVE

public static final int LEAVE
See Also:
Constant Field Values

DELETECHANNEL

public static final int DELETECHANNEL
See Also:
Constant Field Values

LEAVEALL

public static final int LEAVEALL
See Also:
Constant Field Values

PUTPIECE

public static final int PUTPIECE
See Also:
Constant Field Values

GAMETEXTMSG

public static final int GAMETEXTMSG
SOCGameTextMsg - Game text from players.

Before v2.0.00, messages from the server also used this type. In 2.0.00 and later, text from the server is GAMESERVERTEXT instead.

See Also:
Constant Field Values

LEAVEGAME

public static final int LEAVEGAME
See Also:
Constant Field Values

SITDOWN

public static final int SITDOWN
See Also:
Constant Field Values

JOINGAME

public static final int JOINGAME
See Also:
Constant Field Values

BOARDLAYOUT

public static final int BOARDLAYOUT
See Also:
Constant Field Values

DELETEGAME

public static final int DELETEGAME
See Also:
Constant Field Values

NEWGAME

public static final int NEWGAME
See Also:
Constant Field Values

GAMEMEMBERS

public static final int GAMEMEMBERS
See Also:
Constant Field Values

STARTGAME

public static final int STARTGAME
See Also:
Constant Field Values

GAMES

public static final int GAMES
See Also:
Constant Field Values

JOINAUTH

public static final int JOINAUTH
See Also:
Constant Field Values

JOINGAMEAUTH

public static final int JOINGAMEAUTH
See Also:
Constant Field Values

IMAROBOT

public static final int IMAROBOT
See Also:
Constant Field Values

ROBOTJOINGAMEREQUEST

public static final int ROBOTJOINGAMEREQUEST
See Also:
Constant Field Values

PLAYERELEMENT

public static final int PLAYERELEMENT
See Also:
Constant Field Values

GAMESTATE

public static final int GAMESTATE
See Also:
Constant Field Values

TURN

public static final int TURN
See Also:
Constant Field Values

SETUPDONE

public static final int SETUPDONE
See Also:
Constant Field Values

DICERESULT

public static final int DICERESULT
See Also:
Constant Field Values

DISCARDREQUEST

public static final int DISCARDREQUEST
See Also:
Constant Field Values

ROLLDICEREQUEST

public static final int ROLLDICEREQUEST
See Also:
Constant Field Values

ROLLDICE

public static final int ROLLDICE
See Also:
Constant Field Values

ENDTURN

public static final int ENDTURN
See Also:
Constant Field Values

DISCARD

public static final int DISCARD
See Also:
Constant Field Values

MOVEROBBER

public static final int MOVEROBBER
See Also:
Constant Field Values

CHOOSEPLAYER

public static final int CHOOSEPLAYER
See Also:
Constant Field Values

CHOOSEPLAYERREQUEST

public static final int CHOOSEPLAYERREQUEST
See Also:
Constant Field Values

REJECTOFFER

public static final int REJECTOFFER
See Also:
Constant Field Values

CLEAROFFER

public static final int CLEAROFFER
See Also:
Constant Field Values

ACCEPTOFFER

public static final int ACCEPTOFFER
See Also:
Constant Field Values

BANKTRADE

public static final int BANKTRADE
See Also:
Constant Field Values

MAKEOFFER

public static final int MAKEOFFER
See Also:
Constant Field Values

CLEARTRADEMSG

public static final int CLEARTRADEMSG
See Also:
Constant Field Values

BUILDREQUEST

public static final int BUILDREQUEST
See Also:
Constant Field Values

CANCELBUILDREQUEST

public static final int CANCELBUILDREQUEST
See Also:
Constant Field Values

BUYCARDREQUEST

public static final int BUYCARDREQUEST
See Also:
Constant Field Values

DEVCARDACTION

public static final int DEVCARDACTION
SOCDevCardAction message; before v2.0.00, this type was DEVCARD (class name SOCDevCard).

See Also:
Constant Field Values

DEVCARDCOUNT

public static final int DEVCARDCOUNT
See Also:
Constant Field Values

SETPLAYEDDEVCARD

public static final int SETPLAYEDDEVCARD
See Also:
Constant Field Values

PLAYDEVCARDREQUEST

public static final int PLAYDEVCARDREQUEST
See Also:
Constant Field Values

DISCOVERYPICK

public static final int DISCOVERYPICK
See Also:
Constant Field Values

MONOPOLYPICK

public static final int MONOPOLYPICK
See Also:
Constant Field Values

FIRSTPLAYER

public static final int FIRSTPLAYER
See Also:
Constant Field Values

SETTURN

public static final int SETTURN
See Also:
Constant Field Values

ROBOTDISMISS

public static final int ROBOTDISMISS
See Also:
Constant Field Values

POTENTIALSETTLEMENTS

public static final int POTENTIALSETTLEMENTS
See Also:
Constant Field Values

CHANGEFACE

public static final int CHANGEFACE
See Also:
Constant Field Values

REJECTCONNECTION

public static final int REJECTCONNECTION
See Also:
Constant Field Values

LASTSETTLEMENT

public static final int LASTSETTLEMENT
See Also:
Constant Field Values

GAMESTATS

public static final int GAMESTATS
See Also:
Constant Field Values

BCASTTEXTMSG

public static final int BCASTTEXTMSG
See Also:
Constant Field Values

RESOURCECOUNT

public static final int RESOURCECOUNT
See Also:
Constant Field Values

ADMINPING

public static final int ADMINPING
See Also:
Constant Field Values

ADMINRESET

public static final int ADMINRESET
See Also:
Constant Field Values

LONGESTROAD

public static final int LONGESTROAD
See Also:
Constant Field Values

LARGESTARMY

public static final int LARGESTARMY
See Also:
Constant Field Values

SETSEATLOCK

public static final int SETSEATLOCK
See Also:
Constant Field Values

STATUSMESSAGE

public static final int STATUSMESSAGE
See Also:
Constant Field Values

CREATEACCOUNT

public static final int CREATEACCOUNT
See Also:
Constant Field Values

UPDATEROBOTPARAMS

public static final int UPDATEROBOTPARAMS
See Also:
Constant Field Values

ROLLDICEPROMPT

public static final int ROLLDICEPROMPT
See Also:
Constant Field Values

RESETBOARDREQUEST

public static final int RESETBOARDREQUEST
See Also:
Constant Field Values

RESETBOARDAUTH

public static final int RESETBOARDAUTH
See Also:
Constant Field Values

RESETBOARDVOTEREQUEST

public static final int RESETBOARDVOTEREQUEST
See Also:
Constant Field Values

RESETBOARDVOTE

public static final int RESETBOARDVOTE
See Also:
Constant Field Values

RESETBOARDREJECT

public static final int RESETBOARDREJECT
See Also:
Constant Field Values

NEWGAMEWITHOPTIONSREQUEST

public static final int NEWGAMEWITHOPTIONSREQUEST
Since:
1.1.07
See Also:
Constant Field Values

NEWGAMEWITHOPTIONS

public static final int NEWGAMEWITHOPTIONS
Since:
1.1.07
See Also:
Constant Field Values

GAMEOPTIONGETDEFAULTS

public static final int GAMEOPTIONGETDEFAULTS
Since:
1.1.07
See Also:
Constant Field Values

GAMEOPTIONGETINFOS

public static final int GAMEOPTIONGETINFOS
Since:
1.1.07
See Also:
Constant Field Values

GAMEOPTIONINFO

public static final int GAMEOPTIONINFO
Since:
1.1.07
See Also:
Constant Field Values

GAMESWITHOPTIONS

public static final int GAMESWITHOPTIONS
Since:
1.1.07
See Also:
Constant Field Values

BOARDLAYOUT2

public static final int BOARDLAYOUT2
Since:
1.1.08
See Also:
Constant Field Values

PLAYERSTATS

public static final int PLAYERSTATS
Since:
1.1.09
See Also:
Constant Field Values

PLAYERELEMENTS

public static final int PLAYERELEMENTS
Since:
1.1.09
See Also:
Constant Field Values

DEBUGFREEPLACE

public static final int DEBUGFREEPLACE
Since:
1.1.12
See Also:
Constant Field Values

TIMINGPING

public static final int TIMINGPING
Since:
1.1.13
See Also:
Constant Field Values

SIMPLEREQUEST

public static final int SIMPLEREQUEST
SOCSimpleRequest - Generic message type for simple requests by players.

Since:
1.1.18
See Also:
Constant Field Values

SIMPLEACTION

public static final int SIMPLEACTION
SOCSimpleAction - Generic message type for simple actions for players.

Since:
1.1.19
See Also:
Constant Field Values

GAMESERVERTEXT

public static final int GAMESERVERTEXT
SOCGameServerText - Game text announcements from the server.

Before v2.0.00, server text announcements were sent as GAMETEXTMSG just like player chat messages.

Since:
2.0.00
See Also:
Constant Field Values

DICERESULTRESOURCES

public static final int DICERESULTRESOURCES
SOCDiceResultResources - All resources gained by players from a dice roll.

Before v2.0.00, these were sent as SOCPlayerElement(GAIN) and GAMETEXTMSG.

Since:
2.0.00
See Also:
Constant Field Values

MOVEPIECEREQUEST

public static final int MOVEPIECEREQUEST
Ask server to move a piece to another location. Server replies with MOVEPIECE if okay.

Since:
2.0.00
See Also:
Constant Field Values

MOVEPIECE

public static final int MOVEPIECE
Move a piece to another location; server reply to MOVEPIECEREQUEST.

Since:
2.0.00
See Also:
Constant Field Values

REMOVEPIECE

public static final int REMOVEPIECE
SOCRemovePiece - Remove a piece from the board; currently used only with ships.

Since:
2.0.00
See Also:
Constant Field Values

PICKRESOURCESREQUEST

public static final int PICKRESOURCESREQUEST
Ask client to pick this many resources, when they have a settlement or city next to a gold hex. Client replies with PICKRESOURCES.

Since:
2.0.00
See Also:
Constant Field Values

PICKRESOURCES

public static final int PICKRESOURCES
Client reply to PICKRESOURCESREQUEST. Has picked these resource types/counts.

Since:
2.0.00
See Also:
Constant Field Values

REVEALFOGHEX

public static final int REVEALFOGHEX
Reveal a hidden hex on the board; server to all clients in game.

Since:
2.0.00
See Also:
Constant Field Values

PIECEVALUE

public static final int PIECEVALUE
Update the value(s) of a piece on the board.

Since:
2.0.00
See Also:
Constant Field Values

LEGALEDGES

public static final int LEGALEDGES
Legal road or ship edges for the large sea board.

Since:
2.0.00
See Also:
Constant Field Values

SVPTEXTMSG

public static final int SVPTEXTMSG
Text that a player has been awarded Special Victory Point(s). The server will also send a SOCPlayerElement with the SVP total.

Since:
2.0.00
See Also:
Constant Field Values

BOARDSPECIALEDGE

public static final int BOARDSPECIALEDGE
Make an edge on the board special or no longer special (SOCBoardSpecialEdge). Used in some game scenarios.

Since:
2.0.00
See Also:
Constant Field Values

INVENTORYITEMACTION

public static final int INVENTORYITEMACTION
SOCInventoryItemAction message: Add or remove a SOCInventoryItem (excluding SOCDevCards) from a player's inventory. Used in some game scenarios.

Since:
2.0.00
See Also:
DEVCARDACTION, Constant Field Values

SETSPECIALITEM

public static final int SETSPECIALITEM
SOCSetSpecialItem - Special Item requests and change announcements. SOCSpecialItems are used in some game scenarios.

Since:
2.0.00
See Also:
Constant Field Values

LOCALIZEDSTRINGS

public static final int LOCALIZEDSTRINGS
SOCLocalizedStrings - Localized i18n strings for items such as game options or scenarios.

Since:
2.0.00
See Also:
Constant Field Values

SCENARIOINFO

public static final int SCENARIOINFO
SOCScenarioInfo - Client's request about available SOCScenarios, or server's reply about a single scenario.

Since:
2.0.00
See Also:
Constant Field Values

VERSION

public static final int VERSION
Since:
1.1.00
See Also:
Constant Field Values

SERVERPING

public static final int SERVERPING
See Also:
Constant Field Values

sep

public static final java.lang.String sep
Token separators. At most one SEP per message; multiple SEP2 are allowed after SEP. For multi-messages, multiple SEP are allowed; see SOCMessageMulti. SEP is "|".

See Also:
Constant Field Values

sep2

public static final java.lang.String sep2
secondary separator token SEP2, as string. SEP2 is ",".

See Also:
Constant Field Values

sep_char

public static final char sep_char
main separator token sep, as character. SEP is '|'.

See Also:
Constant Field Values

sep2_char

public static final char sep2_char
secondary separator token sep2, as character. SEP2 is ','.

See Also:
Constant Field Values

GAME_NONE

public static final java.lang.String GAME_NONE
"Not for any game" marker, used when any of the SOCMessageTemplate* message types (which all implement SOCMessageForGame) are used for convenience for non-game messages such as SOCLocalizedStrings.

No actual game, option, or scenario will ever have the same name as this marker, because the marker fails isSingleLineAndSafe(String, false) by including a control character.

Since:
2.0.00
See Also:
Constant Field Values

messageType

protected int messageType
An ID identifying the type of message

Constructor Detail

SOCMessage

public SOCMessage()
Method Detail

getType

public int getType()
Returns:
the message type

getMinimumVersion

public int getMinimumVersion()
To identify new message types, give the minimum version where this type is used. Default of 1000 (version 1.0.00) unless overridden.

When overriding, write the entire method on a single line for easier visibility of the version when searching the source code.

Returns:
Version number, as in 1006 for JSettlers 1.0.06.

getMaximumVersion

public int getMaximumVersion()
To identify obsolete message types, give the maximum version where this type is used. Default (for active messages) returns Integer.MAX_VALUE.

Returns:
Version number, as in 1006 for JSettlers 1.0.06, or Integer.MAX_VALUE.

toCmd

public abstract java.lang.String toCmd()
Converts the contents of this message into a String that can be transferred by a client or server. Your class' required method static SOCMessageSubclass parseDataStr(String) must be able to turn this String back into an instance of the message class.

For most message types, at most one sep token is allowed, separating the type ID from the rest of the parameters. For multi-messages (@link SOCMessageMulti}, multiple sep tokens are allowed. Multi-messages are parsed with: static SOCMessageSubclass parseDataStr(String[])


toString

public abstract java.lang.String toString()
Simple human-readable representation, used for debug purposes.

Overrides:
toString in class java.lang.Object

arrayIntoStringBuf

protected static void arrayIntoStringBuf(int[] ia,
                                         java.lang.StringBuffer sb,
                                         boolean useHex)
                                  throws java.lang.NullPointerException
For use in toString: Append int array contents to stringbuffer, formatted as "{ 1 2 3 4 5 }".

Parameters:
ia - int array to append. 0 length is allowed, null is not.
sb - StringBuffer to which ia will be appended, as "{ 1 2 3 4 5 }"
useHex - If true, append ia as hexidecimal strings. Uses Integer.toHexString(int) after checking the sign bit. (Added in 2.0.00)
Throws:
java.lang.NullPointerException - if ia or sb is null
Since:
1.1.09

enumIntoStringBuf

protected static void enumIntoStringBuf(java.util.Enumeration<java.lang.String> se,
                                        java.lang.StringBuffer sb)
                                 throws java.lang.ClassCastException,
                                        java.lang.NullPointerException
For use in toString: Append string enum contents to stringbuffer, formatted as "a,b,c,d,e".

Parameters:
se - Enum of String to append. 0 length is allowed, null is not allowed.
sb - StringBuffer to which se will be appended, as "a,b,c,d,e"
Throws:
java.lang.ClassCastException - if se.nextElement() returns non-String
java.lang.NullPointerException - if se or sb is null
Since:
1.1.09

getClassNameShort

public java.lang.String getClassNameShort()
Utility, get the short simple name of the class: SOCResetBoardVote, not soc.message.SOCResetBoardVote

Returns:
Short name of class, without package name
Since:
1.1.01

isSingleLineAndSafe

public static final boolean isSingleLineAndSafe(java.lang.String s)
Test whether a string is non-empty and its characters are all 'safe' as a single-line string: No newlines or control characters, no line separators or paragraph separators. Whitespace character type Character.SPACE_SEPARATOR is OK. Must not contain sep_char or sep2_char.

Parameters:
s - string to test; if null, returns false.
Returns:
true if all characters are OK, false otherwise. Null string or 0-length string returns false.
Since:
1.1.07
See Also:
isSingleLineAndSafe(String, boolean)

isSingleLineAndSafe

public static final boolean isSingleLineAndSafe(java.lang.String s,
                                                boolean allowSepChars)
Variant of isSingleLineAndSafe(String) that can optionally allow sep_char or sep2_char. See that method for other conditions checked here.

Parameters:
s - string to test; if null, returns false.
allowSepChars - If true, string can contain sep_char or sep2_char
Returns:
true if all characters are OK, false otherwise. Null string or 0-length string returns false.
Since:
2.0.00

toMsg

public static SOCMessage toMsg(java.lang.String s)
Convert a string into a SOCMessage. The string is in the form of "id SEP messagename {SEP2 messagedata}*". If the message type id is unknown, this is printed to System.err.

Parameters:
s - String to convert
Returns:
converted String to a SOCMessage, or null if the string is garbled, or is an unknown command id