// Path: src/com/eyeline/utils/BlankRunnable.java
// public class BlankRunnable implements Runnable{
//     @Override
//     public void run() {}
// }
// 
// Path: src/com/eyeline/utils/DirectoryWatchDog.java
// public abstract class DirectoryWatchDog {
//     private static final Logger log = Logger.getLogger(DirectoryWatchDog.class);
// 
//     protected ExecutorService service =
//             Executors.newSingleThreadExecutor(new NamedThreadFactory(this.getClass().getSimpleName()+"-WatchDog"));
//     protected WatchService watchService;
// 
//     protected abstract void processChangedFile(Path filePath) throws Exception;
//     protected abstract Path getWatchDir();
// 
//     private Runnable listener = new BlankRunnable();
// 
//     private boolean shutup = false;
//     private Future scheduledFuture;
// 
//     @SuppressWarnings("unchecked")
//     public synchronized void start() throws IOException {
//         this.shutup = false;
//         watchService = FileSystems.getDefault().newWatchService();
//         final Path watchDir = getWatchDir();
//         watchDir.register(watchService, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY);
//         scheduledFuture = service.submit(() -> {
//             while (true) {
//                 if (shutup) {
//                     return;
//                 }
//                 WatchKey key;
//                 try {
//                     key = watchService.take();
//                 } catch (InterruptedException x) {
//                     return;
//                 } catch (ClosedWatchServiceException e){
//                     log.warn("",e);
//                     break;
//                 }
//                 for (WatchEvent<?> event : key.pollEvents()) {
//                     WatchEvent.Kind<?> kind = event.kind();
//                     if (kind == StandardWatchEventKinds.OVERFLOW) {
//                         continue;
//                     }
//                     WatchEvent<Path> ev = (WatchEvent<Path>) event;
//                     Path filePath = ev.context();
//                     try {
//                         log.debug("changed file: "+filePath);
//                         this.processChangedFile(watchDir.resolve(filePath));
//                     } catch (Exception e) {
//                         log.warn("Can't process file: "+filePath, e);
//                     } finally {
//                         listener.run();
//                     }
//                 }
//                 boolean valid = key.reset();
//                 if (!valid) {
//                     break;
//                 }
//             }
//         });
//     }
// 
//     public void setListener(Runnable listener) {
//         this.listener = listener;
//     }
// 
//     public synchronized void stop() {
//         this.shutup = true;
//         if (scheduledFuture != null) {
//             scheduledFuture.cancel(false);
//         }
//         if (watchService != null) {
//             try {
//                 watchService.close();
//             } catch (Exception e) {
//                 log.warn("Can't close watchService", e);
//             }
//         }
//     }
// }


import com.eyeline.utils.BlankRunnable;
import com.eyeline.utils.DirectoryWatchDog;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.*;
import java.util.function.Consumer;
import java.util.stream.Stream;
                    String[] data = line.split(Character.toString(delimeter));
                    String subscriber = countryCode + data[0].trim();
                    String title = data[1].trim();
                    MnpParser.Number number = new MnpParser.Number(subscriber, title);
                    try {
                        consumer.accept(number);
                    } catch (Throwable t) {
                        System.err.print("Error at file: "+file+", line: "+line);
                        t.printStackTrace();
                    }
                });
        }
    }

    @Override
    public void parseAllPorted(Consumer<Number> consumer) throws Exception {
        this.parse(dir.resolve(FILENAME_ALL), consumer);
    }

    @Override
    public void parseLastestPorted(Consumer<Number> consumer) throws Exception {
        this.parse(dir.resolve(FILENAME_LASTEST), consumer);
    }

    @Override
    public void parseReturned(Consumer<Number> consumer) throws Exception {
        this.parse(dir.resolve(FILENAME_RETURNED), consumer);
    }


// Path: src/com/eyeline/utils/BlankRunnable.java
// public class BlankRunnable implements Runnable{
//     @Override
//     public void run() {}
// }
// 
// Path: src/com/eyeline/utils/DirectoryWatchDog.java
// public abstract class DirectoryWatchDog {
//     private static final Logger log = Logger.getLogger(DirectoryWatchDog.class);
// 
//     protected ExecutorService service =
//             Executors.newSingleThreadExecutor(new NamedThreadFactory(this.getClass().getSimpleName()+"-WatchDog"));
//     protected WatchService watchService;
// 
//     protected abstract void processChangedFile(Path filePath) throws Exception;
//     protected abstract Path getWatchDir();
// 
//     private Runnable listener = new BlankRunnable();
// 
//     private boolean shutup = false;
//     private Future scheduledFuture;
// 
//     @SuppressWarnings("unchecked")
//     public synchronized void start() throws IOException {
//         this.shutup = false;
//         watchService = FileSystems.getDefault().newWatchService();
//         final Path watchDir = getWatchDir();
//         watchDir.register(watchService, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY);
//         scheduledFuture = service.submit(() -> {
//             while (true) {
//                 if (shutup) {
//                     return;
//                 }
//                 WatchKey key;
//                 try {
//                     key = watchService.take();
//                 } catch (InterruptedException x) {
//                     return;
//                 } catch (ClosedWatchServiceException e){
//                     log.warn("",e);
//                     break;
//                 }
//                 for (WatchEvent<?> event : key.pollEvents()) {
//                     WatchEvent.Kind<?> kind = event.kind();
//                     if (kind == StandardWatchEventKinds.OVERFLOW) {
//                         continue;
//                     }
//                     WatchEvent<Path> ev = (WatchEvent<Path>) event;
//                     Path filePath = ev.context();
//                     try {
//                         log.debug("changed file: "+filePath);
//                         this.processChangedFile(watchDir.resolve(filePath));
//                     } catch (Exception e) {
//                         log.warn("Can't process file: "+filePath, e);
//                     } finally {
//                         listener.run();
//                     }
//                 }
//                 boolean valid = key.reset();
//                 if (!valid) {
//                     break;
//                 }
//             }
//         });
//     }
// 
//     public void setListener(Runnable listener) {
//         this.listener = listener;
//     }
// 
//     public synchronized void stop() {
//         this.shutup = true;
//         if (scheduledFuture != null) {
//             scheduledFuture.cancel(false);
//         }
//         if (watchService != null) {
//             try {
//                 watchService.close();
//             } catch (Exception e) {
//                 log.warn("Can't close watchService", e);
//             }
//         }
//     }
// }


// Path: src/com/eyeline/mnp/parser/ZniisMnpParser.java
import com.eyeline.utils.BlankRunnable;
import com.eyeline.utils.DirectoryWatchDog;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.*;
import java.util.function.Consumer;
import java.util.stream.Stream;

                    String[] data = line.split(Character.toString(delimeter));
                    String subscriber = countryCode + data[0].trim();
                    String title = data[1].trim();
                    MnpParser.Number number = new MnpParser.Number(subscriber, title);
                    try {
                        consumer.accept(number);
                    } catch (Throwable t) {
                        System.err.print("Error at file: "+file+", line: "+line);
                        t.printStackTrace();
                    }
                });
        }
    }

    @Override
    public void parseAllPorted(Consumer<Number> consumer) throws Exception {
        this.parse(dir.resolve(FILENAME_ALL), consumer);
    }

    @Override
    public void parseLastestPorted(Consumer<Number> consumer) throws Exception {
        this.parse(dir.resolve(FILENAME_LASTEST), consumer);
    }

    @Override
    public void parseReturned(Consumer<Number> consumer) throws Exception {
        this.parse(dir.resolve(FILENAME_RETURNED), consumer);
    }


    private Runnable doOnAllUpdates = new BlankRunnable();