Skip to content

Commit 368541d

Browse files
committed
1.57
1 parent 0dc6898 commit 368541d

File tree

9 files changed

+140
-138
lines changed

9 files changed

+140
-138
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package dev.felnull.fnjl;
22

33
public class FNJLBuildIn {
4-
protected static final String VERSION = "1.56";
4+
protected static final String VERSION = "1.57";
55
}

common/src/main/java/dev/felnull/fnjl/io/watcher/DirectoryTreeWatcherImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package dev.felnull.fnjl.io.watcher;
22

3-
import dev.felnull.fnjl.util.FNArrayUtils;
3+
import dev.felnull.fnjl.util.FNArrayUtil;
44
import org.jetbrains.annotations.ApiStatus;
55

66
import java.io.IOException;
@@ -27,8 +27,8 @@ public class DirectoryTreeWatcherImpl extends FileSystemWatcherImpl {
2727
protected DirectoryTreeWatcherImpl(Path rootPath, WatchEventListener watchEventListener, ThreadFactory threadFactory, boolean flowSymbolic, WatchEvent.Kind<?>... events) throws IOException {
2828
super(watchEventListener, threadFactory);
2929
this.rootPath = rootPath;
30-
if (!FNArrayUtils.contains(events, StandardWatchEventKinds.ENTRY_CREATE)) {
31-
events = FNArrayUtils.add(events, StandardWatchEventKinds.ENTRY_CREATE);
30+
if (!FNArrayUtil.contains(events, StandardWatchEventKinds.ENTRY_CREATE)) {
31+
events = FNArrayUtil.add(events, StandardWatchEventKinds.ENTRY_CREATE);
3232
create = false;
3333
} else {
3434
create = true;
@@ -44,11 +44,11 @@ protected void destroy() {
4444
watchingPaths.clear();
4545
}
4646

47-
public DirectoryTreeWatcherImpl(Path rootPath, WatchEventListener watchEventListener, boolean flowSymbolic, WatchEvent.Kind<?>... events) throws IOException {
47+
protected DirectoryTreeWatcherImpl(Path rootPath, WatchEventListener watchEventListener, boolean flowSymbolic, WatchEvent.Kind<?>... events) throws IOException {
4848
super(watchEventListener, rootPath + "-directory-tree-watcher");
4949
this.rootPath = rootPath;
50-
if (!FNArrayUtils.contains(events, StandardWatchEventKinds.ENTRY_CREATE)) {
51-
events = FNArrayUtils.add(events, StandardWatchEventKinds.ENTRY_CREATE);
50+
if (!FNArrayUtil.contains(events, StandardWatchEventKinds.ENTRY_CREATE)) {
51+
events = FNArrayUtil.add(events, StandardWatchEventKinds.ENTRY_CREATE);
5252
create = false;
5353
} else {
5454
create = true;

common/src/main/java/dev/felnull/fnjl/io/watcher/FileSystemWatcher.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,66 @@ static FileSystemWatcher newFileWatcher(@NotNull Path path, @NotNull FileSystemW
3737
return new FileWatcherImpl(path, watchEventListener, events);
3838
}
3939

40+
/**
41+
* ディレクトリを監視
42+
*
43+
* @param path 監視対象パス
44+
* @param watchEventListener 監視リスナー
45+
* @param threadFactory 監視用スレッドのファクトリー
46+
* @param events 監視イベントの類 StandardWatchEventKinds.ENTRY_MODIFYなど
47+
* @return DirectoryWatcher
48+
* @throws IOException 例外
49+
*/
4050
@NotNull
4151
static FileSystemWatcher newDirectoryWatcher(@NotNull Path path, @NotNull FileSystemWatcher.WatchEventListener watchEventListener, @NotNull ThreadFactory threadFactory, @NotNull WatchEvent.Kind<?>... events) throws IOException {
4252
return new DirectoryWatcherImpl(path, watchEventListener, threadFactory, events);
4353
}
4454

55+
/**
56+
* ディレクトリを監視
57+
*
58+
* @param path  監視対象パス
59+
* @param watchEventListener  監視リスナー
60+
* @param events  監視イベントの類 StandardWatchEventKinds.ENTRY_MODIFYなど
61+
* @return DirectoryWatcher
62+
* @throws IOException 例外
63+
*/
4564
@NotNull
4665
static FileSystemWatcher newDirectoryWatcher(@NotNull Path path, @NotNull FileSystemWatcher.WatchEventListener watchEventListener, @NotNull WatchEvent.Kind<?>... events) throws IOException {
4766
return new DirectoryWatcherImpl(path, watchEventListener, events);
4867
}
4968

69+
/**
70+
* ディレクトリの階層すべてを監視
71+
*
72+
* @param rootPath 監視対象のルートパス
73+
* @param watchEventListener 監視リスナー
74+
* @param threadFactory 監視用スレッドのファクトリー
75+
* @param flowSymbolic シンボルリンクをたどるかどうか
76+
* @param events 監視イベントの類 StandardWatchEventKinds.ENTRY_MODIFYなど
77+
* @return DirectoryTreeWatcher
78+
* @throws IOException 例外
79+
*/
80+
@NotNull
81+
static FileSystemWatcher newDirectoryTreeWatcher(@NotNull Path rootPath, @NotNull WatchEventListener watchEventListener, @NotNull ThreadFactory threadFactory, boolean flowSymbolic, @NotNull WatchEvent.Kind<?>... events) throws IOException {
82+
return new DirectoryTreeWatcherImpl(rootPath, watchEventListener, threadFactory, flowSymbolic, events);
83+
}
84+
85+
/**
86+
* ディレクトリの階層すべてを監視
87+
*
88+
* @param rootPath 監視対象のルートパス
89+
* @param watchEventListener 監視リスナー
90+
* @param flowSymbolic シンボルリンクをたどるかどうか
91+
* @param events 監視イベントの類 StandardWatchEventKinds.ENTRY_MODIFYなど
92+
* @return DirectoryTreeWatcher
93+
* @throws IOException 例外
94+
*/
95+
@NotNull
96+
static FileSystemWatcher newDirectoryTreeWatcher(@NotNull Path rootPath, @NotNull WatchEventListener watchEventListener, boolean flowSymbolic, @NotNull WatchEvent.Kind<?>... events) throws IOException {
97+
return new DirectoryTreeWatcherImpl(rootPath, watchEventListener, flowSymbolic, events);
98+
}
99+
50100
void stop();
51101

52102
interface WatchEventListener {

common/src/main/java/dev/felnull/fnjl/io/watcher/FolderWatcher.java

Lines changed: 0 additions & 103 deletions
This file was deleted.

common/src/main/java/dev/felnull/fnjl/util/FNArrayUtils.java renamed to common/src/main/java/dev/felnull/fnjl/util/FNArrayUtil.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,44 @@
22

33
import java.util.Arrays;
44

5-
public class FNArrayUtils {
5+
public class FNArrayUtil {
66
public static <T> T[] add(T[] array, T element) {
77
T[] n = Arrays.copyOf(array, array.length + 1);
88
n[array.length] = element;
99
return n;
1010
}
1111

12+
public static int[] add(int[] array, int element) {
13+
int[] n = Arrays.copyOf(array, array.length + 1);
14+
n[array.length] = element;
15+
return n;
16+
}
17+
1218
public static <T> T[] add(T[] array, T[] elements) {
1319
T[] n = Arrays.copyOf(array, array.length + elements.length);
1420
System.arraycopy(elements, 0, n, array.length, elements.length);
1521
return n;
1622
}
1723

24+
public static int[] add(int[] array, int[] elements) {
25+
int[] n = Arrays.copyOf(array, array.length + elements.length);
26+
System.arraycopy(elements, 0, n, array.length, elements.length);
27+
return n;
28+
}
29+
1830
public static <T> boolean contains(T[] array, T element) {
1931
for (T t : array) {
2032
if (element.equals(t))
2133
return true;
2234
}
2335
return false;
2436
}
37+
38+
public static boolean contains(int[] array, int element) {
39+
for (int t : array) {
40+
if (element == t)
41+
return true;
42+
}
43+
return false;
44+
}
2545
}

common/src/main/java/dev/felnull/fnjl/util/FNDataUtil.java

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,66 @@ public static FileSystemWatcher watchFile(@NotNull Path path, @NotNull SingleFil
335335
return FileSystemWatcher.newFileWatcher(path, listener, threadFactory, events);
336336
}
337337

338+
/**
339+
* ディレクトリを監視
340+
*
341+
* @param path 監視対象パス
342+
* @param listener 監視リスナー
343+
* @param threadFactory 監視用スレッドのファクトリー
344+
* @param events 監視イベントの類 StandardWatchEventKinds.ENTRY_MODIFYなど
345+
* @return DirectoryWatcher
346+
* @throws IOException 例外
347+
*/
348+
@NotNull
349+
public static FileSystemWatcher watchDirectory(@NotNull Path path, @NotNull FileSystemWatcher.WatchEventListener listener, @NotNull ThreadFactory threadFactory, @NotNull WatchEvent.Kind<?>... events) throws IOException {
350+
return FileSystemWatcher.newDirectoryWatcher(path, listener, threadFactory, events);
351+
}
352+
353+
/**
354+
* ディレクトリを監視
355+
*
356+
* @param path  監視対象パス
357+
* @param listener  監視リスナー
358+
* @param events  監視イベントの類 StandardWatchEventKinds.ENTRY_MODIFYなど
359+
* @return DirectoryWatcher
360+
* @throws IOException 例外
361+
*/
362+
@NotNull
363+
public static FileSystemWatcher watchDirectory(@NotNull Path path, @NotNull FileSystemWatcher.WatchEventListener listener, @NotNull WatchEvent.Kind<?>... events) throws IOException {
364+
return FileSystemWatcher.newDirectoryWatcher(path, listener, events);
365+
}
366+
367+
/**
368+
* ディレクトリの階層すべてを監視
369+
*
370+
* @param rootPath 監視対象のルートパス
371+
* @param listener 監視リスナー
372+
* @param threadFactory 監視用スレッドのファクトリー
373+
* @param flowSymbolic シンボルリンクをたどるかどうか
374+
* @param events 監視イベントの類 StandardWatchEventKinds.ENTRY_MODIFYなど
375+
* @return DirectoryTreeWatcher
376+
* @throws IOException 例外
377+
*/
378+
@NotNull
379+
public static FileSystemWatcher watchDirectoryTree(@NotNull Path rootPath, @NotNull FileSystemWatcher.WatchEventListener listener, @NotNull ThreadFactory threadFactory, boolean flowSymbolic, @NotNull WatchEvent.Kind<?>... events) throws IOException {
380+
return FileSystemWatcher.newDirectoryTreeWatcher(rootPath, listener, threadFactory, flowSymbolic, events);
381+
}
382+
383+
/**
384+
* ディレクトリの階層すべてを監視
385+
*
386+
* @param rootPath 監視対象のルートパス
387+
* @param listener 監視リスナー
388+
* @param flowSymbolic シンボルリンクをたどるかどうか
389+
* @param events 監視イベントの類 StandardWatchEventKinds.ENTRY_MODIFYなど
390+
* @return DirectoryTreeWatcher
391+
* @throws IOException 例外
392+
*/
393+
@NotNull
394+
public static FileSystemWatcher watchDirectoryTree(@NotNull Path rootPath, @NotNull FileSystemWatcher.WatchEventListener listener, boolean flowSymbolic, @NotNull WatchEvent.Kind<?>... events) throws IOException {
395+
return FileSystemWatcher.newDirectoryTreeWatcher(rootPath, listener, flowSymbolic, events);
396+
}
397+
338398
/**
339399
* インプットストリームをアウトプットストリームへ
340400
*

common/src/test/java/dev/felnull/fnjltest/Main.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,6 @@
22

33
public class Main {
44
public static void main(String[] args) throws Exception {
5-
/* DirectoryTreeWatcherImpl dtwi = new DirectoryTreeWatcherImpl(Paths.get("V:\\dev\\java\\FelNullJavaLibrary\\test"), new FileSystemWatcher.WatchEventListener() {
6-
@Override
7-
public void onWatchEvent(WatchEvent<Path> watchEvent, Path path) {
8-
System.out.println(watchEvent.kind().name() + ":" + path.toAbsolutePath());
9-
}
10-
}, false, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_DELETE);*/
115

12-
/*FileSystemWatcher.newDirectoryWatcher(Paths.get("V:\\dev\\java\\FelNullJavaLibrary\\test"), new FileSystemWatcher.WatchEventListener() {
13-
@Override
14-
public void onWatchEvent(WatchEvent<Path> watchEvent, Path path) {
15-
System.out.println(path.toAbsolutePath());
16-
}
17-
}, StandardWatchEventKinds.OVERFLOW, StandardWatchEventKinds.ENTRY_MODIFY);*/
18-
19-
//DirectoryTreeWatcherImpl.registerFiles(Paths.get("V:\\dev\\java\\FelNullJavaLibrary"), false);
20-
21-
/*FolderWatcher fw = new FolderWatcher(Paths.get("V:\\dev\\java\\FelNullJavaLibrary\\test"), new FolderWatcher.FolderWatchListener() {
22-
@Override
23-
public void update(Path path, WatchEvent<?> watchEvent) {
24-
System.out.println(path);
25-
}
26-
});*/
27-
28-
while (true) {
29-
Thread.sleep(1000);
30-
}
316
}
327
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
fnjl_group=dev.felnull
22
fnjl_name=felnull-java-library
3-
fnjl_version=1.56
3+
fnjl_version=1.57
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dev.felnull.fnjln;
22

33
public class FNJLNBuildIn {
4-
protected static final String VERSION = "1.56";
4+
protected static final String VERSION = "1.57";
55

66
protected static final int NATIVE_LIBRARY_VERSION = 1;
77
}

0 commit comments

Comments
 (0)