Class MessageParser
java.lang.Object
|
+----MessageParser
- public class MessageParser
- extends Object
A class used in parsing a Message.
Written: Radu Sion
Version: 0.41
Source: MessageParser.java
- See Also:
- Message, MessageCreator, MessageConstants
-
MessageParser()
-
-
getDataByte(Message, int)
- Gets a byte from the data area of the Message
Treating the Message as a Data
Message (DataBytes, DataString etc) !!!
(no checkings are done to ensure that it's really a Data Message)
-
getDataBytes(Message)
- Gets the byte array if it's a DataBytes or DataString Message.
-
getDataChar(Message, int)
- Gets a character from the data area of the Message
Treating the Message as a Data
Message (DataBytes, DataString)
(no checkings are done to ensure that it's really a Data Message)
-
getDataString(Message)
- Gets the String if it's a DataString or DataBytes Message.
-
getDescription(Message)
- Tries to get a human readable description of the Message.
-
getDestination(Message)
- Gets the destination number of the Message destination.
-
getDestinationGroup(Message)
- Gets the destination group number of the Message destination.
-
getSender(Message)
- Gets the sender number of the Message sender.
-
getSenderGroup(Message)
- Gets the sender group number of the Message sender.
-
isCHGRP(Message)
- Test if it's a CHGRP (Change Group) Message.
-
isCTS(Message)
- Tests if it's a CTS (Request to send) Message.
-
isData(Message)
- Tests if it's a DataXXXXX Message.
-
isDataBytes(Message)
- Tests if it's a DataBytes Message.
-
isDataString(Message)
- Tests if it's a DataString Message.
-
isDNF(Message)
- Tests if it's a DNF (Destination not found) Message.
-
isDOWN(Message)
- Tests if it's a DOWN (client is down) Message.
-
isINVRQ(Message)
- Tests if it's a INVRQ (Invalid Request) Message.
-
isNOP(Message)
- Tests if it's a NOP (No Operation == ignore) Message.
-
isOK(Message)
-
Tests if it's a OK Message.
-
isRESET(Message)
- Tests if it's a RESET Message.
-
isValid(Message)
- Tests the validity of the Message.
MessageParser
public MessageParser()
isValid
public static boolean isValid(Message message)
- Tests the validity of the Message.
Should be used before any other call to a method of this class.
The CRC is tested , also the whole header.
- Parameters:
- message - The Message to test for validity
- Returns:
- Returns true if valid, false otherwise
getDescription
public static String getDescription(Message message)
- Tries to get a human readable description of the Message.
- Parameters:
- message - The Message to describe
- Returns:
- A description String
getSender
public static int getSender(Message message)
- Gets the sender number of the Message sender.
- Parameters:
- message - The Message to use
getDestination
public static int getDestination(Message message)
- Gets the destination number of the Message destination.
- Parameters:
- message - The Message to use
getSenderGroup
public static int getSenderGroup(Message message)
- Gets the sender group number of the Message sender.
- Parameters:
- message - The Message to use
getDestinationGroup
public static int getDestinationGroup(Message message)
- Gets the destination group number of the Message destination.
- Parameters:
- message - The Message to use
isINVRQ
public static boolean isINVRQ(Message message)
- Tests if it's a INVRQ (Invalid Request) Message.
The INVRQ is generated by the server only.
- Parameters:
- message - The Message to use
- Returns:
- Returns true if INVRQ, false otherwise
isOK
public static boolean isOK(Message message)
- Tests if it's a OK Message.
The OK is generated also by the server as a confirmation of a fullfiled request.
- Parameters:
- message - The Message to use
- Returns:
- Returns true if OK, false otherwise
isCHGRP
public static int isCHGRP(Message message)
- Test if it's a CHGRP (Change Group) Message.
The CHGRP is generated by a client only when it wishes to change it's group
- Parameters:
- message - The Message to use
- Returns:
- It returns the wanted new group if ok, MessageConstants.INVALID otherwise
isDOWN
public static int isDOWN(Message message)
- Tests if it's a DOWN (client is down) Message.
The DOWN is generated by the server when a client is down, in order to notify other clients.
Not implemented yet. [SUBJECT TO CHANGE !!!]
- Parameters:
- message - The Message to use
- Returns:
- It returns the client number that went down if ok, MessageConstants.INVALID otherwise
isNOP
public static boolean isNOP(Message message)
- Tests if it's a NOP (No Operation == ignore) Message.
- Parameters:
- message - The Message to use
- Returns:
- Returns true if it's NOP, false otherwise
isCTS
public static boolean isCTS(Message message)
- Tests if it's a CTS (Request to send) Message.
CTS is server-generated when the client is free to send Messages again.
- Parameters:
- message - The Message to use
- Returns:
- Returns true if it's CTS, false otherwise
isDNF
public static int isDNF(Message message)
- Tests if it's a DNF (Destination not found) Message.
DFN is some INVRQ and should be obsoleted by it.
- Parameters:
- message - The Message to use
- Returns:
- Returns the destination client number if it's DNF, MessageConstants.INVALID otherwise
isRESET
public static boolean isRESET(Message message)
- Tests if it's a RESET Message.
RESET is server generated. On receiving it, the client should efectively reset.
- Parameters:
- message - The Message to test
- Returns:
- Returns true if it's RESET, false otherwise
isData
public static boolean isData(Message message)
- Tests if it's a DataXXXXX Message.
- Parameters:
- message - The Message to test
- Returns:
- True if it a data message, false otherwise
isDataString
public static int isDataString(Message message)
- Tests if it's a DataString Message.
- Parameters:
- message - The Message to test
- Returns:
- The sender number if it's DataString, MessageConstants.INVALID otherwise
isDataBytes
public static int isDataBytes(Message message)
- Tests if it's a DataBytes Message.
- Parameters:
- message - The Message to test
- Returns:
- The sender number if it's DataBytes, MessageConstants.INVALID otherwise
getDataBytes
public static byte[] getDataBytes(Message message)
- Gets the byte array if it's a DataBytes or DataString Message.
- Parameters:
- message - The Message to use
- Returns:
- Returns a byte array if it's DataBytes, null otherwise
getDataString
public static String getDataString(Message message)
- Gets the String if it's a DataString or DataBytes Message.
- Parameters:
- message - The Message to use
- Returns:
- Returns a String if it's DataString, null otherwise
getDataChar
public static char getDataChar(Message message,
int index)
- Gets a character from the data area of the Message
Treating the Message as a Data
Message (DataBytes, DataString)
(no checkings are done to ensure that it's really a Data Message)
- Parameters:
- message - The Message to use
- index - Index in the data area of the Message
- Returns:
- Returns a character from the data area of the Message
getDataByte
public static byte getDataByte(Message message,
int index)
- Gets a byte from the data area of the Message
Treating the Message as a Data
Message (DataBytes, DataString etc) !!!
(no checkings are done to ensure that it's really a Data Message)
- Parameters:
- message - The Message to use
- index - Index in the data area of the Message
- Returns:
- Returns a byte from the data area of the Message