com.latencybusters.lbm.sdm
Class LBMSDMessage

java.lang.Object
  extended by com.latencybusters.lbm.sdm.LBMSDM
      extended by com.latencybusters.lbm.sdm.LBMSDMessage
All Implemented Interfaces:
java.lang.Cloneable

public class LBMSDMessage
extends LBMSDM
implements java.lang.Cloneable

LBMSDMessage is the main class for managing an LBM SDM message. It heavily relies on class LBMSDMFields to collect LBMSDMField and LBMSDMArray classes in to a message. LBMSDMessage is the primary interface for applications.


Field Summary
 
Fields inherited from class com.latencybusters.lbm.sdm.LBMSDM
DEBUG_BASIC, debug_level, DEBUG_VERBOSE_PARSING
 
Constructor Summary
LBMSDMessage()
          Create an empty SDM message
LBMSDMessage(LBMSDMFields args)
          Create an SDM message with a predefined set of fields
LBMSDMessage(LBMSDMFieldsAttribute user_attr)
          Create an empty SDM message using a field set attribute
 
Method Summary
 void add(LBMSDMField f)
          Add a field to a message - the field set will be automatically created if needed
 LBMSDMessage clone()
          Clone an SDM message
 int count()
          Count the number of fields in a message
 byte[] data()
          Get a byte buffer (array) to a raw SDM message in network order.
 LBMSDMFieldsAttribute get_attr()
          Get the field set attributes are associated with this message A copy is returned
 LBMSDMFields get_fset()
          Get the field set that is associated with this message
 LBMSDMField get(int pos)
          Get a field by the index
 int length()
          Get the raw length of the message.
 LBMSDMField locate(java.lang.String name)
          Locate a field by name
 void parse(byte[] buf)
          Parse a byte buffer containing a raw SDM message (as received on a socket) to fill the SDM message object.
 void parse(byte[] buf, int offset)
          Parse a byte buffer containing a raw SDM message (as received on a socket) to fill the SDM message object.
 void remove(int pos)
          Remove a field by specifying the index
 void remove(java.lang.String name)
          Remove a field by specifying the name
 void set(LBMSDMField newfield)
          Set an SDM message field.
 void set(LBMSDMField newfield, int fieldidx)
          Set an SDM message field based on the message element index.
 void set(LBMSDMField newfield, int fieldidx, int arrayidx)
          Set an SDM message field based on the message element index and the array index.
 void set(LBMSDMFields args)
          Add to the SDM message a set of fields.
 boolean test_clone(LBMSDMessage m)
          An api that is used during testing to ensure that cloned objects are truly cloned.
 java.lang.String toDbgString()
          Dump an internal (ascii) representation of this message
 java.lang.String toString()
          Dump a string (ascii) representation of this message
 
Methods inherited from class com.latencybusters.lbm.sdm.LBMSDM
log, set_debug_level
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LBMSDMessage

public LBMSDMessage()
Create an empty SDM message


LBMSDMessage

public LBMSDMessage(LBMSDMFieldsAttribute user_attr)
Create an empty SDM message using a field set attribute

Parameters:
user_attr - A field set attribute object

LBMSDMessage

public LBMSDMessage(LBMSDMFields args)
Create an SDM message with a predefined set of fields

Parameters:
args - The set of fields to be added to the SDM message
Method Detail

set

public void set(LBMSDMFields args)
Add to the SDM message a set of fields. This copies the reference, so the caller must retain the field set until the message no longer needs the field set.

Parameters:
args - The set of fields to be added to the SDM message
See Also:
LBMSDMFields

set

public void set(LBMSDMField newfield)
         throws LBMSDMException
Set an SDM message field. The field name must exist already.

Parameters:
newfield - The new field
Throws:
LBMSDMAddingFieldException - when the field doesn't exist
LBMSDMException

set

public void set(LBMSDMField newfield,
                int fieldidx)
         throws LBMSDMException
Set an SDM message field based on the message element index. The field must exist already.

Parameters:
newfield - The new field
fieldidx - The field index in the message
Throws:
LBMSDMAddingFieldException - when the field doesn't exist
LBMSDMException

set

