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
  • Constructor Details

    • MaskedPasswordBuilder

      public MaskedPasswordBuilder(String stringToMask, String pattern)
      The constructor.
      Parameters:
      stringToMask - The string to mask.
      pattern - The pattern to mask.
  • Method Details

    • hasNext

      public boolean hasNext()
      Returns true if the string to mask has more characters.
      Returns:
      true 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)
      Returns true of the current character is one of the choices.
      Parameters:
      choices - Check whether the current char is one of the choices.
      Returns:
      true of the current character is one of the choices.
    • currentCharIs

      public boolean currentCharIs(Character character)
      Returns true if the current character is character.
      Parameters:
      character - The character to check.
      Returns:
      true if the current character is character.
    • currentCharIsWhitespace

      public boolean currentCharIsWhitespace()
      Returns true if the current character is a whitespace.
      Returns:
      true if the current character is a whitespace.
    • mark

      public void mark()
      Saves the current index, to be used by reset().
    • reset

      public void reset()
      Resets the current character (or index) to the one set by mark().
    • maskPasswordAt

      public void maskPasswordAt(Integer index)
      Appends the password mask at the index.
      Parameters:
      index - the index in the current buffer to append the masked password at.
    • getCurrentIndex

      public int getCurrentIndex()
      Returns the current index.
      Returns:
      the current index.
    • findNextPassword

      public boolean findNextPassword()
      Find the next password in the input.
      Returns:
      true if there is another password to be found in the string to mask.
    • build

      public String build()
      Builds the masked string.
      Returns:
      the masked string.