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

Constructor Index

 o MessageParser()

Method Index

 o 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)
 o getDataBytes(Message)
Gets the byte array if it's a DataBytes or DataString Message.
 o 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)
 o getDataString(Message)
Gets the String if it's a DataString or DataBytes Message.
 o getDescription(Message)
Tries to get a human readable description of the Message.
 o getDestination(Message)
Gets the destination number of the Message destination.
 o getDestinationGroup(Message)
Gets the destination group number of the Message destination.
 o getSender(Message)
Gets the sender number of the Message sender.
 o getSenderGroup(Message)
Gets the sender group number of the Message sender.
 o isCHGRP(Message)
Test if it's a CHGRP (Change Group) Message.
 o isCTS(Message)
Tests if it's a CTS (Request to send) Message.
 o isData(Message)
Tests if it's a DataXXXXX Message.
 o isDataBytes(Message)
Tests if it's a DataBytes Message.
 o isDataString(Message)
Tests if it's a DataString Message.
 o isDNF(Message)
Tests if it's a DNF (Destination not found) Message.
 o isDOWN(Message)
Tests if it's a DOWN (client is down) Message.
 o isINVRQ(Message)
Tests if it's a INVRQ (Invalid Request) Message.
 o isNOP(Message)
Tests if it's a NOP (No Operation == ignore) Message.
 o isOK(Message)
Tests if it's a OK Message.
 o isRESET(Message)
Tests if it's a RESET Message.
 o isValid(Message)
Tests the validity of the Message.

Constructors

 o MessageParser
 public MessageParser()

Methods

 o 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
 o 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
 o getSender
 public static int getSender(Message message)
Gets the sender number of the Message sender.

Parameters:
message - The Message to use
 o getDestination
 public static int getDestination(Message message)
Gets the destination number of the Message destination.

Parameters:
message - The Message to use
 o getSenderGroup
 public static int getSenderGroup(Message message)
Gets the sender group number of the Message sender.

Parameters:
message - The Message to use
 o getDestinationGroup
 public static int getDestinationGroup(Message message)
Gets the destination group number of the Message destination.

Parameters:
message - The Message to use
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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