-
-
Notifications
You must be signed in to change notification settings - Fork 229
Feature : Allow setting custom linefeed on DefaultXmlPrettyPrinter #568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
374e125
eb23bbd
c0b3e41
3b066cb
8595328
79564a4
f515eba
4cc4394
6974014
b75bfdd
18abcc2
c764189
af70ece
7deeb84
8360276
6187f3d
d0aaf64
29a2bbf
fc4fb17
dd198f2
b43811c
05b1f04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,10 +79,24 @@ public interface Indenter | |
|
||
/** | ||
* By default, will try to set as System.getProperty("line.separator") | ||
* can later set custom lineFeed with withCustomlineFeed method | ||
* Can later set custom lineFeed with withCustomlineFeed method | ||
* @since 2.15 | ||
*/ | ||
protected static String _lineFeed; | ||
private final static String DEFAULT_LINE_FEED; | ||
static { | ||
String lf = null; | ||
try { | ||
lf = System.getProperty("line.separator"); | ||
} catch (Throwable t) { } // access exception? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's just catch There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. late reply, but done 👍🏻 |
||
|
||
if (lf != null) { | ||
DEFAULT_LINE_FEED = lf; | ||
} else { | ||
DEFAULT_LINE_FEED = "\n"; // incase system has changed property name? line.separator | ||
} | ||
} | ||
|
||
protected static String _lineFeed = DEFAULT_LINE_FEED; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pjfanning I have a question. How can we solve this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My thoughts, line-feed outside of Lf2SpacesIndenter? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lf2SpacesIndenter could have a constructor that takes an instance of DefaultXmlPrettyPrinter in its constructor. Or we could make Lf2SpacesIndenter non-static. |
||
|
||
/* | ||
/********************************************************** | ||
|
@@ -133,23 +147,11 @@ public void indentObjectsWith(Indenter i) | |
|
||
public void spacesInObjectEntries(boolean b) { _spacesInObjectEntries = b; } | ||
|
||
/** | ||
* Initialize lineFeed with systemDefault. | ||
* @since 2.15 | ||
*/ | ||
static { | ||
String lf = null; | ||
try { | ||
lf = System.getProperty("line.separator"); | ||
} catch (Throwable t) { } // access exception? | ||
_lineFeed = lf; | ||
} | ||
|
||
/** | ||
* Sets custom linefeed | ||
* @since 2.15 | ||
*/ | ||
public DefaultXmlPrettyPrinter withCustomlineFeed(String lineFeed) { | ||
public DefaultXmlPrettyPrinter withCustomLineFeed(String lineFeed) { | ||
// 06-Feb-2023, joohyukkim: when JacksonException extends RuntimeExceptions, throw it? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you remove this comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done :) |
||
if (lineFeed != null) { | ||
_lineFeed = lineFeed; | ||
|
Uh oh!
There was an error while loading. Please reload this page.