// Path: src/main/java/com/github/drapostolos/rdp4j/spi/PolledDirectory.java
// public interface PolledDirectory {
// 
//     /**
//      * Returns a snapshot of the current content in this directory, i.e.
//      * listing all {@link FileElement}s in this directory.
//      * <p>
//      * Returning a {@code null} value will be treated the same as if an {@link IOException} was
//      * thrown.
//      * <p>
//      * NOTE! <br>
//      * All files within a directory are expected to have unique names (i.e. method
//      * {@link FileElement#getName()} is expected to return a name unique among all files within this
//      * directory).
//      * 
//      * @return a list of {@link FileElement}s in this directory
//      * @throws IOException if not possible to list files in this directory, due
//      *         to I/O error. Throwing {@link IOException} will fire a {@link IoErrorRaisedEvent}
//      *         event in {@link IoErrorListener#ioErrorRaised(IoErrorRaisedEvent)}.
//      * @throws DirectoryPollerException For errors you don't want firing {@link IoErrorRaisedEvent}
//      *         events for. This will cause the Directory-Poller
//      *         to silently skip this poll-cycle and wait for next poll-cycle. In Other
//      *         words use this exception when you think it is possible to recover within
//      *         next coming poll-cycles (Keep a MaxRetries counter or similar in your
//      *         implementation).
//      * @throws RuntimeException if any unexpected crashes occurs. This will
//      *         cause the Directory-Poller to log an error message (along with the causing
//      *         {@link RuntimeException}) and stop the {@link DirectoryPoller}.
//      */
//     Set<FileElement> listFiles() throws IOException;
// 
//     /**
//      * It is recommended to implement this method if clients wants to remove this
//      * {@link PolledDirectory} from the {@link DirectoryPoller}.
//      * 
//      * @param obj Object to compare.
//      */
//     @Override
//     public boolean equals(Object obj);
// 
//     /**
//      * It is recommended to implement this method if clients wants to remove this
//      * {@link PolledDirectory} using {@link DirectoryPoller#removePolledDirectory(PolledDirectory)}
//      * .
//      */
//     @Override
//     public int hashCode();
// }


import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.drapostolos.rdp4j.spi.PolledDirectory;
package com.github.drapostolos.rdp4j;




/**
 * This is a Skeletal implementation of all {@link Rdp4jListener} sub-interfaces.
 * Contains default implementations of all methods.
 * <p>
 * It is up to the client to implement any desired methods.
 * 
 * @see <a href="https://github.com/drapostolos/rdp4j/wiki/User-Guide">User-Guide</a>
 */
