eglx.rbd package and its StrLib library

The eglx.rbd package contains the StrLib library, which includes functions and constants that are particularly convenient for a subset of users who are migrating code from IBM® Rational® products. For new development, use the more efficient functions in the StringLib library and in the EDT STRING type.

Package

eglx.rbd

Variables
Each of the following StrLib variables is of the EGL STRING type:
  • StrLib.defaultDateFormat
  • StrLib.defaultTimeFormat
  • StrLib.defaultTimeStampFormat
  • StrLib.MoneyFormat
  • StrLib NumericFormat

As shown later, StrLib.defaultDateFormat, StrLib.defaultTimesStampFormat, and StrLib.defaultNumericFormat affect the behavior of a related formatting function in the StrLib library. In addition, you might use any of those variables to provide pattern details when you invoke the StringLib.format function.

Functions
The StrLib functions are written in EGL:
function booleanAsString(value boolean in) returns(string)
/*********************************************************************
* Accept a Boolean value and return the equivalent string.           *
**********************************************************************/
   if ( value )
      return( "true" );
   else
      return( "false" );
   end
	end

function characterLen(text string in) returns(int)
/********************************************************************* 
* Accept a string, remove leading and trailing blanks and nulls,     * 
* and return the number of characters.                               * 
**********************************************************************/
	  return( text.clip().length() );
end
	
function clip(source string? in) returns(string?)
/********************************************************************* 
* Accept a string, remove leading and trailing blanks and nulls,     * 
* and return the string.                                             * 
**********************************************************************/
   if ( source == null )
      return( null );
   else
      return( source.clip() );
   end
end
	
function clip(source string? in, clipType int? in) returns(string?)
/********************************************************************* 
* Accept a string; remove leading blanks and nulls (clipType = 1),   *  
* trailing blanks and nulls (clipType = 2), or both (clipType = 0);  * 
* and return the string.  If clipType is another number, return      * 
* the string as is. If clipType or the string is null, return null.  *
**********************************************************************/
   if ( source == null || clipType == null )
      return( null );
   else
      case ( clipType )
         when (0)
            return( source.trim() );
         when (1)
            return( source.clipLeading() );
         when (2)
            return( source.clip() );
         otherwise
            return( source );
      end
   end
end
	
function formatDate(dateValue date? in) returns(string?)
/********************************************************************* 
* Accept a date and format it in accordance                          *
* with the value of StrLib.defaultDateFormat.                        *
**********************************************************************/
   if ( dateValue == null )
      return( null );
   else
      return( StringLib.format( dateValue, defaultDateFormat ));
   end
end
	
function formatDate(dateValue date? in, format string? in) returns(string?)
/********************************************************************* 
* Accept a date and format it in accordance with an input pattern.   *
* For details on values for the second parameter, see                *
* "Pattern characters used to format non-string values to strings."  *
**********************************************************************/
   if ( dateValue == null || format == null )
      return( null );
   else
      return( StringLib.format( dateValue, format ));
   end
end
	
function formatNumber(value smallint?   in) returns (string?)
function formatNumber(value int?        in) returns (string?)
function formatNumber(value bigint?     in) returns (string?)
function formatNumber(value decimal?    in) returns (string?)
function formatNumber(value smallfloat? in) returns (string?)
function formatNumber(value float?      in) returns (string?)
/********************************************************************* 
* Accept a numeric value and format it in accordance                 *
* with the value of StrLib.defaultNumericFormat.                     *
**********************************************************************/
   if ( value == null )
      return( null );
   else
      return( StringLib.format( value, defaultNumericFormat ) );
   end
end
	
function formatNumber(value smallint?   in, format string? in) returns (string?)
function formatNumber(value int?        in, format string? in) returns (string?)
function formatNumber(value bigint?     in, format string? in) returns (string?)
function formatNumber(value decimal?    in, format string? in) returns (string?)
function formatNumber(value smallfloat? in, format string? in) returns (string?)
function formatNumber(value float?      in, format string? in) returns (string?)
/******************************************************************** 
* Accept a numeric value and format it in accordance with an input  *
* pattern. For details on values for the second parameter, see      *
* "Pattern characters used to format non-string values to strings." *
*********************************************************************/
   if ( value == null || format == null )
      return( null );
   else
      return( StringLib.format( value, format ) );
   end
end

function formatTimeStamp(timestampvalue timestamp("yyyyMMddHHmmssffffff")? in) 
         returns(string?)