public void set(LBMSDMField newfield,
                int fieldidx,
                int arrayidx)
         throws LBMSDMException
Set an SDM message field based on the message element index and the array index.

Parameters:
newfield - The new field
fieldidx - The field index in the message
arrayidx - The array index in the field
Throws:
LBMSDMAddingFieldException - when the field doesn't exist
LBMSDMException

get_fset

public LBMSDMFields get_fset()
Get the field set that is associated with this message

Returns:
LBMSDMFields object

get_attr

public LBMSDMFieldsAttribute get_attr()
Get the field set attributes are associated with this message A copy is returned

Returns:
LBMSDMFieldsAttribute object

add

public void add(LBMSDMField f)
         throws LBMSDMException
Add a field to a message - the field set will be automatically created if needed

Parameters:
f - The LBMSDMField object to be added
Throws:
LBMSDMException

remove

public void remove(int pos)
Remove a field by specifying the index

Parameters:
pos - The index of the field

remove

public void remove(java.lang.String name)
Remove a field by specifying the name

Parameters:
name - The field name to be removed

parse

public void parse(byte[] buf,
                  int offset)
           throws LBMSDMException
Parse a byte buffer containing a raw SDM message (as received on a socket) to fill the SDM message object. The byte buffer must be in network order

Parameters:
buf - The byte array (buffer) containing the raw SDM message to be parsed
offset - The index in the array where parsing should start
Throws:
LBMSDMException - if a problem occurs parsing the message buffer, for example if the message has bad data

parse

public void parse(byte[] buf)
           throws LBMSDMException
Parse a byte buffer containing a raw SDM message (as received on a socket) to fill the SDM message object. The byte buffer must be in network order

Parameters:
buf - The byte array (buffer) containing the raw SDM message to be parsed
Throws:
LBMSDMException - if a problem occurs parsing the message buffer for example if the message has bad data

data

public byte[] data()
            throws java.lang.IndexOutOfBoundsException,
                   LBMSDMException
Get a byte buffer (array) to a raw SDM message in network order. This buffer can be transmitted, for example via a socket

Returns:
A byte buffer containing a network ordered raw SDM message
Throws:
java.lang.IndexOutOfBoundsException - if the byte buffer can not be build
LBMSDMException - when an unexpected error occurs within LBMSDM

toDbgString

public java.lang.String toDbgString()
Dump an internal (ascii) representation of this message

Returns:
A string containing the message

toString

public java.lang.String toString()
Dump a string (ascii) representation of this message

Overrides:
toString in class java.lang.Object
Returns:
A string containing the message

clone

public LBMSDMessage clone()
                   throws java.lang.CloneNotSupportedException
Clone an SDM message

Overrides:
clone in class java.lang.Object
Returns:
A complete clone of the message
Throws:
java.lang.CloneNotSupportedException - which should not happen :-)

test_clone

public boolean test_clone(LBMSDMessage m)
                   throws LBMSDMException
An api that is used during testing to ensure that cloned objects are truly cloned. This API is not for general use.

Parameters:
m - An SDM message object to test against this object
Returns:
true if fields are identical (should not be if correctly cloned)
Throws:
LBMSDMException

locate

public LBMSDMField locate(java.lang.String name)
Locate a field by name

Parameters:
name - Name of field being located
Returns:
The relevant LBMSDMField or null

count

public int count()
Count the number of fields in a message

Returns:
The number of fields in the message

length

public int length()
           throws java.lang.IndexOutOfBoundsException,
                  LBMSDMException
Get the raw length of the message. This API will rebuild the message. It is more efficient to call data() and get the length of the returned array instead of calling data() and length()

Returns:
The number of bytes the message will use
Throws:
java.lang.IndexOutOfBoundsException
LBMSDMException

get

public LBMSDMField get(int pos)
Get a field by the index

Parameters:
pos - The index of the field required
Returns:
The LBMSDMField object


All of the documentation and software included in this and any other Informatica Inc "Ultra Messaging" Release is Copyright (C) 2004-2014, Informatica Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted only as covered by the terms of a valid software license agreement with 29West Inc. Copyright © 2004-2014, Informatica, Inc. All Rights Reserved.