Package org.apache.commons.net
Class PrintCommandListener
- java.lang.Object
-
- org.apache.commons.net.PrintCommandListener
-
- All Implemented Interfaces:
java.util.EventListener,ProtocolCommandListener
public class PrintCommandListener extends java.lang.Object implements ProtocolCommandListener
This is a support class for some example programs. It is a sample implementation of the ProtocolCommandListener interface which just prints out to a specified stream all command/reply traffic.- Since:
- 2.0
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringCMD_LOGINprivate static java.lang.StringCMD_PASSprivate static java.lang.StringCMD_USERprivate static java.lang.StringDIRECTION_MARKER_RECEIVEprivate static java.lang.StringDIRECTION_MARKER_SENDprivate chareolMarkerprivate static java.lang.StringHIDDEN_MARKERprivate booleannoLoginprivate booleanshowDirectionprivate java.io.PrintWriterwriter
-
Constructor Summary
Constructors Constructor Description PrintCommandListener(java.io.PrintStream printStream)Constructs an instance which prints everything using the default Charset.PrintCommandListener(java.io.PrintStream printStream, boolean suppressLogin)Constructs an instance which optionally suppresses login command text and indicates where the EOL starts with the specified character.PrintCommandListener(java.io.PrintStream printStream, boolean suppressLogin, char eolMarker)Constructs an instance which optionally suppresses login command text and indicates where the EOL starts with the specified character.PrintCommandListener(java.io.PrintStream printStream, boolean suppressLogin, char eolMarker, boolean showDirection)Constructs an instance which optionally suppresses login command text and indicates where the EOL starts with the specified character.PrintCommandListener(java.io.PrintWriter writer)Constructs the default instance which prints everything.PrintCommandListener(java.io.PrintWriter writer, boolean suppressLogin)Constructs an instance which optionally suppresses login command text.PrintCommandListener(java.io.PrintWriter writer, boolean suppressLogin, char eolMarker)Constructs an instance which optionally suppresses login command text and indicates where the EOL starts with the specified character.PrintCommandListener(java.io.PrintWriter writer, boolean suppressLogin, char eolMarker, boolean showDirection)Constructs an instance which optionally suppresses login command text and indicates where the EOL starts with the specified character.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.StringgetCommand(ProtocolCommandEvent event)private java.lang.StringgetMessage(ProtocolCommandEvent event)private java.lang.StringgetPrintableString(java.lang.String msg)voidprotocolCommandSent(ProtocolCommandEvent event)This method is invoked by a ProtocolCommandEvent source after sending a protocol command to a server.voidprotocolReplyReceived(ProtocolCommandEvent event)This method is invoked by a ProtocolCommandEvent source after receiving a reply from a server.
-
-
-
Field Detail
-
DIRECTION_MARKER_RECEIVE
private static final java.lang.String DIRECTION_MARKER_RECEIVE
- See Also:
- Constant Field Values
-
DIRECTION_MARKER_SEND
private static final java.lang.String DIRECTION_MARKER_SEND
- See Also:
- Constant Field Values
-
HIDDEN_MARKER
private static final java.lang.String HIDDEN_MARKER
- See Also:
- Constant Field Values
-
CMD_LOGIN
private static final java.lang.String CMD_LOGIN
- See Also:
- Constant Field Values
-
CMD_USER
private static final java.lang.String CMD_USER
- See Also:
- Constant Field Values
-
CMD_PASS
private static final java.lang.String CMD_PASS
- See Also:
- Constant Field Values
-
writer
private final java.io.PrintWriter writer
-
noLogin
private final boolean noLogin
-
eolMarker
private final char eolMarker
-
showDirection
private final boolean showDirection
-
-
Constructor Detail
-
PrintCommandListener
public PrintCommandListener(java.io.PrintStream printStream)
Constructs an instance which prints everything using the default Charset.- Parameters:
printStream- where to write the commands and responses e.g. System.out- Since:
- 3.0
-
PrintCommandListener
public PrintCommandListener(java.io.PrintStream printStream, boolean suppressLogin)Constructs an instance which optionally suppresses login command text and indicates where the EOL starts with the specified character.- Parameters:
printStream- where to write the commands and responsessuppressLogin- iftrue, only print command name for login- Since:
- 3.0
-
PrintCommandListener
public PrintCommandListener(java.io.PrintStream printStream, boolean suppressLogin, char eolMarker)Constructs an instance which optionally suppresses login command text and indicates where the EOL starts with the specified character.- Parameters:
printStream- where to write the commands and responsessuppressLogin- iftrue, only print command name for logineolMarker- if non-zero, add a marker just before the EOL.- Since:
- 3.0
-
PrintCommandListener
public PrintCommandListener(java.io.PrintStream printStream, boolean suppressLogin, char eolMarker, boolean showDirection)Constructs an instance which optionally suppresses login command text and indicates where the EOL starts with the specified character.- Parameters:
printStream- where to write the commands and responsessuppressLogin- iftrue, only print command name for logineolMarker- if non-zero, add a marker just before the EOL.showDirection- iftrue, add"> "or"< "as appropriate to the output- Since:
- 3.0
-
PrintCommandListener
public PrintCommandListener(java.io.PrintWriter writer)
Constructs the default instance which prints everything.- Parameters:
writer- where to write the commands and responses
-
PrintCommandListener
public PrintCommandListener(java.io.PrintWriter writer, boolean suppressLogin)Constructs an instance which optionally suppresses login command text.- Parameters:
writer- where to write the commands and responsessuppressLogin- iftrue, only print command name for login- Since:
- 3.0
-
PrintCommandListener
public PrintCommandListener(java.io.PrintWriter writer, boolean suppressLogin, char eolMarker)Constructs an instance which optionally suppresses login command text and indicates where the EOL starts with the specified character.- Parameters:
writer- where to write the commands and responsessuppressLogin- iftrue, only print command name for logineolMarker- if non-zero, add a marker just before the EOL.- Since:
- 3.0
-
PrintCommandListener
public PrintCommandListener(java.io.PrintWriter writer, boolean suppressLogin, char eolMarker, boolean showDirection)Constructs an instance which optionally suppresses login command text and indicates where the EOL starts with the specified character.- Parameters:
writer- where to write the commands and responses, not null.suppressLogin- iftrue, only print command name for logineolMarker- if non-zero, add a marker just before the EOL.showDirection- iftrue, add">" or"< "as appropriate to the output- Since:
- 3.0
-
-
Method Detail
-
getCommand
private java.lang.String getCommand(ProtocolCommandEvent event)
-
getMessage
private java.lang.String getMessage(ProtocolCommandEvent event)
-
getPrintableString
private java.lang.String getPrintableString(java.lang.String msg)
-
protocolCommandSent
public void protocolCommandSent(ProtocolCommandEvent event)
Description copied from interface:ProtocolCommandListenerThis method is invoked by a ProtocolCommandEvent source after sending a protocol command to a server.- Specified by:
protocolCommandSentin interfaceProtocolCommandListener- Parameters:
event- The ProtocolCommandEvent fired.
-
protocolReplyReceived
public void protocolReplyReceived(ProtocolCommandEvent event)
Description copied from interface:ProtocolCommandListenerThis method is invoked by a ProtocolCommandEvent source after receiving a reply from a server.- Specified by:
protocolReplyReceivedin interfaceProtocolCommandListener- Parameters:
event- The ProtocolCommandEvent fired.
-
-