/** * Parses the input stream to read the header * * @param input data input to read from * @return the parsed protocol header * @throws IOException */ public static ManagementProtocolHeader parse(DataInput input) throws IOException { validateSignature(input); expectHeader(input, ManagementProtocol.VERSION_FIELD); int version = input.readInt(); expectHeader(input, ManagementProtocol.TYPE); byte type = input.readByte(); switch (type) { case ManagementProtocol.TYPE_REQUEST: return new ManagementRequestHeader(version, input); case ManagementProtocol.TYPE_RESPONSE: return new ManagementResponseHeader(version, input); case ManagementProtocol.TYPE_BYE_BYE: return new ManagementByeByeHeader(version); case ManagementProtocol.TYPE_PING: return new ManagementPingHeader(version); case ManagementProtocol.TYPE_PONG: return new ManagementPongHeader(version); default: throw ProtocolLogger.ROOT_LOGGER.invalidType("0x" + Integer.toHexString(type)); } } }
/** * Parses the input stream to read the header * * @param input data input to read from * @return the parsed protocol header * @throws IOException */ public static ManagementProtocolHeader parse(DataInput input) throws IOException { validateSignature(input); expectHeader(input, ManagementProtocol.VERSION_FIELD); int version = input.readInt(); expectHeader(input, ManagementProtocol.TYPE); byte type = input.readByte(); switch (type) { case ManagementProtocol.TYPE_REQUEST: return new ManagementRequestHeader(version, input); case ManagementProtocol.TYPE_RESPONSE: return new ManagementResponseHeader(version, input); case ManagementProtocol.TYPE_BYE_BYE: return new ManagementByeByeHeader(version); case ManagementProtocol.TYPE_PING: return new ManagementPingHeader(version); case ManagementProtocol.TYPE_PONG: return new ManagementPongHeader(version); default: throw MESSAGES.invalidType("0x" + Integer.toHexString(type)); } } }
/** * Parses the input stream to read the header * * @param input data input to read from * @return the parsed protocol header * @throws IOException */ public static ManagementProtocolHeader parse(DataInput input) throws IOException { validateSignature(input); expectHeader(input, ManagementProtocol.VERSION_FIELD); int version = input.readInt(); expectHeader(input, ManagementProtocol.TYPE); byte type = input.readByte(); switch (type) { case ManagementProtocol.TYPE_REQUEST: return new ManagementRequestHeader(version, input); case ManagementProtocol.TYPE_RESPONSE: return new ManagementResponseHeader(version, input); case ManagementProtocol.TYPE_BYE_BYE: return new ManagementByeByeHeader(version); case ManagementProtocol.TYPE_PING: return new ManagementPingHeader(version); case ManagementProtocol.TYPE_PONG: return new ManagementPongHeader(version); default: throw ProtocolLogger.ROOT_LOGGER.invalidType("0x" + Integer.toHexString(type)); } } }