| 1400 | } |
| 1401 | |
| 1402 | public static void trim(TrimType type, CharSequence str, StringSink sink) { |
| 1403 | if (str == null) { |
| 1404 | return; |
| 1405 | } |
| 1406 | int startIdx = 0; |
| 1407 | int endIdx = str.length() - 1; |
| 1408 | if (type == TrimType.LTRIM || type == TrimType.TRIM) { |
| 1409 | while (startIdx < endIdx && str.charAt(startIdx) == ' ') { |
| 1410 | startIdx++; |
| 1411 | } |
| 1412 | } |
| 1413 | if (type == TrimType.RTRIM || type == TrimType.TRIM) { |
| 1414 | while (startIdx < endIdx && str.charAt(endIdx) == ' ') { |
| 1415 | endIdx--; |
| 1416 | } |
| 1417 | } |
| 1418 | sink.clear(); |
| 1419 | if (startIdx != endIdx) { |
| 1420 | sink.put(str, startIdx, endIdx + 1); |
| 1421 | } |
| 1422 | } |
| 1423 | |
| 1424 | public static void unescape(@NotNull CharSequence cs, int start, int end, char unescape, @NotNull Utf16Sink sink) { |
| 1425 | final int lastChar = end - 1; |