Class CmdKit
java.lang.Object
com.iohao.net.framework.core.kit.CmdKit
Command ID manipulation utilities. Packs cmd and subCmd into a single int
using bit shifting (cmd occupies upper 16 bits, subCmd occupies lower 16 bits).
- Author:
- 渔民小镇
- date:
- 2021-12-20
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intgetCmd(int cmdMerge) Extract the cmd (upper 16 bits) from a merged command ID.static intgetSubCmd(int cmdMerge) Extract the subCmd (lower 16 bits) from a merged command ID.static intmerge(int cmd, int subCmd) Merge cmd and subCmd into a single int (cmd << 16 | subCmd).static StringtoSimpleString(CmdInfo cmdInfo) Format aCmdInfoas a simple"cmd-subCmd"string.static StringtoString(int cmdMerge) Format a merged command ID as a human-readable string[cmd:X-Y Z].
-
Constructor Details
-
CmdKit
public CmdKit()
-
-
Method Details
-
getCmd
public static int getCmd(int cmdMerge) Extract the cmd (upper 16 bits) from a merged command ID.- Parameters:
cmdMerge- the merged command ID- Returns:
- the cmd value
-
getSubCmd
public static int getSubCmd(int cmdMerge) Extract the subCmd (lower 16 bits) from a merged command ID.- Parameters:
cmdMerge- the merged command ID- Returns:
- the subCmd value
-
merge
public static int merge(int cmd, int subCmd) Merge cmd and subCmd into a single int (cmd << 16 | subCmd).- Parameters:
cmd- the command module ID (upper 16 bits)subCmd- the sub-command ID (lower 16 bits)- Returns:
- the merged command ID
-
toString
Format a merged command ID as a human-readable string[cmd:X-Y Z].- Parameters:
cmdMerge- the merged command ID- Returns:
- formatted string representation
-
toSimpleString
-