/********************************************************************* 
* Accept a timestamp value and format it in accordance               *
* with the value of StrLib.defaultTimestampFormat.                   *
**********************************************************************/
   if ( timestampvalue == null )
      return( null );
   else
      return( StringLib.format( timestampvalue, defaultTimestampFormat ) );
   end
end
	
function formatTimeStamp(timestampvalue timestamp("yyyyMMddHHmmssffffff")? in,
                         format string? in)
         returns (string?)
/********************************************************************* 
* Accept a timestamp value and format it in accordance with an input *
* pattern. For details on values for the second parameter, see       *
* "Pattern characters used to format non-string values to strings."  *
**********************************************************************/
   if ( timestampvalue == null || format == null )
      return( null );
   else
      return( StringLib.format( timestampvalue, format ) );
   end
end

function getNextToken(source string inout, index int inout, delimiters string in)
         returns (string?)
/********************************************************************* 
* Returns a token from a substring that starts at a specified        *
* byte position of an input string.                                  *
*                                                                    *
*    source:                                                         *
*       Takes the input string.                                      *
*    index:                                                          *
*       Takes the starting position at which to begin searching      *
*       for a token, given that the first byte in source is at       *
*       position 1. If a token is found, the value in index is       *
*       changed to the index of the first byte that follows the      *
*       token. If no token is found, index is set to one plus the    *
*       number of bytes in the source string.                        *
*    delimiters:                                                     *
*       Takes a string that contains one or more delimiter           *
*       characters, with no characters separating one from the next. *
**********************************************************************/
   charIndex int = index / 2 + 1;
   token string? = StringLib.getNextToken(source, charIndex, delimiters);
   if ( token != null )
      index = (charIndex - 1) * 2 + 1;
   end
   return( token );
end
	
function getTokenCount(source string in, delimiters string in) returns (int)
/********************************************************************* 
* Returns the number of tokens in a source string                    *
*                                                                    *
*    source:                                                         *
*       Takes the input string.                                      *
*    delimiters:                                                     *
*       Takes a string that contains one or more delimiter           *
*       characters, with no characters separating one from the next. *
**********************************************************************/
   return( StringLib.getTokenCount( source, delimiters ) );
end

function indexOf(source string inout, pattern string in) returns (int)
/*********************************************************************
* Returns an index into a string of characters. The index indicates  *
* the first character position at which a specified pattern starts.  *
* If the pattern is not found, the function returns a zero.          *
*                                                                    *
*    source:                                                         *
*       Takes the input string.                                      *
*    pattern:                                                        *
*       Takes a sequence of characters to search for in source.      *
**********************************************************************/
   return( source.indexOf( pattern ) );
end
	
function indexOf(source string inout, pattern string in, startIndex int in)
         returns (int)
/********************************************************************* 
* Returns an index into a string of characters. The index indicates  *
* the first character position at which a specified pattern starts.  *
*                                                                    *
* The value of the third parameter determines how many characters    * 
* to skip when the function inspects the source string.              * 
*                                                                    *
* If the pattern is not found, the function returns a zero.          *
*                                                                    *
*    source:                                                         *
*       Takes the input string.                                      *
*    pattern:                                                        *
*       Takes a quence of characters to search for in source.        *
*    skipIndex                                                       *
*       Takes a number of characters to skip.                        *
**********************************************************************/
   return( source.indexOf( pattern, startIndex ) );
end
	
function lowerCase(characterItem string? in) returns(string?)
/********************************************************************* 
* Converts all uppercase values in a character string to lowercase   *
* values. Numeric and existing lowercase values are not affected.    *
**********************************************************************/
   if ( characterItem == null )
      return( null );
   else
      return( characterItem.toLowerCase() );
   end
end

function spaces(characterCount int? in) returns(string?)
/********************************************************************* 
* Returns a string of spaces of the specified length.                *
**********************************************************************/
   if ( characterCount == null )
      return( null );
   else
      result string;
      fiftyBlanks string = "                                                  ";
      while ( characterCount >= 50 )
         result ::= fiftyBlanks;
         characterCount -= 50;
      end
      if ( characterCount > 0 )
         result ::= fiftyBlanks[1:characterCount];
      end
      return( result );
   end
end

function upperCase(characterItem string? in) returns(string?)
/********************************************************************* 
* Converts all lowercase values in a character string to uppercase   *
* values. Numeric and existing uppercase values are not affected.    *
**********************************************************************/
   if ( characterItem == null )
      return( null );
   else
      return( characterItem.toUpperCase() );
   end
	end
Comments

The StrLib library is implemented as an EGL library, not as an EGL external type.

Compatibility

Table 1. Compatibility
Target Issue
Java No issues.
JavaScript No issues.