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.
For details about using custom icons with your Java operators, see the Java Client library documentation for getIconResource
in com.streambase.sb.operator.Operator
Note
The Java code in this sample is delivered only in source code form. To build the code, you must load the sample into StreamBase Studio, which automatically builds the Java code.
-
In the Package Explorer, notice that the
java-src
directory is imported into thejavaoperator
project. This directory containssample.StringCase.java
, which extendscom.streambase.sb.operator.Operator
. -
Double-click the
StringCase.sbapp
application 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 toJava1
Lowercase
. Change this setting toUppercase
. Do the same for theJava2
operator. -
Select the
StringCase.sbapp
tab in the EventFlow Editor, then click thebutton. 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
symbol
field, enteribm
, and in theprice
field, enter120
, and click . -
In the Application Output View, notice that in OutputStream1, after the write to the Query Table, the symbol string is
IBM
in uppercase. -
Type symbol
Dell
, price40
, and click . -
In the Manual Input view, select
PriceQuery
from the Input Stream list. -
Type symbol
ibm
, and click . The price,120
, is displayed in the Application Output window. -
Type symbol
dElL
in 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.
In StreamBase Studio, import this sample with the following steps:
-
From the top menu, select
→ . -
Select
javaoperator
from the Extending StreamBase category. -
Click OK.
StreamBase Studio creates a project for the sample.
When you load the sample into StreamBase Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.
Important
Load this sample in StreamBase Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.
Using the workspace copy of the sample avoids the permission problems that can occur when trying to work with the initially installed location of the sample. The default workspace location for this sample is:
studio-workspace
/sample_javaoperator
See Default Installation Directories for the location of studio-workspace
on your system.
In the default TIBCO StreamBase installation, this sample's files are initially installed in:
streambase-install-dir
/sample/javaoperator
See Default Installation Directories for the default location of studio-workspace
on your system.