Skip to content

Commit

Permalink
0.6.3 - New Matches interface (implemented by FileFilterUtil.Cache) a…
Browse files Browse the repository at this point in the history
…nd some additional comments/documentation.
  • Loading branch information
TeamworkGuy2 committed Aug 18, 2016
1 parent 4682a1f commit 5f3c0d0
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 16 deletions.
16 changes: 8 additions & 8 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/TestChecks"/>
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jarray-util/jar/jarray_util.jar" sourcepath="/JArrayUtil"/>
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jcollection-interfaces/jar/jcollection_interfaces.jar" sourcepath="/JCollectionInterfaces"/>
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jcollection-util/jar/jcollection_util.jar" sourcepath="/JCollectionUtility"/>
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jfunc/jar/jfunc.jar" sourcepath="/JFunc"/>
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jsimple-types/jar/jsimple_types.jar" sourcepath="/JSimpleTypes/src"/>
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jtext-template/jar/jtext_template.jar"/>
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jtext-util/jar/jtext_util.jar" sourcepath="/JTextUtil"/>
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jtwg2-logging/jar/jtwg2_logging.jar" sourcepath="/JTwg2Logging"/>
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jarray-util/bin/jarray_util.jar" sourcepath="/JArrayUtil"/>
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jcollection-interfaces/bin/jcollection_interfaces.jar" sourcepath="/JCollectionInterfaces"/>
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jcollection-util/bin/jcollection_util.jar" sourcepath="/JCollectionUtility"/>
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jfunc/bin/jfunc.jar" sourcepath="/JFunc"/>
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jsimple-types/bin/jsimple_types.jar" sourcepath="/JSimpleTypes/src"/>
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jtext-template/bin/jtext_template.jar"/>
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jtext-util/bin/jtext_util.jar" sourcepath="/JTextUtil"/>
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jtwg2-logging/bin/jtwg2_logging.jar" sourcepath="/JTwg2Logging"/>
<classpathentry kind="output" path="bin"/>
</classpath>
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ This project does its best to adhere to [Semantic Versioning](http://semver.org/


--------
###[0.6.2](N/A) - 2016-08-13
###[0.6.3](N/A) - 2016-08-18
####Added
* Matches interface with getMatches() and getFailedMatches() (implemented by FileFilterUtil.Cache)
* Additional comments/documentation


--------
###[0.6.2](https://github.com/TeamworkGuy2/JFileIo/commit/4682a1fd40d7b3364aea8f21742f5848ba52fbab) - 2016-08-14
####Added
* ExecuteCmd getInputReader() and getErrorReader() and marked the input and error reader fields volatile

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
JFileIo
==============
version: 0.6.2
version: 0.6.3

Utilities for reading/writing data from/to files in Java. Includes:
* Builders and utility methods for external process execution (i.e. runtime.exec(...))
Expand Down
Binary file modified bin/jfile_io.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion package-lib.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version" : "0.6.2",
"version" : "0.6.3",
"name" : "jfile-io",
"description" : "Java Helpers for File I/O: filtered FileVisitor builders, rolling file renamer, cached buffer file reader, and other File/Path helpers to make Java I/O easier",
"homepage" : "https://github.com/TeamworkGuy2/JFileIo",
Expand Down
8 changes: 6 additions & 2 deletions src/twg2/io/files/FileFilterUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import twg2.text.stringSearch.StringCompare;

/**
/** Contains {@link Cache} and {@link Builder} helpers for filtering files and directories
* @author TeamworkGuy2
* @since 2015-9-19
*/
Expand All @@ -29,7 +29,7 @@ public static String standardizePathName(String path) {
/** A compound {@link FileFilter} that also supports tracking matches and failed matches from
* each call to its {@link #getFileFilter() filter}
*/
public static final class Cache {
public static final class Cache implements Matches<Path> {
private Predicate<Path>[] filters;
private Predicate<Path> compoundFilter;
private List<Path> matches;
Expand Down Expand Up @@ -84,11 +84,13 @@ public Predicate<Path> getFileFilter() {
}


@Override
public List<Path> getMatches() {
return matches;
}


@Override
public List<Path> getFailedMatches() {
return failedMatches;
}
Expand All @@ -97,6 +99,7 @@ public List<Path> getFailedMatches() {




/** {@link FileFilter} builder
*/
public static final class Builder {
Expand Down Expand Up @@ -202,4 +205,5 @@ public Cache buildOrNullIfNoFilters(boolean trackMatches, boolean trackFailedMat

}


}
5 changes: 4 additions & 1 deletion src/twg2/io/files/FileRecursion.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package twg2.io.files;

import java.io.File;
import java.nio.file.FileVisitor;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand All @@ -9,7 +12,7 @@
import java.util.function.Predicate;
import java.util.function.Supplier;

/**
/** For the pre Java 1.7 days, most of this is obsolete now with {@link FileVisitor} and {@link Files#walkFileTree(Path, FileVisitor)}
* @author TeamworkGuy2
* @since 2014-1-1
*/
Expand Down
13 changes: 11 additions & 2 deletions src/twg2/io/files/FileVisitorUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.function.BiFunction;
import java.util.function.Predicate;

/**
/** Contains {@link Cache} and {@link Builder} helpers for creating {@link FileVisitor} and {@link FileFilterUtil.Cache} instances
* @author TeamworkGuy2
* @since 2015-9-19
*/
Expand Down Expand Up @@ -129,6 +129,10 @@ public void setVisitDirectoryFailedDefaultResult(FileVisitResult defaultVisitDir


// ==== build ====
/**
* @return a container containing a {@link FileVisitor} and other filters and caches created from this builder's parameters,
* used for filtering and tracking visited directories and files
*/
public FileVisitorUtil.Cache build() {
FileFilterUtil.Cache preDirFilterCache = preVisitDirFilterBldr != null ? preVisitDirFilterBldr.buildOrNullIfNoFilters() : null;
Predicate<Path> preDirFilter = preDirFilterCache != null ? preDirFilterCache.getFileFilter() : null;
Expand All @@ -149,6 +153,8 @@ public FileVisitorUtil.Cache build() {
}


/** Creates a file visitor which uses a {@link Predicate} to determine whether to {@link FileVisitResult#CONTINUE} or {@link FileVisitResult#SKIP_SUBTREE}
*/
FileVisitor<Path> buildWithDefaultFileVisitResult(Predicate<Path> preDirFilter, Predicate<Path> fileFilter) {
return new FileVisitor<Path>() {
@Override
Expand Down Expand Up @@ -181,6 +187,8 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOEx
}


/** Creates a file visitor which calls optional preVisit, visit, visitFailed, and postVisit functions at each step of the file visit process
*/
FileVisitor<Path> buildWithFuncs(Predicate<Path> preDirFilter, Predicate<Path> fileFilter) {
return new FileVisitor<Path>() {
@Override
Expand Down Expand Up @@ -224,9 +232,10 @@ public static BiFunction<Path, BasicFileAttributes, FileVisitResult> createVisit
/** @return a {@link FileVisitor} failure function which always returns {@link FileVisitResult#CONTINUE}
*/
public static BiFunction<Path, IOException, FileVisitResult> createVisitFailedContinueFunc() {
return (file, exc) -> FileVisitResult.CONTINUE;
return (file, err) -> FileVisitResult.CONTINUE;
}

}


}
16 changes: 16 additions & 0 deletions src/twg2/io/files/Matches.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package twg2.io.files;

import java.util.List;

/** A collection containing matching and non-matching (failed matches) elements
* @author TeamworkGuy2
* @since 2016-08-18
* @param <E> the type of matches/failed matches
*/
public interface Matches<E> {

public List<E> getMatches();

public List<E> getFailedMatches();

}

0 comments on commit 5f3c0d0

Please sign in to comment.