Skip to content

Commit

Permalink
Add release notes, comments, minor renaming. Ready for merge
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 28, 2024
1 parent b93c363 commit 8c6f8e2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
5 changes: 5 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,8 @@ Mathieu Lavigne (@mathieu-lavigne)
* Proposed #45 (and suggested implementation): (csv) Allow skipping ending line break
(`CsvGenerator.Feature.WRITE_LINEFEED_AFTER_LAST_ROW`)
(2.17.0)

Michael Edgar (@MikeEdgar)

* Contributed #465: (yaml) YAML: consider starting `#` and ending `:` as quotable characters
(2.17.0)
3 changes: 3 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Active Maintainers:
=== Releases ===
------------------------------------------------------------------------

#465: (yaml) YAML: consider starting `#` and ending `:` as quotable characters
(contributed by Michael E)

2.17.0-rc1 (26-Feb-2024)

#45: (csv) Allow skipping ending line break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Helper class that defines API used by
* {@link com.fasterxml.jackson.dataformat.yaml.YAMLGenerator}
* to check whether property names and String values need to be quoted or not.
* Also contains default logic implementation; may be sub-classes to provide
* Also contains default logic implementation; may be sub-classed to provide
* alternate implementation.
*
* @since 2.12
Expand Down Expand Up @@ -142,13 +142,15 @@ protected boolean valueHasQuotableChar(String inputStr)
return true;
case '#':
// [dataformats-text#201]: limit quoting with MINIMIZE_QUOTES
if (precededByBlank(inputStr, i)) {
// (but not recognized as comment unless starts line or preceded by whitespace)
if (precededOnlyByBlank(inputStr, i)) {
return true;
}
break;
case ':':
// [dataformats-text#201]: limit quoting with MINIMIZE_QUOTES
if (followedByBlank(inputStr, i)) {
// (but recognized as separator only if end-of-line or followed by whitespace)
if (followedOnlyByBlank(inputStr, i)) {
return true;
}
break;
Expand All @@ -158,21 +160,24 @@ protected boolean valueHasQuotableChar(String inputStr)
return false;
}

private boolean precededByBlank(String inputStr, int offset) {
// @since 2.17
protected boolean precededOnlyByBlank(String inputStr, int offset) {
if (offset == 0) {
return true;
}
return isBlank(inputStr.charAt(offset - 1));
}

private boolean followedByBlank(String inputStr, int offset) {
// @since 2.17
protected boolean followedOnlyByBlank(String inputStr, int offset) {
if (offset == inputStr.length() - 1) {
return true;
}
return isBlank(inputStr.charAt(offset + 1));
}

private boolean isBlank(char value) {
// @since 2.17
protected boolean isBlank(char value) {
return (' ' == value || '\t' == value);
}

Expand Down

0 comments on commit 8c6f8e2

Please sign in to comment.