Package org.whiteflagprotocol.java.core
Class WfBasicMessage
java.lang.Object
org.whiteflagprotocol.java.core.WfBasicMessage
Whiteflag basic message class
This is a class defining a generic basic Whiteflag message. It
includes common properties and methods of all message types, and
implementation independent logic specified by the Whiteflag standard.
A message is composed of two WfMessageSegment
s: a message
header and a message body.
- Since:
- 1.0
- Whiteflag standard x-reference:
- 4. Message Format
-
Field Summary
Modifier and TypeFieldDescriptionfinal WfMessageSegment
The message bodyfinal WfMessageSegment
The message headerfinal WfMessageType
The type of the message -
Constructor Summary
ModifierConstructorDescriptionprotected
WfBasicMessage
(WfBasicMessage message) Creates a basic Whiteflag message from an existing basic messageprotected
WfBasicMessage
(WfMessageType type, WfMessageSegment header, WfMessageSegment body) Creates a basic Whiteflag message from a header and a body -
Method Summary
Modifier and TypeMethodDescriptionencode()
Encodes the Whiteflag messageGets the value of the specified fieldGets the field names of this messagefinal int
Gets the number of fields in this messageboolean
isValid()
Checks if this message contains valid datafinal boolean
Checks if the specified message field contains valid datafinal boolean
Checks if the provided data is valid for the specified message fieldSerializes the Whiteflag messageboolean
Sets the value of the specified fieldtoString()
Returns the message as a concatinated string of field values
-
Field Details
-
type
The type of the message- Whiteflag standard x-reference:
- 2.4.2 Message Functionality
-
header
The message header- Whiteflag standard x-reference:
- 4.2 Message Header
-
body
The message body- Whiteflag standard x-reference:
- 4.3 Message Body
-
-
Constructor Details
-
WfBasicMessage
Creates a basic Whiteflag message from a header and a body- Parameters:
type
- the message typeheader
- the message headerbody
- the message body
-
WfBasicMessage
Creates a basic Whiteflag message from an existing basic message- Parameters:
message
- the basic message- Since:
- 1.1
-
-
Method Details
-
toString
Returns the message as a concatinated string of field values -
isValid
public boolean isValid()Checks if this message contains valid data- Returns:
- TRUE if all message fields contain valid data, else FALSE
-
isValid
Checks if the specified message field contains valid data- Parameters:
fieldname
- the name of the field- Returns:
- TRUE if the field contains valid data, else FALSE
-
isValid
Checks if the provided data is valid for the specified message field- Parameters:
fieldname
- the name of the fielddata
- the value to be checked- Returns:
- TRUE if the field contains valid data, else FALSE
-
getNoFields
public final int getNoFields()Gets the number of fields in this message- Returns:
- the number of message fields
-
getFieldNames
Gets the field names of this message- Returns:
- a string set with all field names
-
get
Gets the value of the specified field- Parameters:
fieldname
- the name of the requested field- Returns:
- the field value, or NULL if field does not exist
-
set
Sets the value of the specified field- Parameters:
fieldname
- the name of the fielddata
- data to be set as the field value- Returns:
- TRUE if field value is set, FALSE if field does not exits, isalready set, or data is invalid
-
serialize
Serializes the Whiteflag message- Returns:
- the serialized message, i.e. the concatinated string of field values
- Throws:
WfCoreException
- if any of the fields does not contain valid data
-
encode
Encodes the Whiteflag message- Returns:
- a buffer with the binary encoded Whiteflag message
- Throws:
WfCoreException
- if any of the fields does not contain valid data
-