// Path: fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationListener.java
// public interface FilesystemAlterationListener {
// 
//     void onStart( final FilesystemAlterationObserver pObserver );
//     void onFileCreate( final File pFile );
//     void onFileChange( final File pFile );
//     void onFileDelete( final File pFile );
//     void onDirectoryCreate( final File pDir );
//     void onDirectoryChange( final File pDir );
//     void onDirectoryDelete( final File pDir );
//     void onStop( final FilesystemAlterationObserver pObserver );
// }
// 
// Path: fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationObserver.java
// public interface FilesystemAlterationObserver {
// 
//     File getRootDirectory();
// 
//     void checkAndNotify();
// 
//     void addListener( final FilesystemAlterationListener pListener );
// 
//     void removeListener( final FilesystemAlterationListener pListener );
// 
//     FilesystemAlterationListener[] getListeners();
// 
// }


import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import org.apache.commons.jci2.monitor.FilesystemAlterationListener;
import org.apache.commons.jci2.monitor.FilesystemAlterationObserver;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.commons.jci2.listeners;



/**
 * AbstractFilesystemAlterationListener provides some convenience methods helping to
 * implement a FilesystemAlterationListener.
 * @author tcurdt
 */
public abstract class AbstractFilesystemAlterationListener implements FilesystemAlterationListener {

    private final Log log = LogFactory.getLog(AbstractFilesystemAlterationListener.class);

    private final Collection<File> createdFiles = new ArrayList<File>();
    private final Collection<File> changedFiles = new ArrayList<File>();
    private final Collection<File> deletedFiles = new ArrayList<File>();
    private final Collection<File> createdDirectories = new ArrayList<File>();
    private final Collection<File> changedDirectories = new ArrayList<File>();
    private final Collection<File> deletedDirectories = new ArrayList<File>();


    private final static class Signal {
        public boolean triggered;
    }

    private final Signal eventSignal = new Signal();
    private final Signal checkSignal = new Signal();

    protected FilesystemAlterationObserver observer;

    public void onDirectoryCreate( final File pDir ) {
// Path: fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationListener.java
// public interface FilesystemAlterationListener {
// 
//     void onStart( final FilesystemAlterationObserver pObserver );
//     void onFileCreate( final File pFile );
//     void onFileChange( final File pFile );
//     void onFileDelete( final File pFile );
//     void onDirectoryCreate( final File pDir );
//     void onDirectoryChange( final File pDir );
//     void onDirectoryDelete( final File pDir );
//     void onStop( final FilesystemAlterationObserver pObserver );
// }
// 
// Path: fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationObserver.java
// public interface FilesystemAlterationObserver {
// 
//     File getRootDirectory();
// 
//     void checkAndNotify();
// 
//     void addListener( final FilesystemAlterationListener pListener );
// 
//     void removeListener( final FilesystemAlterationListener pListener );
// 
//     FilesystemAlterationListener[] getListeners();
// 
// }


// Path: fam/src/main/java/org/apache/commons/jci2/listeners/AbstractFilesystemAlterationListener.java
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import org.apache.commons.jci2.monitor.FilesystemAlterationListener;
import org.apache.commons.jci2.monitor.FilesystemAlterationObserver;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.commons.jci2.listeners;



/**
 * AbstractFilesystemAlterationListener provides some convenience methods helping to
 * implement a FilesystemAlterationListener.
 * @author tcurdt
 */
public abstract class AbstractFilesystemAlterationListener implements FilesystemAlterationListener {

    private final Log log = LogFactory.getLog(AbstractFilesystemAlterationListener.class);

    private final Collection<File> createdFiles = new ArrayList<File>();
    private final Collection<File> changedFiles = new ArrayList<File>();
    private final Collection<File> deletedFiles = new ArrayList<File>();
    private final Collection<File> createdDirectories = new ArrayList<File>();
    private final Collection<File> changedDirectories = new ArrayList<File>();
    private final Collection<File> deletedDirectories = new ArrayList<File>();


    private final static class Signal {
        public boolean triggered;
    }

    private final Signal eventSignal = new Signal();
    private final Signal checkSignal = new Signal();

    protected FilesystemAlterationObserver observer;

    public void onDirectoryCreate( final File pDir ) {
        createdDirectories.add(pDir);