Class SimpleMaskingCallback
- java.lang.Object
-
- org.jline.reader.impl.SimpleMaskingCallback
-
- All Implemented Interfaces:
MaskingCallback
public final class SimpleMaskingCallback extends java.lang.Object implements MaskingCallback
SimpleMaskingCallback
that will replace all the characters in the line with the given mask. If the given mask is equal toLineReaderImpl.NULL_MASK
then the line will be replaced with an empty String.
-
-
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.
-
-
-
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 interfaceMaskingCallback
- 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 interfaceMaskingCallback
- 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
-
-