/** * If there are any listeners, send them the command details. * * @param command the command name * @param message the complete message, including command name * @since 3.0 */ protected void fireCommandSent(String command, String message) { if (getCommandSupport().getListenerCount() > 0) { getCommandSupport().fireCommandSent(command, message); } }
/** * If there are any listeners, send them the reply details. * * @param replyCode the code extracted from the reply * @param reply the full reply text * @since 3.0 */ protected void fireReplyReceived(int replyCode, String reply) { if (getCommandSupport().getListenerCount() > 0) { getCommandSupport().fireReplyReceived(replyCode, reply); } }
/** * Overrides {@link SocketClient#fireReplyReceived(int, String)} so as to * avoid creating the reply string if there are no listeners to invoke. * * @param replyCode passed to the listeners * @param ignored the string is only created if there are listeners defined. * @see #getReplyString() * @since 3.4 */ @Override protected void fireReplyReceived(int replyCode, String ignored) { if (getCommandSupport().getListenerCount() > 0) { getCommandSupport().fireReplyReceived(replyCode, getReplyString()); } }
private int __sendCommand(String command, String args, boolean includeSpace) throws IOException { String message; __commandBuffer.setLength(0); __commandBuffer.append(command); if (args != null) { if (includeSpace) __commandBuffer.append(' '); __commandBuffer.append(args); } __commandBuffer.append(SocketClient.NETASCII_EOL); _writer.write(message = __commandBuffer.toString()); _writer.flush(); if (_commandSupport_.getListenerCount() > 0) _commandSupport_.fireCommandSent(command, message); __getReply(); return _replyCode; }
private int __sendCommand(String command, String args, boolean includeSpace) throws IOException { String message; __commandBuffer.setLength(0); __commandBuffer.append(command); if (args != null) { if (includeSpace) __commandBuffer.append(' '); __commandBuffer.append(args); } __commandBuffer.append(SocketClient.NETASCII_EOL); _writer.write(message = __commandBuffer.toString()); _writer.flush(); if (_commandSupport_.getListenerCount() > 0) _commandSupport_.fireCommandSent(command, message); __getReply(); return _replyCode; }
/*** * Sends a command an arguments to the server and returns the reply code. * <p> * @param command The POP3 command to send. * @param args The command arguments. * @return The server reply code (either POP3Reply.OK or POP3Reply.ERROR). ***/ public int sendCommand(String command, String args) throws IOException { String message; __commandBuffer.setLength(0); __commandBuffer.append(command); if (args != null) { __commandBuffer.append(' '); __commandBuffer.append(args); } __commandBuffer.append(SocketClient.NETASCII_EOL); __writer.write(message = __commandBuffer.toString()); __writer.flush(); if (_commandSupport_.getListenerCount() > 0) _commandSupport_.fireCommandSent(command, message); __getReply(); return _replyCode; }
/*** * Sends a command an arguments to the server and returns the reply code. * <p> * @param command The POP3 command to send. * @param args The command arguments. * @return The server reply code (either POP3Reply.OK or POP3Reply.ERROR). ***/ public int sendCommand(String command, String args) throws IOException { String message; __commandBuffer.setLength(0); __commandBuffer.append(command); if (args != null) { __commandBuffer.append(' '); __commandBuffer.append(args); } __commandBuffer.append(SocketClient.NETASCII_EOL); __writer.write(message = __commandBuffer.toString()); __writer.flush(); if (_commandSupport_.getListenerCount() > 0) _commandSupport_.fireCommandSent(command, message); __getReply(); return _replyCode; }
private void __getReply() throws IOException { String line; _replyLines.setSize(0); line = _reader.readLine(); if (line == null) throw new EOFException("Connection closed without indication."); if (line.startsWith(_OK)) _replyCode = POP3Reply.OK; else if (line.startsWith(_ERROR)) _replyCode = POP3Reply.ERROR; else throw new MalformedServerReplyException( "Received invalid POP3 protocol response from server."); _replyLines.addElement(line); _lastReplyLine = line; if (_commandSupport_.getListenerCount() > 0) _commandSupport_.fireReplyReceived(_replyCode, getReplyString()); }
private void __getReply() throws IOException { String line; _replyLines.setSize(0); line = _reader.readLine(); if (line == null) throw new EOFException("Connection closed without indication."); if (line.startsWith(_OK)) _replyCode = POP3Reply.OK; else if (line.startsWith(_ERROR)) _replyCode = POP3Reply.ERROR; else throw new MalformedServerReplyException( "Received invalid POP3 protocol response from server."); _replyLines.addElement(line); _lastReplyLine = line; if (_commandSupport_.getListenerCount() > 0) _commandSupport_.fireReplyReceived(_replyCode, getReplyString()); }
_writer_.flush(); if (_commandSupport_.getListenerCount() > 0) _commandSupport_.fireCommandSent(command, message);
_writer_.flush(); if (_commandSupport_.getListenerCount() > 0) _commandSupport_.fireCommandSent(command, message);
if (_commandSupport_.getListenerCount() > 0) _commandSupport_.fireReplyReceived(_replyCode, getReplyString());
private void __getReply() throws IOException { _replyString = _reader_.readLine(); if (_replyString == null) throw new NNTPConnectionClosedException( "Connection closed without indication."); // In case we run into an anomaly we don't want fatal index exceptions // to be thrown. if (_replyString.length() < 3) throw new MalformedServerReplyException( "Truncated server reply: " + _replyString); try { _replyCode = Integer.parseInt(_replyString.substring(0, 3)); } catch (NumberFormatException e) { throw new MalformedServerReplyException( "Could not parse response code.\nServer Reply: " + _replyString); } if (_commandSupport_.getListenerCount() > 0) _commandSupport_.fireReplyReceived(_replyCode, _replyString + SocketClient.NETASCII_EOL); if (_replyCode == NNTPReply.SERVICE_DISCONTINUED) throw new NNTPConnectionClosedException( "NNTP response 400 received. Server closed connection."); }
if (_commandSupport_.getListenerCount() > 0) _commandSupport_.fireCommandSent(command, message);
if (_commandSupport_.getListenerCount() > 0) _commandSupport_.fireReplyReceived(_replyCode, getReplyString());
if (_commandSupport_.getListenerCount() > 0) _commandSupport_.fireReplyReceived(_replyCode, getReplyString());
private void __getReply() throws IOException { _replyString = _reader_.readLine(); if (_replyString == null) throw new NNTPConnectionClosedException( "Connection closed without indication."); // In case we run into an anomaly we don't want fatal index exceptions // to be thrown. if (_replyString.length() < 3) throw new MalformedServerReplyException( "Truncated server reply: " + _replyString); try { _replyCode = Integer.parseInt(_replyString.substring(0, 3)); } catch (NumberFormatException e) { throw new MalformedServerReplyException( "Could not parse response code.\nServer Reply: " + _replyString); } if (_commandSupport_.getListenerCount() > 0) _commandSupport_.fireReplyReceived(_replyCode, _replyString + SocketClient.NETASCII_EOL); if (_replyCode == NNTPReply.SERVICE_DISCONTINUED) throw new NNTPConnectionClosedException( "NNTP response 400 received. Server closed connection."); }
if (_commandSupport_.getListenerCount() > 0) _commandSupport_.fireCommandSent(command, message);
if (_commandSupport_.getListenerCount() > 0) { _commandSupport_.fireReplyReceived(_replyCode, getReplyString());