Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-6500

Add padLeft() and padRight() functions to expression language

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.9.2
    • 1.10.0
    • Core Framework
    • None

    Description

      Current Situation

      • Existing solutions to achieve left or right padding are unintuitive
        • Es: ${prop:prepend('0000'):substring(${prop:length()},${prop:length():plus(4)})}

      Improvement Proposal

      • Support two new expression language methods
        • padLeft:
          • padLeft(int n) will prepend a default character to of the input string until it reaches the length n
          • padLeft(int n, char c) will prepend the c characters to the input string until it reaches the length n
        • padRight:
          • padRight(int n) will append a default character to the input string until it reaches the length n
          • padRight(int n, char c) will append the c character to 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

      Examples


      input = "myString"


      • ${input:padLeft(10, '#')} => "##myString"
      • ${input:padRight(10, '#')} => "myString##"
      • ${input:padLeft(10)} => "__myString"
      • ${input:padRight(10)} => "myString__"

      Attachments

        Issue Links

          Activity

            People

              AxelSync Alessandro D'Armiento
              AxelSync Alessandro D'Armiento
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 7.5h
                  7.5h