(String val, int maxLength, boolean rtrim)
| 101 | |
| 102 | // copied from HiveBaseChar |
| 103 | public static String getPaddedValue(String val, int maxLength, boolean rtrim) { |
| 104 | if (val == null) { |
| 105 | return null; |
| 106 | } |
| 107 | if (maxLength < 0) { |
| 108 | return val; |
| 109 | } |
| 110 | |
| 111 | int valLength = val.codePointCount(0, val.length()); |
| 112 | if (valLength > maxLength) { |
| 113 | return enforceMaxLength(val, maxLength); |
| 114 | } |
| 115 | |
| 116 | if (maxLength > valLength && rtrim == false) { |
| 117 | // Make sure we pad the right amount of spaces; valLength is in terms of code points, |
| 118 | // while StringUtils.rpad() is based on the number of java chars. |
| 119 | int padLength = val.length() + (maxLength - valLength); |
| 120 | val = StringUtils.rightPad(val, padLength); |
| 121 | } |
| 122 | return val; |
| 123 | } |
| 124 | |
| 125 | public void testChar(int maxLength, boolean hasRTrim) throws Exception { |
| 126 | // char(n) |
no test coverage detected