[
https://issues.apache.org/jira/browse/NIFI-6500?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Alessandro D'Armiento updated NIFI-6500:
----------------------------------------
Description:
h2. Current Situation
- [Expression Language string
manipulation|https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#strings]
doesn't have anything to perform string padding
- Existing solutions to achieve left or right padding are unintuitive
-- Es:
${prop:prepend('0000'):substring(${prop:length()},${prop:length():plus(4)})}
h1. Improvement Proposal
- Support two new expression language methods
-- padLeft() will add characters on the left of the string until a certain size
is reached
--- padLeft(int n) will add a default character at the left of the input string
until it reaches the length n
--- padLeft(int n, char c) will add the c characters at the left of the input
string until it reaches the length n
-- padRight()
--- padRight(int n) will add a default character at the right of the input
string until it reaches the length n
--- padRight(int n, char c) will add the c characters at the right of the input
string until it reaches the length n
-- Default character should be a renderable character such as underscore
-- If the input string is already longer than the padding length, no operation
should be performed
h3. Examples
input = "myString"
- ${input:padLeft(10, '#')} => "##myString"
- ${input:padRight(10, '#')} => "myString##"
- ${input:padLeft(10)} => "__myString"
- ${input:padRight(10)} => "myString__"
was:
h2. Current Situation
- [Expression Language string
manipulation|https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#strings]
doesn't have anything to perform string padding
- [Existing
solutions|https://community.hortonworks.com/questions/99856/nifi-padding-string.html]
to achieve left or right padding are unintuitive and could require to
instantiate additional processors
h1. Improvement Proposal
- Support two new expression language methods
-- padLeft() will add characters on the left of the string until a certain size
is reached
--- padLeft(int n) will add a default character at the left of the input string
until it reaches the length n
--- padLeft(int n, char c) will add the c characters at the left of the input
string until it reaches the length n
-- padRight()
--- padRight(int n) will add a default character at the right of the input
string until it reaches the length n
--- padRight(int n, char c) will add the c characters at the right of the input
string until it reaches the length n
-- Default character should be a renderable character such as underscore
-- If the input string is already longer than the padding length, no operation
should be performed
h3. Examples
input = "myString"
- ${input:padLeft(10, '#')} => "##myString"
- ${input:padRight(10, '#')} => "myString##"
- ${input:padLeft(10)} => "__myString"
- ${input:padRight(10)} => "myString__"
> Add padLeft() and padRight() functions to expression language
> -------------------------------------------------------------
>
> Key: NIFI-6500
> URL: https://issues.apache.org/jira/browse/NIFI-6500
> Project: Apache NiFi
> Issue Type: New Feature
> Components: Core Framework
> Affects Versions: 1.9.2
> Reporter: Alessandro D'Armiento
> Priority: Minor
>
> h2. Current Situation
> - [Expression Language string
> manipulation|https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#strings]
> doesn't have anything to perform string padding
> - Existing solutions to achieve left or right padding are unintuitive
> -- Es:
> ${prop:prepend('0000'):substring(${prop:length()},${prop:length():plus(4)})}
> h1. Improvement Proposal
> - Support two new expression language methods
> -- padLeft() will add characters on the left of the string until a certain
> size is reached
> --- padLeft(int n) will add a default character at the left of the input
> string until it reaches the length n
> --- padLeft(int n, char c) will add the c characters at the left of the input
> string until it reaches the length n
> -- padRight()
> --- padRight(int n) will add a default character at the right of the input
> string until it reaches the length n
> --- padRight(int n, char c) will add the c characters at the right of the
> input string until it reaches the length n
> -- Default character should be a renderable character such as underscore
> -- If the input string is already longer than the padding length, no
> operation should be performed
> h3. Examples
> input = "myString"
> - ${input:padLeft(10, '#')} => "##myString"
> - ${input:padRight(10, '#')} => "myString##"
> - ${input:padLeft(10)} => "__myString"
> - ${input:padRight(10)} => "myString__"
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)