package kuleuven.group2.filewatch;

import java.nio.file.Path;
import java.util.Collection;
import java.util.HashSet;

/**
 * The SourceWatcher class notifies its subscribers of changed method lists in edited .java files.
 * 
 * @author Ruben
 *
 */
public class SourceWatcher implements FolderWatcherSubscriber {
	
	protected Collection<SourceWatcherSubscriber> subscriberList = new HashSet<SourceWatcherSubscriber>();

    
    public void registerSubscriber(SourceWatcherSubscriber subscriber) {
    	subscriberList.add(subscriber);
    }
    
    public boolean isRegisteredAsSubscriber(SourceWatcherSubscriber subscriber) {
    	return subscriberList.contains(subscriber);
    }
    
    public void unregisterSubscriber(SourceWatcherSubscriber subscriber) {
    	if (isRegisteredAsSubscriber(subscriber)) {
    		subscriberList.remove(subscriber);
    	}
    }
    
    public int numberOfSubscribers() {
    	return subscriberList.size();
    }
    
	public void createEvent(Path filePath) {
		if (! interestedInFile(filePath)) {
			return;
		}
	}

	public void modifyEvent(Path filePath) {
		if (! interestedInFile(filePath)) {
			return;
		}
		
	}
	
	private void onModifiedFile(Path filePath) {
		getChangedMethodListForFile(filePath);
		
	}
	
	private void getChangedMethodListForFile(Path filePath) {
		
	}
	
	private void notifyChangedMethod() {
    	for (SourceWatcherSubscriber subscriber : subscriberList) {
    		subscriber.reportChangedMethod();
    	}
	}

	public void deleteEvent(Path filePath) {
		if (! interestedInFile(filePath)) {
			return;
		}
		
	}
	
	private boolean interestedInFile(Path filePath) {
		return filePath.endsWith(".java");
	}


}

@@ -35,36 +35,8 @@
 %0D%0A%0D%0A
-import java.nio.file.Path;%0D%0A
 impo
@@ -90,16 +90,63 @@
 Set;%0D%0A%0D%0A
+import kuleuven.group2.store.StoreListener;%0D%0A%0D%0A
 /**%0D%0A * 
@@ -316,29 +316,19 @@
 nts 
-FolderWatcherSubscrib
+StoreListen
 er %7B
@@ -988,20 +988,16 @@
 %0A    %7D%0D%0A
-    
 %0D%0A%09publi
@@ -1007,33 +1007,41 @@
 oid 
-c
 re
-ateEvent(Path filePath
+sourceAdded(String resourceName
 ) %7B%0D
@@ -1057,37 +1057,45 @@
 interestedIn
-File(filePath
+Resource(resourceName
 )) %7B%0D%0A%09%09%09ret
@@ -1128,33 +1128,43 @@
 oid 
-modifyEvent(Path filePath
+resourceChanged(String resourceName
 ) %7B%0D
@@ -1180,37 +1180,45 @@
 interestedIn
-File(filePath
+Resource(resourceName
 )) %7B%0D%0A%09%09%09ret
@@ -1263,34 +1263,44 @@
 Modified
-File(Path filePath
+Resource(String resourceName
 ) %7B%0D%0A%09%09g
@@ -1321,29 +1321,37 @@
 dListFor
-File(filePath
+Resource(resourceName
 );%0D%0A%09%09%0D%0A
@@ -1394,34 +1394,44 @@
 dListFor
-File(Path filePath
+Resource(String resourceName
 ) %7B%0D%0A%09%09%0D
@@ -1615,33 +1615,43 @@
 oid 
-deleteEvent(Path filePath
+resourceRemoved(String resourceName
 ) %7B%0D
@@ -1675,21 +1675,29 @@
 edIn
-File(filePath
+Resource(resourceName
 )) %7B
@@ -1759,26 +1759,36 @@
 edIn
-File(Path filePath
+Resource(String resourceName
 ) %7B%0D
@@ -1801,16 +1801,20 @@
 urn 
-filePath
+resourceName
 .end

Make SourceWatcher a StoreListener.