Contents
The StringCase.sbapp sample application uses a Java
operator to change the case of strings. This is then used to implement case-insensitive
query table lookups.
This topic describes the Java operator sample, which includes a StreamBase
application and a Java class that extends com.streambase.sb.streambase.operator.*.
For details about how we used the API to extend com.streambase.sb.operator.*, see Using the StreamBase Java Operator
Wizard in the API Guide. For information about importing
a JAR that contains a Java Operator in StreamBase Studio, and then
selecting an Operator class from that JAR, see Using Java Operators in the
Authoring Guide.
In StreamBase Studio, import this sample with the following steps:
-
From the top menu, click → .
-
Select this sample from the Extending StreamBase list.
-
Click OK.
StreamBase Studio creates a project for the sample.
By default, the sample files are installed in:
-
On Windows:
C:\Program Files\StreamBase Systems\StreamBase.n.m\sample\javaoperator -
On UNIX:
/opt/streambase/sample/javaoperator
When you load the sample into StreamBase Studio, Studio copies the
sample project's files to your Studio workspace. StreamBase Systems
recommends that you use the workspace copy of the sample, especially on UNIX, where
you may not have write access to /opt/streambase. In
the default installation, the path to this sample in your Studio workspace is:
UNIX: ~/streambase-studio-n.m-workspace/sample_javaoperator Windows XP: C:\Documents and Settings\username\My Documents\StreamBase Studion.mWorkspace\ sample_javaoperator Windows Vista: C:\Users\username\Documents\StreamBase Studion.mWorkspace\ sample_javaoperator
-
In the Package Explorer, notice that the
StringCase.jarfile is imported into thejavaoperatorproject. This JAR file contains theStringCase.class, which extendscom.streambase.sb.operator.Operator. -
Double-click the
StringCase.sbappapplication to open it in the EventFlow Editor. -
Click the
operator in the canvas to open its Properties view. In the Parameters tab, notice that the string conversion type (by default) is set toJava1Lowercase. Change this setting toUppercase. Do the same for theJava2operator. -
Select the
StringCase.sbapptab in the EventFlow Editor, then click the
button. The application starts and Studio switches to the SB Test/Debug
perspective.
-
Select the Manual Input view. Select from the Input Stream list.
-
In the
symbolfield, enteribm, and in thepricefield, enter120, and click . -
In the Application Output View, notice that in OutputStream1, after the write to the Query Table, the symbol string is
IBMin uppercase. -
Type symbol
Dell, price40, and click . -
In the Manual Input view, select
PriceQueryfrom the Input Stream list. -
Type symbol
ibm, and click . The price,120, is displayed in the Application Output window. -
Type symbol
dElLin mixed case, and click . The price,40, is displayed in the Application Output window. Notice that the table lookup was successful, because we had stored the string as uppercase, despite the mixed-case initial input. -
When done, press F9 or click the
Stop Running Application button.
