Class SimpleMaskingCallback

    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleMaskingCallback​(java.lang.Character mask)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String display​(java.lang.String line)
      Transforms the line before it is displayed so that sensitive parts can be hidden.
      java.lang.String history​(java.lang.String line)
      Transforms the line before storing it in the history.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SimpleMaskingCallback

        public SimpleMaskingCallback​(java.lang.Character mask)
    • Method Detail

      • display

        public java.lang.String display​(java.lang.String line)
        Description copied from interface: MaskingCallback
        Transforms the line before it is displayed so that sensitive parts can be hidden.

        This method is called by the LineReader whenever the display needs to be updated. It allows the implementation to replace sensitive information with mask characters or other visual indicators while preserving the actual input for processing.

        For example, a password masking implementation might replace each character with an asterisk (*) or hide the input entirely.

        Specified by:
        display in interface MaskingCallback
        Parameters:
        line - the current line being edited (contains the actual input)
        Returns:
        the modified line to display (with sensitive parts masked)
      • history

        public java.lang.String history​(java.lang.String line)
        Description copied from interface: MaskingCallback
        Transforms the line before storing it in the history.

        This method is called by the LineReader when a line is about to be added to the command history. It allows the implementation to remove or redact sensitive information before it is persisted.

        If the return value is empty or null, the line will not be saved in the history at all, which is often appropriate for commands containing passwords or other sensitive data.

        For example, a command like "login --password=secret" might be transformed to "login --password=****" or simply "login" before being stored in history.

        Specified by:
        history in interface MaskingCallback
        Parameters:
        line - the line to be added to history (contains the actual input)
        Returns:
        the modified line for history storage, or null/empty to prevent history storage