Package org.hawaiiframework.logging.util
Class MaskedPasswordBuilder
- java.lang.Object
-
- org.hawaiiframework.logging.util.MaskedPasswordBuilder
-
public class MaskedPasswordBuilder extends Object
A string visitor that builds the same string, but then with masked passwords.- Since:
- 2.0.0
- Author:
- Rutger Lubbers
-
-
Constructor Summary
Constructors Constructor Description MaskedPasswordBuilder(String stringToMask, String pattern)
The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
build()
Builds the masked string.boolean
currentCharIs(Character character)
Returnstrue
if the current character ischaracter
.boolean
currentCharIsOneOf(Character... choices)
Returnstrue
of the current character is one of thechoices
.boolean
currentCharIsWhitespace()
Returnstrue
if the current character is a whitespace.boolean
findNextPassword()
Returnstrue
if there is another password to be found in the string to mask.int
getCurrentIndex()
Returns the current index.boolean
hasNext()
Returnstrue
if the string to mask has more characters.void
mark()
Saves the current index, to be used byreset()
.void
maskPasswordAt(Integer index)
Appends the password mask at theindex
.void
next()
Advances the cursor to the next character.void
reset()
Resets the current character (or index) to the one set bymark()
.
-
-
-
Method Detail
-
hasNext
public boolean hasNext()
Returnstrue
if the string to mask has more characters.
-
next
public void next()
Advances the cursor to the next character.
-
currentCharIsOneOf
public boolean currentCharIsOneOf(Character... choices)
Returnstrue
of the current character is one of thechoices
.
-
currentCharIs
public boolean currentCharIs(Character character)
Returnstrue
if the current character ischaracter
.
-
currentCharIsWhitespace
public boolean currentCharIsWhitespace()
Returnstrue
if the current character is a whitespace.
-
mark
public void mark()
Saves the current index, to be used byreset()
.
-
reset
public void reset()
Resets the current character (or index) to the one set bymark()
.
-
maskPasswordAt
public void maskPasswordAt(Integer index)
Appends the password mask at theindex
.
-
getCurrentIndex
public int getCurrentIndex()
Returns the current index.
-
findNextPassword
public boolean findNextPassword()
Returnstrue
if there is another password to be found in the string to mask.
-
build
public String build()
Builds the masked string.
-
-