public class Find extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Find.AndTest
Iff
lhs evaluates to TRUE, then rhs is evaluated and its result is returned. |
static class |
Find.BinaryTest
A
Find.Test with two operand expressions. |
static class |
Find.BooleanTest
Gets and returns the value of a boolean property, or
false if that property is not set. |
static class |
Find.CatAction
Copies the contents of the current file or archive entry to a given
OutputStream and evaluates to true. |
static class |
Find.ChecksumAction
Calculates a "checksum" of an input stream's content and prints it to
Printers.info(String). |
static class |
Find.CommaTest
Evaluates
lhs, then rhs, and returns the result of the latter evaluation. |
static class |
Find.ConstantTest
Evaluates to a constant boolean value.
|
static class |
Find.CopyAction
Copies the contents of the current file or archive entry to a given file and evaluates to
true. |
static class |
Find.DeleteAction
Sets the "prune flag".
|
static class |
Find.DigestAction
Calculates a "message digest" of an input stream's content and prints it to
Printers.info(String). |
static class |
Find.DisassembleAction
Disassembles a Java class file.
|
static class |
Find.EchoAction
Prints one message and returns
true. |
static class |
Find.ExecAction
Executes an external command; the special string "
{}" within the command is replaced with the full
path of the current file, directory or archive entry. |
static class |
Find.ExecutabilityTest
Tests the value of the boolean property "canExecute".
|
static interface |
Find.Expression
Representation of the "FIND expression".
|
static class |
Find.GlobTest
Matches a
Glob with a property value. |
static class |
Find.LsAction
Prints the file type ('d' or '-'), readability ('r' or '-'), writability ('w' or '-'), size, modification time
and path to the given
Writer and evaluates to true. |
static class |
Find.ModificationTimeTest
Representation of a
Find.Test which checks the node's modification time against the current time and a
(days-based) predicate. |
static class |
Find.NameTest
Tests the value of property "name" against a
Glob. |
static class |
Find.NotExpression
Evaluates a delegate expression and negates its result.
|
static class |
Find.OrTest
Iff
lhs evaluates to FALSE, then rhs is evaluated and its result is returned. |
static class |
Find.PathTest
Tests the value of property "path" against a
Glob. |
static class |
Find.PipeAction
Copies the contents of the current file or archive entry to the STDIN of a given command and returns whether the
command exited with status 0.
|
static class |
Find.PredicateTest<T>
Evaluates a predicate for a property's value and returns the result, or
null iff the property is not
set. |
static class |
Find.PrintAction
Prints the path of the current file and returns
true. |
static class |
Find.PrintfAction
Prints one message and returns
true. |
static class |
Find.PruneAction
Sets the "prune flag".
|
static class |
Find.ReadabilityTest
Tests the value of the boolean property "canRead".
|
static class |
Find.SizeTest
Tests the value of the LONG property "size".
|
static class |
Find.StringPredicateTest
Evaluates a property's value, converted to
String, against a predicate. |
static class |
Find.TypeTest
Tests the value of property "type" against a
Glob. |
static class |
Find.UnaryTest
A
Find.Test with one operand expression. |
static class |
Find.WritabilityTest
Tests the value of the boolean property "canWrite".
|
| Constructor and Description |
|---|
Find() |
| Modifier and Type | Method and Description |
|---|---|
static de.unkrig.commons.lang.protocol.Mapping<String,Object> |
fileProperties(String path,
File file)
Returns a mapping of all relevant properties of the given
file. |
void |
findInFile(File file)
Executes the search in the file (which may be a normal file, or a directory).
|
void |
findInResource(String path,
URL resource)
Executes the search in the resource (which may be a normal file, a directory, or any other resource).
|
void |
findInStream(InputStream is)
Executes the search in STDIN, with path "-".
|
Find.Expression |
getExpression()
Getter for the ZZFIND expression.
|
static de.unkrig.commons.text.expression.Expression |
parseExt(String spec) |
static de.unkrig.commons.lang.protocol.Mapping<String,Object> |
resourceProperties(String path,
URL resource) |
void |
setDescendantsFirst(boolean value)
Whether to process each directory's contents before the directory itself, and each archive's entries before
the archive itself, and each compressed contents before the enclosing file or archive entry.
|
Find |
setExceptionHandler(de.unkrig.commons.lang.protocol.ConsumerWhichThrows<? super IOException,IOException> value)
Under some conditions recovery from exceptions within
findInResource(String, URL) and findInStream(InputStream) makes sense, e.g. by continuing with the "next file". |
void |
setExpression(Find.Expression value)
Sets the "find expression", i.e. the construct specified with the "-name", "-print", etc. command line options.
|
void |
setLookIntoFormat(de.unkrig.commons.lang.protocol.Predicate<? super String> value) |
void |
setMaxDepth(int levels)
Descend at most levels of directories below the top level files and directories. "0" means "only
apply the tests and actions to the top level files and directories".
|
void |
setMinDepth(int levels)
Do not apply any tests or actions at levels less than levels.
|
public void setLookIntoFormat(de.unkrig.commons.lang.protocol.Predicate<? super String> value)
value - Is evaluated against "format:path"ArchiveFormatFactory.allFormats(),
ArchiveFormat.getName(),
CompressionFormatFactory.allFormats(),
CompressionFormat.getName()public void setDescendantsFirst(boolean value)
public void setMinDepth(int levels)
public void setMaxDepth(int levels)
public void setExpression(Find.Expression value)
public Find setExceptionHandler(de.unkrig.commons.lang.protocol.ConsumerWhichThrows<? super IOException,IOException> value)
findInResource(String, URL) and findInStream(InputStream) makes sense, e.g. by continuing with the "next file". For this purpose a custom
exception handler can be configured.
The default behavior is to not attempt exception recovery, i.e. findInResource(String, URL) resp.
findInStream(InputStream) complete abnormally on the first IOException that occurs.
public Find.Expression getExpression()
public void findInStream(InputStream is) throws IOException
This method is thread-safe.
IOExceptionpublic void findInResource(String path, URL resource) throws IOException
This method is thread-safe.
IOExceptionpublic void findInFile(File file) throws IOException
This method is thread-safe.
IOExceptionpublic static de.unkrig.commons.lang.protocol.Mapping<String,Object> fileProperties(String path, File file)
file.
"absolutePath":String"canonicalPath":String"lastModifiedDate":Date"name":String"path":String"size":long"isDirectory":boolean"isFile":boolean"isHidden":boolean"isReadable":boolean"isWritable":boolean"isExecutable":booleanpublic static de.unkrig.commons.lang.protocol.Mapping<String,Object> resourceProperties(String path, URL resource)
public static de.unkrig.commons.text.expression.Expression parseExt(String spec)
Copyright © 2019 Arno Unkrig. All rights reserved.