Package org.approvej.scrub
Class Replacements
java.lang.Object
org.approvej.scrub.Replacements
-
Method Summary
Modifier and TypeMethodDescriptionstatic Replacement<String> Replaces with "[label]" where "label" is the given label.static Replacement<String> masking()Masks each letter or digit of the match with a generic one.static Replacement<String> numbered()Replaces each match with "[scrubbed #]" where#is the number of the distinct replacement.static Replacement<String> Replaces with "[label #]" wherelabelis the given label and#is the number of the distinct replacement.static RelativeDateReplacementReplaces each match of theDateTimeScrubberwith a relative duration, like[today],[yesterday],[in 13 days],[1 year 20 days ago].static RelativeDateTimeReplacementReplaces each match of theDateTimeScrubberwith a relative duration, like[now],[in 1d 23h 59m 59s],[10s ago].static Replacement<String> Replaces each match with the given static replacement string.
-
Method Details
-
numbered
Replaces with "[label #]" wherelabelis the given label and#is the number of the distinct replacement.- Parameters:
label- a String used to identify the replacement- Returns:
- a replacement function that replaces with "
[label #]"
-
numbered
Replaces each match with "[scrubbed #]" where#is the number of the distinct replacement.- Returns:
- a replacement function that replaces with "
[scrubbed #]"
-
labeled
Replaces with "[label]" where "label" is the given label.- Parameters:
label- a String used to identify the replacement- Returns:
- a replacement function that replaces with "
[label]"
-
string
Replaces each match with the given static replacement string.- Parameters:
replacement- the static replacement string- Returns:
- a replacement function that always returns the same string
-
relativeDate
Replaces each match of theDateTimeScrubberwith a relative duration, like[today],[yesterday],[in 13 days],[1 year 20 days ago].- Returns:
- a new
RelativeDateReplacement
-
relativeDateTime
Replaces each match of theDateTimeScrubberwith a relative duration, like[now],[in 1d 23h 59m 59s],[10s ago].- Returns:
- a new
RelativeDateTimeReplacement
-
masking
Masks each letter or digit of the match with a generic one. E.g. all latin uppercase letters are replaced withA, hence the String "John Doe" is replaced with "Aaaa Aaa".This
Replacementis generally useful for well-structured strings that do not vary in length or composition like order numbers, IDs, or strict date/time strings. It is not a good choice for names as they usually vary in length, or UUIDs as they are composed of random characters and digits (hexadecimal).- Returns:
- a replacement function replaces each character with a generic one
-