001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    
018    package org.apache.commons.jci.listeners;
019    
020    import java.io.File;
021    
022    import org.apache.commons.jci.monitor.FilesystemAlterationObserver;
023    
024    /**
025     * The most simple implemenation of an FilesystemAlterationListener.
026     * 
027     * @author tcurdt
028     */
029    public class FileChangeListener extends AbstractFilesystemAlterationListener {
030    
031        private boolean changed;
032        
033        public boolean hasChanged() {
034            return changed;
035        }
036        
037        @Override
038        public void onStart( final FilesystemAlterationObserver pObserver ) {
039            changed = false;
040            super.onStart(pObserver);
041        }
042    
043        @Override
044        public void onStop( final FilesystemAlterationObserver pObserver ) {
045            super.onStop(pObserver);
046        }
047    
048        
049        @Override
050        public void onFileChange( final File pFile ) {
051            changed = true;
052        }
053    
054    
055        @Override
056        public void onFileCreate( final File pFile ) {
057            changed = true;
058        }
059    
060    
061        @Override
062        public void onFileDelete( final File pFile ) {
063            changed = true;
064        }
065    
066    
067        @Override
068        public void onDirectoryChange( final File pDir ) {
069        }
070    
071        @Override
072        public void onDirectoryCreate( final File pDir ) {
073        }
074    
075        @Override
076        public void onDirectoryDelete( final File pDir ) {
077        }
078        
079    }