Class CmdKit

java.lang.Object
com.iohao.net.framework.core.kit.CmdKit

public class CmdKit extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    getCmd(int cmdMerge)
    Extract the cmd (upper 16 bits) from a merged command ID.
    static int
    getSubCmd(int cmdMerge)
    Extract the subCmd (lower 16 bits) from a merged command ID.
    static int
    merge(int cmd, int subCmd)
    Merge cmd and subCmd into a single int (cmd << 16 | subCmd).
    static String
    Format a CmdInfo as a simple "cmd-subCmd" string.
    static String
    toString(int cmdMerge)
    Format a merged command ID as a human-readable string [cmd:X-Y Z].

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static String toString(int cmdMerge)
      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

      public static String toSimpleString(CmdInfo cmdInfo)
      Format a CmdInfo as a simple "cmd-subCmd" string.
      Parameters:
      cmdInfo - the command info record
      Returns:
      simple string representation