Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse BIRT Report Developer Guide
Previous Page Home Next Page

Previous Next

Class BirtComp

The BirtComp class provides functions to compare values, for example, to test if a value is equal to, greater than, or less than another value. All the functions return either true or false. This class is static. The application cannot create instances of the class.

BirtComp.anyOf

This function tests if a value or values is found in a field.

Syntax

Parameters

source

The field that contains the values to compare to.

target

The value or values to find in source.

Returns

True if a target value matches a value in source; returns false otherwise.

Examples

The following example tests if Canada, Mexico, or USA are values in the Country field. If any one of the countries is in the field, the function returns true.

The following example tests if Jan 15, 2009 or Jan 31, 2009 are values in the payDate field:

The following example tests if two specific product codes are values in the productCode field. If either value appears in the field, the string Obsolete is displayed; otherwise the productCode value is displayed as it appears in the field.

if (BirtComp.anyOf(row["productCode"], "S18_1749", "S18_2248" )){
displayString = "Obsolete"
}
row["productCode"]
}

BirtComp.between

This function tests if a value is between two specified values.

Syntax

Parameters

source

The value to test.

target1

The first value in the range of values to compare to.

target2

The second value in the range of values to compare to.

Returns

True if the source value is between the target1 and target values; returns false otherwise.

Examples

The following expressions test field values to see if they are within a specified range of values:

The following example calculates shipment dates. If an OrderDate value is in December 2008 (between 12/01/08 and 12/31/08), add 5 days to the OrderDate value. If an OrderDate value is in a month other than December, add 3 days to the OrderDate value.

shipDate = BirtDateTime.addDay( row["OrderDate"], 5 )
}
ShipDate = BirtDateTime.addDay( row["OrderDate"], 3 )
}

BirtComp.compareString

This function tests if a string value matches another string value, given specified conditions.

Syntax

Parameters

source1

The first string value to use in the comparison.

source2

The second string value to use in the comparison.

ignoreCase

Specify true to perform a case-insensitive comparison. Specify false to perform a case-sensitive comparison.

trim

Specify true to remove any leading or trailing blanks before comparing the two values. Blanks in the middle of a string are not removed. Specify false if you want the comparison to include leading or trailing blanks.

Returns

True if the source1 value matches the source2 value; returns false otherwise.

Examples

The following expressions compare strings with different conditions specified:

BirtComp.equalTo

This function tests if a value is equal to another value.

Syntax

Parameters

source

The first value to use in the comparison.

target

The second value to use in the comparison.

Returns

True if the source value is equal to the target value; returns false otherwise.

Examples

The following expressions test field values to see if they are equal to specified values:

BirtComp.greaterOrEqual

This function tests if a value is greater than or equal to another value.

Syntax

Parameters

source

The first value to use in the comparison.

target

The second value to use in the comparison.

Returns

True if the source value is greater than or equal to the target value; returns false otherwise.

Examples

The following expressions test field values to see if they are greater than or equal to specified values:

BirtComp.greaterThan

This function tests if a value is greater than another value.

Syntax

Parameters

source

The first value to use in the comparison.

target

The second value to use in the comparison.

Returns

True if the source value is greater than the target value; returns false otherwise.

Examples

The following expressions test field values to see if they are greater than specified values:

BirtComp.lessOrEqual

This function tests if a value is less than or equal to another value.

Syntax

Parameters

source

The first value to use in the comparison.

target

The second value to use in the comparison.

Returns

True if the source value is less than or equal to the target value; returns false otherwise.

Examples

The following expressions test field values to see if they are less than or equal to specified values:

BirtComp.lessThan

This function tests if a value is less than another value.

Syntax

Parameters

source

The first value to use in the comparison.

target

The second value to use in the comparison.

Returns

True if the source value is less than the target value; returns false otherwise.

Examples

The following expressions test field values to see if they are less than specified values:

BirtComp.like

This function tests if a string value matches a pattern. The pattern must use SQL pattern-matching syntax.

Syntax

Parameters

source

The string value to evaluate.

target