public abstract class AbstractRdp4jListener implements DirectoryListener, IoErrorListener, DirectoryPollerListener,
        PollCycleListener, InitialContentListener {

    private static final Logger LOG = LoggerFactory.getLogger(AbstractRdp4jListener.class);

    /**
     * Dummy implementation doing nothing.
     */
    @Override
    public void beforeStart(BeforeStartEvent event) {

    }

    /**
     * Dummy implementation doing nothing.
     */
    @Override
    public void afterStop(AfterStopEvent event) {

    }

    /**
     * Dummy implementation doing nothing.
     * 
     * @throws InterruptedException when interrupted.
     */
    @Override
    public void beforePollingCycle(BeforePollingCycleEvent event) throws InterruptedException {

    }

    /**
     * Dummy implementation doing nothing.
     * 
     * @throws InterruptedException when interrupted.
     */
    @Override
    public void afterPollingCycle(AfterPollingCycleEvent event) throws InterruptedException {

    }

    /**
     * Logs any occurred I/O errors
     * 
     * @throws InterruptedException when interrupted.
     */
    @Override
    public void ioErrorRaised(IoErrorRaisedEvent event) throws InterruptedException {
        String message = "I/O error raised when polling directory '%s'!";
        PolledDirectory dir = event.getPolledDirectory();
        IOException e = event.getIoException();
        LOG.error(String.format(message, dir), e);
    }

    /**
     * Logs when an I/O error has ceased.
     * 
     * @throws InterruptedException when interrupted.
     */
    @Override
    public void ioErrorCeased(IoErrorCeasedEvent event) throws InterruptedException {
        String message = "I/O error ceased when polling directory '%s'!";
// Path: src/main/java/com/github/drapostolos/rdp4j/spi/PolledDirectory.java
// public interface PolledDirectory {
// 
//     /**
//      * Returns a snapshot of the current content in this directory, i.e.
//      * listing all {@link FileElement}s in this directory.
//      * <p>
//      * Returning a {@code null} value will be treated the same as if an {@link IOException} was
//      * thrown.
//      * <p>
//      * NOTE! <br>
//      * All files within a directory are expected to have unique names (i.e. method
//      * {@link FileElement#getName()} is expected to return a name unique among all files within this
//      * directory).
//      * 
//      * @return a list of {@link FileElement}s in this directory
//      * @throws IOException if not possible to list files in this directory, due
//      *         to I/O error. Throwing {@link IOException} will fire a {@link IoErrorRaisedEvent}
//      *         event in {@link IoErrorListener#ioErrorRaised(IoErrorRaisedEvent)}.
//      * @throws DirectoryPollerException For errors you don't want firing {@link IoErrorRaisedEvent}
//      *         events for. This will cause the Directory-Poller
//      *         to silently skip this poll-cycle and wait for next poll-cycle. In Other
//      *         words use this exception when you think it is possible to recover within
//      *         next coming poll-cycles (Keep a MaxRetries counter or similar in your
//      *         implementation).
//      * @throws RuntimeException if any unexpected crashes occurs. This will
//      *         cause the Directory-Poller to log an error message (along with the causing
//      *         {@link RuntimeException}) and stop the {@link DirectoryPoller}.
//      */
//     Set<FileElement> listFiles() throws IOException;
// 
//     /**
//      * It is recommended to implement this method if clients wants to remove this
//      * {@link PolledDirectory} from the {@link DirectoryPoller}.
//      * 
//      * @param obj Object to compare.
//      */
//     @Override
//     public boolean equals(Object obj);
// 
//     /**
//      * It is recommended to implement this method if clients wants to remove this
//      * {@link PolledDirectory} using {@link DirectoryPoller#removePolledDirectory(PolledDirectory)}
//      * .
//      */
//     @Override
//     public int hashCode();
// }


// Path: src/main/java/com/github/drapostolos/rdp4j/AbstractRdp4jListener.java
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.drapostolos.rdp4j.spi.PolledDirectory;

package com.github.drapostolos.rdp4j;




/**
 * This is a Skeletal implementation of all {@link Rdp4jListener} sub-interfaces.
 * Contains default implementations of all methods.
 * <p>
 * It is up to the client to implement any desired methods.
 * 
 * @see <a href="https://github.com/drapostolos/rdp4j/wiki/User-Guide">User-Guide</a>
 */
public abstract class AbstractRdp4jListener implements DirectoryListener, IoErrorListener, DirectoryPollerListener,
        PollCycleListener, InitialContentListener {

    private static final Logger LOG = LoggerFactory.getLogger(AbstractRdp4jListener.class);

    /**
     * Dummy implementation doing nothing.
     */
    @Override
    public void beforeStart(BeforeStartEvent event) {

    }

    /**
     * Dummy implementation doing nothing.
     */
    @Override
    public void afterStop(AfterStopEvent event) {

    }

    /**
     * Dummy implementation doing nothing.
     * 
     * @throws InterruptedException when interrupted.
     */
    @Override
    public void beforePollingCycle(BeforePollingCycleEvent event) throws InterruptedException {

    }

    /**
     * Dummy implementation doing nothing.
     * 
     * @throws InterruptedException when interrupted.
     */
    @Override
    public void afterPollingCycle(AfterPollingCycleEvent event) throws InterruptedException {

    }

    /**
     * Logs any occurred I/O errors
     * 
     * @throws InterruptedException when interrupted.
     */
    @Override
    public void ioErrorRaised(IoErrorRaisedEvent event) throws InterruptedException {
        String message = "I/O error raised when polling directory '%s'!";
        PolledDirectory dir = event.getPolledDirectory();
        IOException e = event.getIoException();
        LOG.error(String.format(message, dir), e);
    }

    /**
     * Logs when an I/O error has ceased.
     * 
     * @throws InterruptedException when interrupted.
     */
    @Override
    public void ioErrorCeased(IoErrorCeasedEvent event) throws InterruptedException {
        String message = "I/O error ceased when polling directory '%s'!";
        PolledDirectory dir = event.getPolledDirectory();