substring extractor

SubString Extractor

Version: 17.07

Supported Since: 17.01

What is a SubString Extractor?

A SubString Extractor is a processing element which can be used to extract a value from the message context, then extract a particular substring of that value providing the starting index and/or ending index as configurations and finally store it as a scope variable.

In order to use this processing element, you must first select the String Processors dependency from the processor list when you are creating an empty Ultra project. If you have already created a project, you can add this dependency via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Processors list, select the String Processors dependency.

Alternatively, you can add the following dependency to the maven pom.xml manually.

<dependency>
    <groupId>org.adroitlogic.x.processors</groupId>
    <artifactId>x-processor-string</artifactId>
    <version>17.07</version>
</dependency>
substring extractor outports

Out Ports

Next

The message will be sent to this outport if the substring extraction operation is successful

On Exception

The message will be sent to this outport if the processing element failed in substring extraction operation

Parameters

Variable Name*

Basic

Name for the scope variable to store the resulting string after substring extraction operation.

Extraction Type*

Basic

Defines how the value which is to be subjected to split operation, is extracted from message context. This is an select type parameter and has following options to be selected from.

  • HEADER - The value of a message transport header should be extracted

  • PROPERTY - The value of a message property should be extracted

  • VARIABLE - The value of a scope variable in any scope should be extracted

  • CURRENT_SCOPE_VARIABLE - The value of a scope variable which is in current scope should be extracted

Extraction Name*

Basic

Depending on the selected Extraction Type, input for this parameter should vary as follows.

  • HEADER - In this case the value of this parameter should be the name of the transport header

  • PROPERTY - In this case the value of this parameter should be the name of the message property

  • VARIABLE - In this case the value of this parameter should be the name of the scope variable

  • CURRENT_SCOPE_VARIABLE - In this case the value of this parameter should be the name of the scope variable in current context.

Begin Index

Basic

Integer parameter which determines the beginning of the substring to be extracted. The default value for this is zero. Note that for a given beginning index, it is inclusive which means the substring will begin from the character that holds that index position in the input string (the value extracted from message context). This parameter will only accept non-negative integer values.

Example 1

Input String: "unhappy"
Begin Index: 2
Resulting SubString: "happy"
Example 2

Input String: "emptiness"
Begin Index: 9
Resulting SubString: "" (an empty string)

Note that the above two examples are considered without an end index parameter. In example 2, since the last character of the string "emptiness" is on index 8 and the given begin index is 9, the returned substring result is an empty string.

The index values for a string starts from zero. For example the string "ultraesb", the character "u" is the 0th index character.

End Index

Basic

Integer parameter which determines the beginning of the substring to be extracted. Note that for a given end index, it is exclusive which means the substring will end one character before the end index in the input string (the value extracted from message context). This parameter will only accept non-negative integer values.

Example 3

Input String: "hamburger"
Begin Index: 4
End Index: 8
Resulting SubString: "urge"
Example 4

Input String: "smiles"
Begin Index: 1
End Index: 5
Resulting SubString: "mile"

Sample Use Case

Substring is a very simple operation which can be useful in many scenarios. Let’s consider the following example say we get a custom header along with an HTTP request. We’ll call that X_ID. Now this X_ID it composed on two parts, the product code and product name with product code having a fixed known length. Say product code has 3 characters then an example an X_ID would be as "PR1-NKSHOES". Now we want to extract out the product code from the X_ID header and use it to decide on how to proceed on the integration flow. In such a scenario the SubString Extractor processing can be of help. This sample scenarios is shown below.

It starts with a NIO HTTP Ingress Connector. Then we have the SubString Extractor processing element, ../flow_control/conditions_evaluator.html element, next we have two NIO HTTP Egress Connector elements to send the message out depending on the condition evaluator result.

substring extractor flow

Here the responsibility of the SubString Extractor processing element is to extract a substring of the given header and simply store it as a scope variable. Then that scope variable will be used by the Conditions Evaluator processing element to take the decision and finally one of the NIO HTTP Egress Connectors will send the message out depending on the path the message comes to them.

substring extractor conf
In this topic
In this topic
Contact Us