The string pattern to match. You must enclose the pattern in double quotation marks (" "). Use the correct case when typing the characters that you want to match. You can use the following special character in a pattern:

n
A percent character (%) matches zero or more characters. For example, %ace% matches any string value that contains the substring ace, such as Facebook and MySpace. It does not match Ace Corporation because this string contains a capital A, and not the lowercase a.
n
An underscore character (_) that matches exactly one character. For example, t_n matches tan, ten, tin, and ton. It does not match teen or tn.

To match a literal percent (%) or underscore (_) character, precede those characters with two backslash (\\) characters. For example, to match S_10, use the following pattern:

To match 50%, use the following pattern:

Returns

True if the source value matches the target value; returns false otherwise.

Examples

The following example returns true for values in the productCode field that start with S18:

The following example returns true for productName values that contain the substring Ford preceded by a single character:

BirtComp.match

This function tests if a string value matches a pattern. The pattern must use JavaScript regular expression syntax.

Syntax

Parameters

source

The string value to evaluate.

target

The string pattern to match. In JavaScript regular expression syntax, you specify a pattern within a pair of forward slash (/) characters. You can use any special character supported by JavaScript regular expressions, such as the following:

n
A question mark character (?) matches zero or one occurrence of the character previous to it. For example, /te?n/ matches tn, ten, and often. It does not match teen or intern.
n
An asterisk character (*) that matches zero or any number of occurrences of the character previous to it. For example, /te*n/ matches tn, ten, often, and teen. It does not match intern.
n
A caret character (^) specifies that the substring to look for is at the beginning of a string. For example, /^ten/ matches ten, tennis, and tense. It does not match often or pretend.

To match a special character literally, precede the special character with a backslash (\) characters. For example, to match S*10, use the following pattern:

To match 50%, use the following pattern:

Returns

True if the source value matches the target value; returns false otherwise.

Examples

The following example returns true for values in the productCode field that start with S18:

The following example returns true for productName values that contain the substring Ford:

BirtComp.notBetween

This function tests if a value is not between two specified values.

Syntax

Parameters

source

The value to test.

target1

The first value in the range of values to compare to.

target2

The second value in the range of values to compare to.

Returns

True if the source value is not between the target1 and target values; returns false otherwise.

Examples

The following expressions test field values to see if they are outside a specified range of values:

The following example calculates shipment dates. If an OrderDate value is not in December 2008 (not between 12/01/08 and 12/31/08), add 3 days to the OrderDate value. If an OrderDate value is in December, add 5days to the OrderDate value.

shipDate = BirtDateTime.addDay( row["OrderDate"], 3 )
}
ShipDate = BirtDateTime.addDay( row["OrderDate"], 5 )
}

BirtComp.notEqual

This function tests if a value is not equal to another value.

Syntax

Parameters

source

The first value to use in the comparison.

target

The second value to use in the comparison.

Returns

True if the source value is not equal to the target value; returns false otherwise.

Examples

The following expressions test field values to see if they are not equal to specified values:

BirtComp.notLike

This function tests if a string value matches a pattern. The pattern must use SQL pattern-matching syntax.

Syntax

Parameters

source

The string value to evaluate.

target

The string pattern to match. You must enclose the pattern in double quotation marks (" "). Use the correct case when typing the characters that you want to match. You can use the following special character in a pattern:

n
A percent character (%) matches zero or more characters. For example, %ace% matches any string value that contains the substring ace, such as Facebook and MySpace. It does not match Ace Corporation because this string contains a capital A, and not the lowercase a.
n
An underscore character (_) that matches exactly one character. For example, t_n matches tan, ten, tin, and ton. It does not match teen or tn.

To match a literal percent (%) or underscore (_) character, precede those characters with two backslash (\\) characters. For example, to match S_10, use the following pattern:

To match 50%, use the following pattern:

Returns

True if the source value does not match the target value; returns false otherwise.

Examples

The following example returns false for values in the productCode field that start with S18:

The following example returns false for productName values that contain the substring Ford preceded by a single character:


(c) Copyright Actuate Corporation 2009

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire