Class Sanitizers
- Since:
- 3.5.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final UnaryOperator<String> Replaces non-breaking spaces by regular spaces in the input String.Removes any character from the input String that cannot be printed, such as invisible control characters and unused code points. -
Method Summary
Modifier and TypeMethodDescriptionstatic BiFunction<String, Supplier<String>, String> withContext(Function<String, String> sanitizer) Converts the given sanitizer function to aBiFunction, to provide context information when logging a trace message for characters that were removed.
-
Field Details
-
NON_PRINTABLE_CHARACTERS
Removes any character from the input String that cannot be printed, such as invisible control characters and unused code points. Does not filter out whitespace characters like tabs and line feeds.Logs a message listing the stripped out characters, when found and
TRACElevel is active for this class. You may combine withwithContext(Function)to provide context information for this log message. -
NON_BREAKING_SPACES
Replaces non-breaking spaces by regular spaces in the input String. This shall be used when non-breaking spaces are not desired, for example when storing in the application labels associated to links.This sanitizer does not log any message when a non-breaking space is found, as such character is not considered unexpected nor illegal.
- Since:
- 4.0.0
-
-
Method Details
-
withContext
public static BiFunction<String,Supplier<String>, withContextString> (Function<String, String> sanitizer) Converts the given sanitizer function to aBiFunction, to provide context information when logging a trace message for characters that were removed.The first argument of the
BiFunctionis the value to sanitize. The second argument is to provide context information (e.g."description field of project Power-Training"), to indicate from where the value comes in the application. This context is used to log an accurate message, when some characters are stripped out andTRACElevel is active for this class. It helps an administrator to identify the offending artifact in the application and sanitize it there directly, if desired.- Parameters:
sanitizer- the sanitizing function provided by the Sanitizers class- Returns:
- a BiFunction wrapping the given function
- Throws:
NullPointerException- if sanitizer is nullIllegalArgumentException- if sanitizer is not a function provided by the Sanitizers class- Since:
- 3.7.0
-