Powered By Blogger

Jul 29, 2016

WSO2 Data Mapper Operators - String category

This post describes about the operators in the String category







  • Concat

This can be used to concat two or more string values

1.Drag and drop the operator to the editor
concat1.png 
2. To configure the operator by specifying the number of inputs and the concat delimiter, right click and select “Configure concat operator” menu action

concat2.png



Eg: name and the origin will concat using the delimiter “,” and maps the result to the description

concatEx.png
  • Split
This can be used to split a string value using a specified delimiter 

split.png

Eg: if the oring value is “French:FR” the the split the origin from “:” and map the ‘French’ and ‘FR’ to origin and value fields


spitEx.png
  • Uppercase

This can be used to convert a string value to uppercase

upper1.png
Eg: make the name to uppercase
upperEx.png
  • Lowercase

This can be used to convert a string value to lowercase

lower.png
Eg: converts the origin to lowercase
lowerEx.png
  • String Length
This can be used to get the length of a string

stringLe.png
Eg: get the length of the value field and map
stringLEx.png
  • StartsWith



This can be used to check whether a String starts with a specific value ( This is not supported in Java 7)

Eg: if the origin value if ORI-French, then we can check if it’s starts with ‘ORI’


1.Drag and drop the operator to the editor
str.png




2. You can give the String value you need to check into the first input box and the string pattern to the other input box. String pattern can be given in two ways as below

-Can give via the dialog box by right click and select “Configure StartsWith operator” menu action and then specify the pattern at {$Pattern}

startEx.png


start2.png



-Can give as an input to the operator either using another operator as shown below or using the input value from the data mapper input tree


startwith3.png

  • Endswith

This can be used to check whether a String ends with a specific value. ( This is not supported in Java 7)

(Works similar to the startsWith operator)
ends.png


  • SubString



This can be used to extracts a part of the String value

Eg: if the description is “VEG-Vegetarian”, then we can extract the VEG part and maps the value


1.Drag and drop the operator to the editor
sub.png


2. You can give the String value into the first input box and the start index and the length to the other two input boxes. Those can be given in two ways as below


-Can give via the dialog box by right click and select “Configure SubString operator” menu action and then specify the start {$Index} and {$Length}

subSt1.png


subst2.png


-Can give as an input to the operator either using two other operators as shown below or using the input values from the data mapper input tree


substr4.png


  • Trim
This can be used to remove white spaces from the beginning and end of a String


trim.png


  • Replace

This can be used to replace the first occurrence of a target String with another


Eg: if the description is “Ctg:Vegetarian”, then we can replace Vegetarian with VEG and maps the value


1.Drag and drop the operator to the editor

replace1.png



2. You can give the String value into the first input box and the target string and the replace with string to the other two input boxes. Those can be given in two ways as below
 
-Can give via the dialog box by right click and select “Configure Replace operator” menu action and then specify the {$Target} and {$Replace}


replace2.png

replace3.png


-Can give as an input to the operator either using two other operators as shown below or using the input values from the data mapper input tree

relce4.png

  • Match

This can be used to check whether the input match with a (JS) Regular Expression

1.Drag and drop the operator to the editor



match1.png


2. You can give the String value into the first input box and the pattern the other input box. The pattern can be given in two ways as below
 

-Can give via the dialog box by right click and select “Configure Match operator” menu action and then specify the {$Pattern}
match2.png

match3.png


-Can give as an input to the operator either using another operator as shown below or using the input values from the data mapper input tree

match4.png






1 comment: